2

What does this symbol </> means in Haskell?

What is it called?

How to use it?

I use ghc 7.8 to compile the application.

linquize
  • 19,828
  • 10
  • 59
  • 83
  • 5
    Instead of a downvote how about teaching how to fish? @linquize, http://www.haskell.org/hoogle/ lets you search for symbols too. – Sean Perry Jun 03 '14 at 16:18
  • 2
    And note it isn't really defined by Haskell as a language but by a library. You could define your own procedure named `>` that performs any arbitrary operation, such as formatting your harddrive. – Thomas M. DuBuisson Jun 03 '14 at 16:43
  • An alternative to hoogle would be `:i (>)` in GHCi, which will give you the type of the function and the module it comes from. – Jeff Burka Jun 03 '14 at 17:16
  • @JeffBurka - because "Top Level: Not in scope" is helpful? – Richard Huxton Jun 03 '14 at 21:21
  • @Richard If you see this symbol in a file you're looking at, as OP seems to have done, then when you load that file in GHCi, it will be in scope. If you just see it online somewhere, then no GHCi won't be much help. – Jeff Burka Jun 04 '14 at 02:11

1 Answers1

11

It's an alias for combine.

Combine two paths, if the second path isAbsolute, then it returns the second.

Valid x => combine (takeDirectory x) (takeFileName x) `equalFilePath` x
Posix:   combine "/" "test" == "/test"
Posix:   combine "home" "bob" == "home/bob"
Windows: combine "home" "bob" == "home\\bob"
Windows: combine "home" "/bob" == "/bob"
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • 1
    Why? Because ``<>`` is the operator for the ``mappend`` operation which is the generic version of the ``++`` operator. So ``>`` is meant to look like 'join with slash'. – Sean Perry Jun 03 '14 at 16:20
  • I like this function in haskell, in C# we have `Path.Combine()` which is cross-platform too. – linquize Jun 03 '14 at 16:21
  • SeanPerry: That's an interesting observation. I never thought of that. I wonder if it would make sense for `FilePath` to be a `newtype` and `combine` the `mappend` of its `Monoid` instance ... – Tom Ellis Jun 03 '14 at 17:03
  • 3
    @TomEllis If you'd rather use a `newtype` you might as well go all the way and switch to something like [`system-filepath`](https://hackage.haskell.org/package/system-filepath). – duplode Jun 03 '14 at 18:30
  • 1
    @duplode: Yes I see that has exactly the behaviour I was thinking of. Nice. – Tom Ellis Jun 03 '14 at 19:11