Probably because you don't apply x to xx anywhere?
On 6 Jun 2009, at 11:48, John Ky wrote:
Hi Haskell Cafe,
In the following code, I get an error saying Ambiguous occurrence
`x'. Why can't Haskell work out which x to call based on the type
of getA?
Thanks
-John
#!/usr/bin/env
On Sat, Jun 6, 2009 at 1:48 AM, John Ky newho...@gmail.com wrote:
Hi Haskell Cafe,
In the following code, I get an error saying Ambiguous occurrence `x'. Why
can't Haskell work out which x to call based on the type of getA?
Thanks
-John
#!/usr/bin/env runhaskell
{-# LANGUAGE
Hi Luke,
You're right. My code had a typo. Unfortunately, I still get the same
error whichever way I do it.
For example:
{-# LANGUAGE DisambiguateRecordFields #-}
import A
import B
main = do
let xx = getA
print (x xx)
and:
#!/usr/bin/env runhaskell
{-# LANGUAGE
The error is because of the way records work in Haskell. Recall that a
record is just sugar for the normal datatype syntax. Namely:
data FooA a b c = FooA {getA :: a, getB:: b, getC :: c}
can be accessed as either
f (FooA a b c) = ...
or
f fooA = ... (getA fooA) ... etc
That is,