[Haskell-cafe] Inferred typing?
nowgate at yahoo.com
Tue May 12 01:59:01 EDT 2009
In the code below, is the type returned by the return functions inferred from
the result type in the function type signature, i.e., just change the result
type to Maybe Int and the code will return a Maybe monad, (Just 4), instead of
a List monad?
fn :: [Int] -> [Int]
fn l = mzero `mplus` (return (head l)) `mplus` (return (last l))
*Main> :l test5
[1 of 1] Compiling Main ( test5.hs, interpreted )
Ok, modules loaded: Main.
*Main> fn [4,5,6,7,8]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe