[Haskell-cafe] Inferred typing?

michael rice 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?

Michael

=========

import 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]
[4,8]
*Main> 



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/3b04a5b2/attachment.html


More information about the Haskell-Cafe mailing list