
In ghci, any statement that returns Show a => IO a (that is IO a where the a is showable) will be run in IO and the result a will be shown once it finishes. If a is not showable it will simply run the IO action, but not show the result.
:t sequence (map print [1,2,3]) sequence (map print [1,2,3]) :: IO [()] :i Show instance Show a => Show [a] -- Defined in ‘GHC.Show’ instance Show () -- Defined in ‘GHC.Show’
On Wed, Feb 3, 2016 at 5:35 AM, Olumide <50295@web.de> wrote:
On 01/02/2016 17:39, David McBride wrote:
Note that it has not actually printed them out.
I hope you don't mind me asking but why then does sequence (map print [1,2,3] ) return the numbers 1, 2, 3 (albeit followed by [(),(),()]).
It merely has an array of as yet unexecuted actions. To print them
you'd go like sequence (map print) [1,2,3] ...
Erm ... sequence (map print) [1,2,3] returns an error.
- Olumide
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners