Max Li
Max Li

Reputation: 591

What does "<>" mean in haskell sample code?

I have done lots of googling and failed in figuring this question out. Partially because google does not treat "<>" as a keyword. I see this "operator" from the code sample at optparse-applicative sample

Anybody knows the meaning of "<>" in haskell please help. Thanks!

Upvotes: 1

Views: 108

Answers (1)

Libby
Libby

Reputation: 1467

Like Alexis said in the comment above, (<>) is from Data.Monoid. You can think of monoids as appendable things, so lists and text and stuff like that, and <> or mappend is how you append them. [1,2,3] <> [4,5,6] is the same as [1,2,3] ++ [4,5,6] -- both resulting in [1,2,3,4,5,6].

In the library you linked to, ParserHelp is defined as a monoid here so you can use <> to "add" ParserHelps.

Googling operators is tough. Hoogle is really helpful for this!

Upvotes: 7

Related Questions