Haskell Error
There are a few type errors in your code.
theFilter :: Integer -> Integer
has an incorrect type signature because the function produces the value True, which is a data constructor for the Bool type. So theFilter should be Integer -> Bool.
The function body is also incorrect. Your second guard
en `mod` 2 == True
is comparing values of two different types. mod produces a value with an instance of the Integral typeclass, and True is (as mentioned above) a data constructor for the Bool type. == requires the values being compared to have the same type (Eq a => a -> a -> Bool).
Also in the second guard, you call
theFilter (en / 2)
but / is Fractional a => a -> a -> a, and theFilter takes an Integer argument. You want either quot or div depending on the behavior you are looking for.
theMainer :: Integer -> Boolean
is wrong because there is no Boolean type constructor. What you are looking for is Bool, so theMainer should be Integer -> Bool. The other problem with this function is that the value produced by each guard has a different type. Your function signature says the function gives a Bool value, and your second guard (otherwise) matches that, but show (in your first guard) has the signature Show a => a -> String.
Finally, you are using a top-level expression (map theMainer numbers), which is not allowed in Haskell. If you want to see the result of map, either remove it from the file and do it from ghci, or put it into main:
main = print $ map theMainer numbers
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now