While I was researching for a talk I came across something that I thought was not possible, and I still can't figure out why it is working. In the Control.Bind
module, there is the definition of the fish operator:
composeKleisli ∷ ∀ a b c m. Bind m ⇒ (a → m b) → (b → m c) → a → m c
The documentation above it gives an example:
third = tail >=> tail >=> head
This is where my mind doesn't compute. I thought it would never compile* and yet it does:
> :t tail >=> tail >=> head
forall t2. Array t2 -> Maybe t2
How can this be? Clearly tail
and head
differ in the output m
.
* or that the type checker would infer the following type: forall t2. Array (Array t2) -> Array t2