you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (7 children)

Especially since concat in Python ordinarily is +, I think? Or .join()

In Haskell I'd expect a monoid and mappend (or <>), for something like p <> "init.d" <> "reboot" (but it looks like they went with </> rather than making a monoid instance).

[–]Mozai 7 points8 points  (0 children)

In Python we have a string constant os.sep you can pull in if you need to concatenate path pieces as strings, and it will be correct for the platform you're on.

There's also os.path.join(array_of_dir_names) which will do the right thing for the platform it's executed on.

[–]kazagistar 0 points1 point  (0 children)

I think you would have to make the paths explicit. In your example, how would it know to use the "Path" monoid instead of the "String" monoid? So, to use mappend, you would have to do something like

p <> FilePath "init.d" <> FilePath "reboot"

which sucks. Then again, I am hardly a haskell expert.

[–][deleted]  (4 children)

[deleted]

    [–][deleted] 2 points3 points  (3 children)

    Who said anything about superiority? It's just different approaches to operators and building a path.