News for hackers. Stuff that matters.
Re:Why the world needs Haskell by Zak on Wednesday July 10, 2013 @12:46AM (#6017499)
A thing that people are often unaware of when trying to understand how the IO type works in Haskell is that you cannot define the IO type in Haskell.
Re:Why the world needs Haskell by kenko on Wednesday July 10, 2013 @01:21AM (#6017597)
Sure you can: http://hackage.haskell.org/packages/archive/ghc-prim/0.2.0.0...

You can't define RealWorld, though, nor (IIRC) is IO really a state monad.

Re:Why the world needs Haskell by Zak on Wednesday July 10, 2013 @01:30AM (#6017637)
I used "define" imprecisely.

You cannot, so far as I know, implement `>>=` for the IO type defined in the above link within Haskell, which means you can't actually use it to do IO.

Re:Why the world needs Haskell by kenko on Wednesday July 10, 2013 @10:58AM (#6020123)
Re:Why the world needs Haskell by applicative on Wednesday July 10, 2013 @07:35PM (#6023551)
Here's another definition -- by continuation -- from Hug's Prelude (http://cpansearch.perl.org/src/AUTRIJUS/Language-Haskell-0.0...) :

    newtype IO a = IO ((a -> IOResult) -> IOResult)

    data IOResult 
      = Hugs_ExitWith    Int
      | Hugs_Catch       IOResult (Exception -> IOResult) (Obj -> IOResult)
      | Hugs_ForkThread  IOResult IOResult
      | Hugs_DeadThread
      | Hugs_YieldThread IOResult
      | Hugs_Return      Obj
      | Hugs_BlockThread (Obj -> IOResult) ((Obj -> IOResult) -> IOResult)