effect-handlers 0.1.0.7 → 0.1.0.8
raw patch · 3 files changed
+50/−1 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Effects.Eff: class Typeable (a :: k)
+ Control.Effects.Eff: class Typeable k (a :: k)
Files
- effect-handlers.cabal +3/−1
- test/Examples/Combined.hs +35/−0
- test/Examples/Reader.hs +12/−0
effect-handlers.cabal view
@@ -1,5 +1,5 @@ name: effect-handlers-version: 0.1.0.7+version: 0.1.0.8 synopsis: A library for writing extensible algebraic effects and handlers. Similar to extensible-effects but with deep handlers. homepage: https://github.com/edofic/effect-handlers bug-reports: https://github.com/edofic/effect-handlers/issues@@ -100,6 +100,8 @@ default-language: Haskell2010 hs-source-dirs: bench, test main-is: TestBench.hs+ other-modules: Examples.Combined+ Examples.Reader build-depends: base >=4.7 && <5 , effect-handlers , criterion >= 1.0 && <2
+ test/Examples/Combined.hs view
@@ -0,0 +1,35 @@+module Examples.Combined where++import Control.Effects.Eff+import Control.Effects.Exception+import Control.Effects.Reader+import Control.Effects.Search++import Control.Monad++testPrg = do+ v <- ask+ x <- choose [1..(v :: Int)]+ when (x < 5) $ searchFail (T :: T Int)+ y <- choose [3,4]+ let d = x - y+ if d == 0+ then throw $ "division by zero"+ else return ((fromIntegral v) / (fromIntegral d))+++testPrgRun n = runPure + . handle exceptionHandler + . handle (handleDFS :: Handler (Search Int) r a [a])+ . handle (readerHandler n)++testPrgRes :: Int -> Either String [Float]+testPrgRes n = testPrgRun n testPrg++testPrgRun2 n = runPure + . handle (handleDFS :: Handler (Search Int) r a [a])+ . handle exceptionHandler + . handle (readerHandler n) ++testPrgRes2 :: Int -> [Either String Float]+testPrgRes2 n = testPrgRun2 n testPrg
+ test/Examples/Reader.hs view
@@ -0,0 +1,12 @@+module Examples.Reader where++import Control.Effects.Eff+import Control.Effects.Reader+import Control.Effects.Exception++prg1 = ask++prg1run x = runPure . handle (readerHandler x)++prg1res :: Int -> Int+prg1res x = prg1run x prg1