[Haskell-cafe] A "commutative diagram" conjecture about applicative functors

Isaac Dupree isaacdupree at charter.net
Mon Dec 31 09:43:09 EST 2007


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


More information about the Haskell-Cafe mailing list