[Haskell-cafe] :t main

Scherrer, Chad Chad.Scherrer at pnl.gov
Tue Nov 29 21:07:02 EST 2005

I've been reading some of the articles about comonads, and I thought the idea of giving main the type OI () -> () was pretty interesting. So I was wondering, would it be possible to allow the type of main to be inferred? It seems like 
IO ()
OI () -> ()
OI () -> IO ()

all make sense (at least I think they do). One particularly nice side effect of this (pardon the pun) is that a good number of useful programs can be written as

getContentsW :: OI () -> a
doSomeStuff :: (Show b) => a -> b
print :: (Show b) => b -> IO ()
main = print . doSomeStuff . getContentsW

so much less understanding about monads et al is required to do some basic stuff. I think it would be much easier in this case to make the transition to Haskell.

Also, has anyone given any thought to syntactic sugar for comonads? Since arrows and monads share the (<-) symbol, it seems like a nice unification could be possible... Maybe (-<) alone could be used similarly?

Chad Scherrer

More information about the Haskell-Cafe mailing list