Search code examples
haskellsyntaxoperatorsnotation

Haskell >.> notation


In the book "The Craft of Function Programming" the symbol '>.>' joins functions together, opposite the direction of '.'. But when I implemented it using ghci, it shows the error '>.>' out of scope. Why? Is it an old notation that is not used anymore?


Solution

  • It's probably just a function defined by the book (I didn't read the book). AFAIK, >.> is not used anywhere. You could define it yourself:

    (>.>) = flip (.)
    

    The de-facto notation of this seems to be (#).

    Since functions are arrows "Control.Category" you could also use >>>, e.g.

    Prelude Control.Category> ((*2) . (+1)) 4
    10
    Prelude Control.Category> ((*2) <<< (+1)) 4
    10
    Prelude Control.Category> ((*2) >>> (+1)) 4
    9
    Prelude Control.Category> ((+1) >>> (*2)) 4
    10