
Hi. I am a student, who get interesting in Haskell. So, nowdays, I study Hakell with "Introduction to Functional Programming using Haskell - second edition" And today, I face an error from bellow code. ---------------------------- module OperationTest where data Nat = Zero | Succ Nat deriving (Show) (+) :: Nat -> Nat -> Nat m + Zero = m m + Succ n = Succ (m + n) ---------------------------- But above source make an error like bellow Reading file "g:\Haskell\OperationTest.hs": Dependency analysis ERROR "g:\Haskell\OperationTest.hs":8 - Ambiguous variable occurrence "+" *** Could refer to: OperationTest.+ Prelude.+ above source is from the text book - "Introduction to Functional Programming using Haskell - second edition" and I use Hugs to interpret it. I understand what interpreter say, but I don't know How I can solve this problem. Please, Help me!!! - 5 - P.S. Tank you very much to read my broken english letter.

In article
But above source make an error like bellow
Reading file "g:\Haskell\OperationTest.hs": Dependency analysis ERROR "g:\Haskell\OperationTest.hs":8 - Ambiguous variable occurrence "+" *** Could refer to: OperationTest.+ Prelude.+
There's already a definition for (+) imported from the Prelude. When you write "Succ (m + n)" the interpreter doesn't know whether you mean the one you've just defined ("OperationTest.+") or the one imported from the Prelude ("Prelude.+"). -- Ashley Yakeley, Seattle WA

Mmmmmmmm.........
and then How can I solve this problem?
Would you say the solution.
Thank you.
"Ashley Yakeley"
In article
, "NamO" wrote: But above source make an error like bellow
Reading file "g:\Haskell\OperationTest.hs": Dependency analysis ERROR "g:\Haskell\OperationTest.hs":8 - Ambiguous variable occurrence "+" *** Could refer to: OperationTest.+ Prelude.+
There's already a definition for (+) imported from the Prelude. When you write "Succ (m + n)" the interpreter doesn't know whether you mean the one you've just defined ("OperationTest.+") or the one imported from the Prelude ("Prelude.+").
-- Ashley Yakeley, Seattle WA

On Sat, 10 Jan 2004 04:28:33 -0800
Ashley Yakeley
In article
, "NamO" wrote: Mmmmmmmm.........
and then How can I solve this problem? Would you say the solution. Thank you.
Either use a different name for your operator, or specify the "+" that you want by writing "OperationTest.+" instead of "+".
You can also hide the Prelude (+), though it is a somewhat useful function. import Prelude hiding ( (+) )

Derek Elkins
Either use a different name for your operator, or specify the "+" that you want by writing "OperationTest.+" instead of "+".
You can also hide the Prelude (+), though it is a somewhat useful function.
Wouldn't making Nat an instance of Num also work? instance Num Nat where -- the definition of (+) for Nat here -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (4)
-
Ashley Yakeley
-
Derek Elkins
-
Ketil Malde
-
NamO