A type not inferred with RankNTypes

Akio Takano tkn.akio at gmail.com
Mon May 13 04:47:03 CEST 2013


Hi,

The attached program does not typecheck if I don't include a type signature
for 'bar' (the line C). I can't figure out if this is a limitation in the
type system or a bug in GHC. One thing that confuses me is that replacing
the line (B) with (A) makes the program typecheck.

Could anyone help me figuring out what is going on?

I'm using GHC 7.6.2. The error was:

 % ghc forall.hs
[1 of 1] Compiling Foo              ( forall.hs, forall.o )

forall.hs:18:11:
    Could not deduce (Fractional a) arising from the literal `0.1'
    from the context (Num (Scalar t), Scalar t ~ a)
      bound by a type expected by the context:
                 (Num (Scalar t), Scalar t ~ a) => AD t
      at forall.hs:18:7-13
    Possible fix:
      add (Fractional a) to the context of
        a type expected by the context:
          (Num (Scalar t), Scalar t ~ a) => AD t
        or the inferred type of bar :: a
    In the first argument of `foo', namely `0.1'
    In the expression: foo 0.1
    In an equation for `bar': bar = foo 0.1

Regards,
Takano Akio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20130513/d6a559ea/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forall.hs
Type: application/octet-stream
Size: 545 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20130513/d6a559ea/attachment.obj>


More information about the Glasgow-haskell-users mailing list