[Haskell-beginners] weird constraint
Sylvain Henry
sylvain at haskus.fr
Wed Jan 16 15:05:47 UTC 2019
Remember that a -> b -> a is equivalent to a -> (b -> a)
So: (forall a. Num a => a -> a) . (a -> (b -> a))
Becomes: (Num (b -> a). (b -> a) -> (b -> a)) . (a -> (b -> a))
Then: Num (b -> a). a -> (b -> a)
Finally: Num (b -> a). a -> b -> a
On 16/01/2019 15:52, Dimitri DeFigueiredo wrote:
> Could someone help me make sense of this Num constraint given by GHCi?
> I was expecting to get:
>
> inc . const :: Num a => a -> b -> a
>
> rather than:
>
> inc . const :: Num (b -> a) => a -> b -> a
>
> Here's the transcript:
>
>
> GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
> Prelude> inc x = x + 1
> Prelude> :t inc
> inc :: Num a => a -> a
> Prelude> :t const
> const :: a -> b -> a
> Prelude> :t inc . const
> inc . const :: Num (b -> a) => a -> b -> a
> Prelude>
>
>
> Thanks,
>
> Dimitri
>
More information about the Beginners
mailing list