Hi! Somebody posted the following message on comp.lang.functional. It reports an error when having a main function which has type "IO [()]", together with using runhugs. This is a bug; the Haskell report says that main "must be a computation of type IO t for some type t". /Koen. ---------- Forwarded message ---------- Date: Wed, 14 Feb 2001 23:23:50 +0100 From: Tore Lund <tl001@online.no> Newsgroups: comp.lang.functional Subject: Re: Purity of the stack execution model? Markus Mottl wrote:
actions = [putStr "foo", putStr "bar"] nl = putStr "\n" main = sequence actions >> nl >> mapM (>> nl) (reverse actions)
Maybe some kindly soul could tell me what is the type of main here. Running the right-hand clause within a "do" construct works fine. However, if I try the following: module Main where actions = [putStr "foo", putStr "bar"] nl = putStr "\n" main = sequence actions >> nl >> mapM (>> nl) (reverse actions) I get this message from runhugs: Program error: fromDyn failed. Expecting <<IO() >> found <<IO[ Program error: {instShow_v1536_v1601 [instTypeable_v1537 (head (unsafePerformIO main))]}runhugs: Error occurred Trying to equip main with various IO types just leads to more errors. What am I missing please? * Moreover, this is admittedly a powerful example of what can be done with Haskell and monads. Is it possible to write such a program with comparable ease in, say, SML or OCaml? -- Tore