I've been working on improving this error message. Here's the current
version:
R.hs:1:
Ambiguous type variable `a' in constraints
`Random a' arising from use of `randomRs' at R.hs:4
`Num a' arising from the literal `0' at R.hs:4
Possible cause: the monomorphism restriction applied to the
following:
f :: Int -> [a] (bound at R.hs:4)
better, eh?
| -----Original Message-----
| From: Jorge Adriano [mailto:[EMAIL PROTECTED]]
| Sent: 22 January 2003 18:28
| To: GHC Users Mailing List
| Subject: Ambiguous type variable
|
| Hi all,
|
| This works fine, as expected
| > f :: (Num a, Random a) => Int -> [a]
| > f = randomRs (0,1).mkStdGen
|
| If I skip the type signature, though, I get the following error
messages:
| Main.hs:14:
| Ambiguous type variable(s) `a' in the constraint `Random a'
| arising from use of `randomRs' at Main.hs:14
| In the first argument of `(.)', namely `randomRs (0, 1)'
| In the definition of `f': (randomRs (0, 1)) . mkStdGen
|
| Main.hs:14:
| Ambiguous type variable(s) `a' in the constraint `Num a'
| arising from the literal `1' at Main.hs:14
| In the first argument of `randomRs', namely `(0, 1)'
| In the first argument of `(.)', namely `randomRs (0, 1)'
|
| Why exctly can't ghci figure how the type of f?
|
| This just happens when loading the code from a file,
| > :t randomRs (0,1).mkStdGen
| in ghci works fine.
|
| J.A.
| _______________________________________________
| Glasgow-haskell-users mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users