On 03/01/06, Donn Cave <[EMAIL PROTECTED]> wrote: > On Tue, 3 Jan 2006, Chris Kuklewicz wrote: > ... > > I sometimes call a function with side-effects in IO a "command". But > > the terms are fungible. But calling putStr a "function" is correct. It > > is not a "pure function" however. > > Is that the standard party line? I mean, we all know its type and > semantics, whatever you want to call them, but if we want to put names > to things, I had the impression that the IO monad is designed to work > in a pure functional language - so that the functions are indeed actually > pure, including putStr. It's the monad that actually incurs the side > effects. Or something like that. So it isn't at all necessary to have > another word for functions of type IO a. > I'd say it depends on the way that you're thinking about it. Strictly speaking, putStr is a pure function which returns an action. It's also referentially transparent, since it always returns the same action for the same string.
However, if you think of functions a -> IO b as the arrows a -> b in a new category where composition is Kleisli composition: (@@) :: Monad m => (a -> m b) -> (t -> m a) -> (t -> m b) y @@ x = \u -> x u >>= y Then these arrows are "effectful" and would be considered impure. I think I prefer the first explanation, as it's a somewhat important property that the same action is computed for the same input. This doesn't hold of side-effectful arrows in general. Note that with Hughes' Arrows, this restriction can (often quite cleverly) be side-stepped in order to make some rather major optimisations. - Cale _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
