Reputation: 5
I'm trying to use Haskell (which I am completely new too) and Every time I attempt to compile this using ghci I get Not in scope: 'isNumber'
, what am I doing wrong?
digits :: [a] -> Bool
digits a = digits a True
digits1 :: [a] -> Bool -> Bool
digits1 [] False = False
digits1 [] True = True
digits1 (l:ls) True = digits ls isNumber l
digits1 (l:ls) False = False
Upvotes: 0
Views: 620
Reputation: 370152
You get that error message because isNumber
is defined in the Data.Char
module, which you didn't import it. Importing it will fix that error.
That's not your only problem though. One other problem is that digits ls isNumber l
is calling digits
with four arguments, but you've defined digits
to only take one argument.
Similarly the call digits a True
calls digits
with two arguments - same problem. You probably meant to write digits1 a True
here, as digits1
does take two arguments.
Lastly both digits
and digits1
are defined to take arbitrary lists as arguments, but you seem to want to call isNumber
on the list's elements. Since isNumber
is a function that only works on Char
s - not arbitrary values - you should probably take a list of Char
s (i.e. a String
) instead.
Upvotes: 7