[Haskell-cafe] A "commutative diagram" conjecture
about applicative functors
Twan van Laarhoven
twanvl at gmail.com
Mon Dec 31 09:33:47 EST 2007
Isaac Dupree wrote:
> Unfortunately, I get puzzling type errors if I annotate either one of
> them with their type (e.g.
> (Applicative f) => f (a -> b) -> f a -> f (Int, b)
> ) in an expression. The very answer doesn't seem to typecheck.
>
> > :t \f x -> fmap ((,) (0::Int)) (f <*> x) :: (Applicative f) => f (a1
> -> a) -> f a1 -> f (Int, a)
Here the type annotation applies to the *body* of the lambda abstraction,
adding parentheses around the whole thing solve your problem.
> :t (\f x -> fmap ((,) (0::Int)) (f <*> x)) :: (Applicative f) => f (a1
-> a) -> f a1 -> f (Int, a)
Aside from the fact that ghci has some trouble formating the output.
Twan
More information about the Haskell-Cafe
mailing list