Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-22, 09:59am
haskell type classing
Subject: haskell type classing  ·  Posted: 2006-02-08, 03:37am
Rank: ? (4)
Member #: 26601
Aight, I'm trying teach myself how to write my own classes in haskell and I came upon an error recently and cant seems to figure out how to fix it. Can anyone help???

My Script so far says:

Code:
  1. module Lab2 where
  2. class Null a where
  3.   
  4.   nullify :: a -> a
  5.   
  6. instance Null Int where
  7.   nullify x = 0


and when i run it hugs I get an error that says"

"Hugs session for:
C:\Program Files\Hugs98\lib\Prelude.hs
C:\Documents and Settings\04044465\Desktop\lab2.hs
Lab2> nullify 10
ERROR - Unresolved overloading
*** Type : (Num a, Null a) => a
*** Expression : nullify 10 "


Now please do not link me to the tutorial on haskell.org, cuz i know what I'm doing I just can't figure this bit out. Please someone help........

 
  Reply to this ·  Post link ·  Top
Subject: Re: haskell type classing  ·  Posted: 2006-02-08, 04:09am
Rank: ? (4)
Member #: 26601
actually u guys can forget abt that post I solved it
The code was right I just had to write "nullify 10::Int" in hugs rather than "nullify 10"

however another question :

what is the instance for lists:

eg. "instance Null ???? where....."

???? - class for lists

i dont know anyone can help??

 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs