Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

Commit 259046c

Browse files
Add launchIO
1 parent 5fb99b0 commit 259046c

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/Control/Monad/IO.purs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
module Control.Monad.IO
2-
( INFINITY
2+
( module Control.Monad.IO.Effect
33
, IO(..)
4+
, launchIO
45
) where
56

67
import Control.Alt (class Alt)
78
import Control.Alternative (class Alternative)
8-
import Control.Monad.Aff (Aff)
9+
import Control.Monad.Aff (Aff, launchAff)
910
import Control.Monad.Aff.Class (class MonadAff)
1011
import Control.Monad.Aff.Unsafe (unsafeCoerceAff)
1112
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1213
import Control.Monad.Eff.Exception (Error)
1314
import Control.Monad.Eff.Unsafe (unsafeCoerceEff)
1415
import Control.Monad.Error.Class (class MonadError)
15-
import Control.Monad.IO (INFINITY)
16+
import Control.Monad.IO.Effect (INFINITY)
17+
import Control.Monad.IOSync (IOSync)
1618
import Control.Monad.Rec.Class (class MonadRec)
1719
import Control.MonadZero (class MonadZero)
1820
import Control.Plus (class Plus)
1921
import Data.Monoid (class Monoid)
20-
import Data.Newtype (class Newtype, wrap)
22+
import Data.Newtype (class Newtype, unwrap, wrap)
2123
import Prelude
2224

23-
foreign import data INFINITY :: Effect
24-
2525
newtype IO a = IO (Aff (infinity :: INFINITY) a)
2626

27+
launchIO :: a. IO a -> IOSync Unit
28+
launchIO = void <<< liftEff <<< launchAff <<< unwrap
29+
2730
derive instance newtypeIO :: Newtype (IO a) _
2831

2932
derive newtype instance functorIO :: Functor IO

src/Control/Monad/IO/Effect.purs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Control.Monad.IO.Effect
2+
( INFINITY
3+
) where
4+
5+
foreign import data INFINITY :: Effect

src/Control/Monad/IOSync.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Control.Monad.IOSync
2-
( module Control.Monad.IO
2+
( module Control.Monad.IO.Effect
33
, IOSync(..)
44
) where
55

@@ -10,7 +10,7 @@ import Control.Monad.Eff.Class (class MonadEff, liftEff)
1010
import Control.Monad.Eff.Exception (Error, catchException, error, throwException)
1111
import Control.Monad.Eff.Unsafe (unsafeCoerceEff)
1212
import Control.Monad.Error.Class (class MonadError, catchError, throwError)
13-
import Control.Monad.IO (INFINITY)
13+
import Control.Monad.IO.Effect (INFINITY)
1414
import Control.Monad.Rec.Class (class MonadRec)
1515
import Control.MonadZero (class MonadZero)
1616
import Control.Plus (class Plus)

0 commit comments

Comments
 (0)