on master help sign in
Merge branch 'ioexcept-ffi' of https://github.com/aaronc/Idris-dev into aaronc-ioexcept-ffi

Conflicts: libs/base/Control/IOExcept.idr

commit9b2ca0488ef3d203d092dfd49ea894d51ff713ad authorEdwin Brady <ecb10@st-andrews.ac.uk> dateWed 20 Jan 2016, 16:09 (11 years ago) parent9e8930d4eff833
2 files changed+12−8
CONTRIBUTORS+1 libs/base/Control/IOExcept.idr+11−8
CONTRIBUTORS+1
@@ -11,6 +11,7 @@ Jakob Brünker
1111Alyssa Carter
1212David Raymond Christiansen
1313Carter Charbonneau
14+Aaron Craelius
1415Jason Dagit
1516Guglielmo Fachini
1617Simon Fowler
libs/base/Control/IOExcept.idr+11−8
@@ -2,25 +2,28 @@ module Control.IOExcept
22
33-- An IO monad with exception handling
44
5−record IOExcept err a where
5+record IOExcept' (f:FFI) err a where
66 constructor IOM
7− runIOExcept : IO (Either err a)
7+ runIOExcept : IO' f (Either err a)
88
9−implementation Functor (IOExcept e) where
9+Functor (IOExcept' f e) where
1010 map f (IOM fn) = IOM (map (map f) fn)
1111
12−implementation Applicative (IOExcept e) where
12+Applicative (IOExcept' f e) where
1313 pure x = IOM (pure (pure x))
1414 (IOM f) <*> (IOM a) = IOM [| f <*> a |]
1515
16−implementation Monad (IOExcept e) where
16+Monad (IOExcept' f e) where
1717 (IOM x) >>= f = IOM $ x >>= either (pure . Left) (runIOExcept . f)
1818
19−ioe_lift : IO a -> IOExcept err a
19+ioe_lift : IO' f a -> IOExcept' f err a
2020ioe_lift op = IOM $ map Right op
2121
22−ioe_fail : err -> IOExcept err a
22+ioe_fail : err -> IOExcept' f err a
2323ioe_fail e = IOM $ pure (Left e)
2424
25−ioe_run : IOExcept err a -> (err -> IO b) -> (a -> IO b) -> IO b
25+ioe_run : IOExcept' f err a -> (err -> IO' f b) -> (a -> IO' f b) -> IO' f b
2626ioe_run (IOM act) err ok = either err ok !act
27+
28+IOExcept : Type -> Type -> Type
29+IOExcept = IOExcept' FFI_C