[Haskell-cafe] -fno-monomorphism-restriction makes type-inference ambiguous?

Eike Scholz eikescholz at gmx.de
Mon Feb 27 10:47:17 EST 2006

Note: This Question has already been asked on the haskell mailing list.
      But haskell-cafe seems to be more adequate for for this question.


i have encountered a problem and I don't quite understand 
the reason why I get the results I get. 
ghci seems to infer different types for the same expression.

Consider that I have disabled the monomorphism restriction 
in module AGC.lhs (which is attached).

and I have a toplevel definition of:

> mylength = synAttr listLength

loding the module in ghci (6.4) gives (beside some correct warnings):

$ Ok, modules loaded: Main.
$ *Main> :type synAttr
$ synAttr :: (Data b) => ((?stack::[Dyn]) => b -> a) -> Attr a

$ *Main> :type listLength
$ listLength :: (?stack::[Dyn]) => List -> Float

$ *Main> :type (synAttr listLength)
$ (synAttr listLength) :: Attr Float

$ *Main> :type mylength
$ mylength :: (?stack::[Dyn]) => Dyn -> Dyn -> [Dyn] -> Maybe Float

$ *Main> let mylength = synAttr listLength
$ *Main> :type mylength
$ mylength :: Dyn -> Dyn -> [Dyn] -> Maybe Float


> type Attr a = Dyn -> Dyn -> [Dyn]-> Maybe a

the problem I have is that inferred types for the toplevel declaration
mylength differ from the verbatim equal definition in the Let

for the toplevel it infers:

  mylength :: (?stack::[Dyn]) => Dyn -> Dyn -> [Dyn] -> Maybe Float

for the let-Binding
  mylength :: Dyn -> Dyn -> [Dyn] -> Maybe Float

and this is what I expected.

Has anyone an Idea, why this happens?

best regards,

  Eike Scholz

PS: Beware of the comments in the attached file. This file is under
heavy development. I am dyslexic and don't correct the comments 
while continuously rewriting code and comments. I hope that the comments
are useful anyway. 
The (+>) (~>) (#>) operators are broken at the moment and don't work the
way intended.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: AGC.lhs
Type: text/x-literate-haskell
Size: 8036 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060227/f7c67560/AGC-0001.bin

More information about the Haskell-Cafe mailing list