Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the Haskell (.:) operator defined?

Apparently the common name for the ((.).(.)) operator is (.:). Where is (.:) defined? Or do I have to define it myself?

like image 543
Ana Avatar asked Mar 27 '15 21:03

Ana


People also ask

What is Haskell operator?

Haskell provides special syntax to support infix notation. An operator is a function that can be applied using infix syntax (Section 3.4), or partially applied using a section (Section 3.5).

How do you do does not equal in Haskell?

The == operator means "is equal". The /= operator means "is not equal". It's supposed to be reminiscent of the mathematical "≠" symbol (i.e., an equals sign with a diagonal line through it).

What is left and right in Haskell?

The Either type is sometimes used to represent a value which is either correct or an error; by convention, the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: "right" also means "correct").


1 Answers

You can find it in the composition library, along with other higher order function compositions. This operator is not defined in base. If you don't want to add a (very small) package as a dependency then just define it yourself, although I would use the more generalize version that uses fmap:

(.:) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
(.:) = fmap fmap fmap

which just fmaps a function through two layers of functors. For functions, all three of these fmaps specialize to (.).

like image 106
bheklilr Avatar answered Nov 15 '22 12:11

bheklilr