[Haskell-cafe] Why are these record accesses ambiguous

2009-06-06 Thread John Ky
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 DisambiguateRecordFields #-} import A import B main = do let xx = getA

Re: [Haskell-cafe] Why are these record accesses ambiguous

2009-06-06 Thread Miguel Mitrofanov
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

Re: [Haskell-cafe] Why are these record accesses ambiguous

2009-06-06 Thread Luke Palmer
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

Re: [Haskell-cafe] Why are these record accesses ambiguous

2009-06-06 Thread John Ky
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

Re: [Haskell-cafe] Why are these record accesses ambiguous

2009-06-06 Thread Joe Fredette
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,