[Haskell-cafe] IO () and IO [()]

Neil Mitchell ndmitchell at gmail.com
Mon Mar 10 18:17:43 EDT 2008


Hi

>  I would like to know if in fact there's any difference in practice
>  between (), [()], i.e. if in practice the difference matters.

Usually, not so much. A lot of Monad functions have _ variants, i.e.
mapM and mapM_. If you don't need the result, use the mapM_ version,
as it will run faster and not space/stack leak in some circumstances.

>  By the way, as a consequence can you possibly get IO (()) or IO ([()])
>  and are these all different from each other?

Read () as Unit.  You can't put anything in a Unit, even if the
bracket notation subtly suggests you can. You can have IO Unit and IO
[Unit], but not IO Un(Unit)it or IO Un([Unit])it. The two types you
gave can't exist.

Thanks

Neil


More information about the Haskell-Cafe mailing list