Here is what I have:
{-
Here's how it works:
> listM 'a' 'b' 'c' :: String "abc" > putStrLn $ listM 'a' 'b' 'c' abc > listM (1::Int) (2::Int) :: [Int] [1,2]
That's how he fails
> sum $ listM 1 2 No instance for (ListResultMult (a2 -> [a0]) a1) ... > listM 1 :: [Int] No instance for (ListResultMult [Int] a0) ...
Contrast with printf:
instance Show a => ListResultMult (IO ()) a where lstM a as = print . reverse $ a:as > listM "foo" "bar" -- boo No instance for (ListResult t0 [Char]) ... > printf "%s %s" "foo" "bar" foo bar > listM "foo" "bar" :: IO () -- yay ["foo","bar"]
Enter insecurity:
> :t listM 2 "foo" Some weird type is actually inferred
So here is what I want to do:
- Type Security. I thought that when I defined
ListResultMult ra => ListResultMult (a -> r) a and ListResultMult [a] a , it would only allow you to create homogeneous lists and notice a type error when you don't. Why wasn’t it? - Breaking. I do not know what is strange happening with
listM 1 :: [Int] . What?
source share