I'm new to haskell and I've tried to make my own typeclass here:
class Group g where
makeGroup :: g -> g -> [g]
instance Group Int where
makeGroup size offset = [ x `mod` size | x <- [1 + offset, size + offset]]
myTest :: (Group g) => Int -> Int -> [g]
myTest x y = makeGroup x y
Could someone tell me where I went wrong?
New problem
The type signature myTest :: (Group g) => g -> g -> [g]
compiles but throws this error
<interactive>:30:1:
No instance for (Group g0) arising from a use of ‘it’ The type variable ‘g0’ is ambiguous Note: there is a potential instance available: instance Group Int -- Defined at ex.hs:4:10 In the first argument of ‘print’, namely ‘it’ In a stmt of an interactive GHCi command: print it
What does this stem from?
Show
typeclass. – Jeff Amesclass (Show g) => Group g where
... – Jeff Ames