Twan van Laarhoven wrote:
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.

thank you, oops, how annoying. I wonder if GHCi should output parentheses to make its :type result be a valid expression...

Isaac
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to