I'm new to Haskell, and I'm stuck with an example. I'd like to experiment with the Maybe type, but my code does not compile:
divide100By :: Int a -> Maybe a
divide100By x = case (Int x) of
Nothing -> Nothing
Just x -> 100 / x
main = putStrLn ("Result: " ++ show (divide100By 5))
But I'm always getting the error:
Not in scope: data constructor 'Int'
I'm afraid I don't quite get the function definition in Haskell (the divide100By :: Int a -> Maybe a part)... Can someone please tell me what's wrong here?
Intdoes not take a type argument, so you wantdivide100By :: Int -> Maybe Int. Your function body also has at least 3 other problems... - Alec