Re: Hi, I have a question!

2004-01-11 Thread Ketil Malde
Derek Elkins [EMAIL PROTECTED] writes:

 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
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Hi, I have a question!

2004-01-10 Thread NamO
Mmmm.

and then How can I solve  this problem?
Would you say the solution.
Thank you.


Ashley Yakeley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 In article [EMAIL PROTECTED],
  NamO [EMAIL PROTECTED] 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



___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Hi, I have a question!

2004-01-10 Thread Ashley Yakeley
In article [EMAIL PROTECTED],
 NamO [EMAIL PROTECTED] wrote:

 Mmmm.
 
 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 +.

-- 
Ashley Yakeley, Seattle WA

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Hi, I have a question!

2004-01-09 Thread NamO
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.



___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Hi, I have a question!

2004-01-09 Thread Ashley Yakeley
In article [EMAIL PROTECTED],
 NamO [EMAIL PROTECTED] 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

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe