[Haskell-beginners] Functor fmap: how to

Imants Cekusins imantc at gmail.com
Fri Jun 26 11:16:02 UTC 2015


a Functor instance is defined for IO, so we can fmap (a -> b) over IO, too.
not using IO monad it seems ;)


module FunctorIO where

{-
   usage:
   *FunctorIO> main
   {type something, <enter>}
-}

process:: String -> String
process s = s ++ " .. ok"

main::IO String
main = func getLine


func::IO String -> IO String
func ios = process <$> ios


More information about the Beginners mailing list