It so happens that Haskell currently insists on main :: IO (). That's simple to fix, however, and with great pay-off. Suppose instead main :: TV a (where I'm omitting the other TV type args for simplicity.) Then a program could not only be run, but also composed with other programs. They could even be composed by the end-user *while running*, as in Eros.
<br><br>Similarly, ghci implicitly inserts "print" when given a non-IO type. We could make that mechanism a little more general, and allow implicit insertions of other kinds of renderers, for purely functional images, music, 2D & 3D geometry & animation, interactive GUIs, etc.
<br><br> - Conal<br><br><div class="gmail_quote">On Dec 9, 2007 4:38 PM, Lennart Augustsson <<a href="mailto:lennart@augustsson.net">lennart@augustsson.net</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I doubt all imperative programming will be banished from Haskell anytime soon. I really, really wish we had all the nice abstractions in place already, but we just don't.<br><br>You can't write any program in Haskell without using IO, because the type of main involves IO.
<br>And currently I believe that almost any real program will have to involve IO.<br>(BTW, the only H98 IO avoiding wrapper, interact, was included in Haskell because I insisted on it.)<br>It's just from my experience. No matter how pure your program is, here and there it will be interacting with the rest of the world.
<br><font color="#888888"><br> -- Lennart</font><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">On Dec 9, 2007 10:16 PM, Conal Elliott <<a href="mailto:conal@conal.net" target="_blank">conal@conal.net
</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks. If I'm tracking, your real point is that imperative programming in Haskell is still useful enough to keep around. I agree.<br><br>I'm still puzzled. Did you understand something I said, or maybe someone else said, as suggesting that imperative programming be removed from Haskell any time soon?
<div><br><br>> It's also important to teach people to stay away from IO whenever possible, but it's simply not always possible. <br><br></div>How can we possibly teach them to stay away from IO where possible if we're also telling them that they can't write *any* real program without using IO?
<br><br>Cheers, - Conal<div><div></div><div><br><br><div class="gmail_quote">On Dec 9, 2007 12:02 PM, Lennart Augustsson <<a href="mailto:lennart@augustsson.net" target="_blank">lennart@augustsson.net</a>
> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Conal,<br><br>It's true that you can avoid using IO (except for a wrapper) for certain kinds of programs.<br>For instance, if all you want is a String->String function, or some GUI program (you forgot to mention fudgets, which was the first wrapper of this kind) then you can ignore IO and just use a nice wrapper.
<br><br>But if someone asks me how to traverse a directory tree, invoking the 'file' program for each ',o' file and then renaming it if it's a text file, then what should I answer? "Sorry, you can't do that in Haskell." or "You need to use the IO monad."?
<br>I prefer the latter answer, and I think people who learn Haskell need to learn something about how you do some of the things that are easy in other languages.<br><br>It's also important to teach people to stay away from IO whenever possible, but it's simply not always possible.
<br><font color="#888888"><br> -- Lennart</font><div><div></div><div><br><br><div class="gmail_quote">On Dec 9, 2007 5:31 PM, Conal Elliott <<a href="mailto:conal@conal.net" target="_blank">conal@conal.net
</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>> IO is important because you can't write any real program without using it.<br><br></div>Ouch! I get awfully discouraged when I read statements like this one. The more people who believe it, the more true it becomes. If you want to do functional programming, instead of imperative programming in a functional language, you can. For instance, write real, interactive programs in FRP, phooey, or TV. And if you do, you'll get semantic simplicity, powerful & simpler reasoning, safety and composability.
<br><font color="#888888"><br> - Conal<br><br></font><div class="gmail_quote"><div>On Dec 8, 2007 1:26 AM, Lennart Augustsson <<a href="mailto:lennart@augustsson.net" target="_blank">lennart@augustsson.net
</a>> wrote:<br></div><div><div></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I agree with Dan here.<br><br>IO is important because you can't write any real program without using it.<br>So why not teach enough of it to get people off the ground straight away?<br><br>People who hang around long enough to do some more Haskell programming
<br>will run into the other monads sooner or later. But IO is an unavoidable step to<br>writing Haskell programs.<div><div></div><div><br><font color="#888888"><br><br></font><br><div class="gmail_quote">
On Dec 4, 2007 5:11 AM, Dan Piponi <
<a href="mailto:dpiponi@gmail.com" target="_blank">dpiponi@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>
On Dec 3, 2007 6:36 PM, Ben Franksen <
<a href="mailto:ben.franksen@online.de" target="_blank">ben.franksen@online.de</a>> wrote:<br>> then the special features of IO<br>> will remain associated with monads in general, leading to a whole jumble of<br>
> completely wrong ideas about them.
<br><br></div>As I only learnt about monads a couple of years ago, the process is<br>still fresh in my mind. I wasted quite a bit of time labouring under<br>the impression that monads were primarily about sequencing. But that
<br>wasn't because I incorrectly generalised from IO. It was because<br>countless people out there explicitly said they were about sequencing.<br>I suspect that if courses started with the List monad there'd be<br>
countless blogs telling people that monads are a way to eliminate<br>loops from your code like the way list comprehensions are used in<br>Python.<br><div><br>> This is yet another problem with IO as the standard example for monads: its
<br>> effect base is huge and poorly structured.<br><br></div>You don't teach *all* of IO to students in one go!<br><div><br>> This again makes it difficult to<br>> see exactly which intuitions about IO can be generalized to arbitrary
<br>> monads and which not.<br><br></div>That's true of any monad. IO is unique. [] is unique. Cont is unique.<br>All of them can lead you down the garden path. You need to see<br>multiple monads, and it helps if you can sneak an example under a
<br>student's nose so they can already reason about monads before they<br>even know what a monad is.<br><div><br>> What is pointless about failure and how to handle it?<br><br></div>It's pointless when you're still trying to make your first tweaks to
<br>"Hello, World!" work.<br>--<br><font color="#888888">Dan<br></font><div><div></div><div>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org" target="_blank">
Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br><br></blockquote></div></div></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>