As it so happened, someone recently expressed a similar interest for I/O:
But in the context of Haskell, what exactly is “idiomatic code” ?
-
effect-free expressions? Haskell is nonstrict, which is why it’s so nice to program in. Hence the lack of those effects
(
unless somethingunsafe...
is being used)-;
-
the absence of effect-centric actions (functorial, applicative, monadic, arrow, comonadic et al )? Alright, just provide some other way to manage exceptions or other effects in Haskell (and remember: even effect systems rely on one or more of those interfaces - usually the monadic one).
Otherwise, perhaps this could be of interest:
(with abstract monadic I/O first appearing officially in Haskell 1.3).
Instead of IO a
, a program would have the type:
type Dialogue = [Response] -> [Request]
…it would be one big effect-free expression, with all that imperative ugliness confined to the interpreter (which does use abstract monadic I/O). But since Haskell 2010 also provides an FFI:
foreign import ccall runDialogue :: Dialogue -> IO ()
(
if the in-Haskell interpeter is too slow ;-)