Skip to content

Commit

Permalink
Added Transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
NickSeagull committed Apr 26, 2018
1 parent 53ccd4b commit 649af6a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PHONY: build docs
.PHONY: build docs

FILES=`find ./src -iregex '.*\.\(hs\)'`
DOCFILES=`find . -iregex '.*\.\(hs\)'`
Expand Down
7 changes: 5 additions & 2 deletions eta-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: ba97beeabbafc893bb8065143e121492afe977b1c7564d7c51a43a268b18bc77
-- hash: 982169364dc7e1f96608940bfcc199bb998eabfbd3101daba27de462595ade15

name: eta-prelude
version: 0.2.0
version: 0.3.0
synopsis: The Eta prelude
description: Please see README.md
homepage: https://github.com/typelead/eta
Expand Down Expand Up @@ -36,6 +36,8 @@ library
Eta.Classes.Integral
Eta.Classes.IsString
Eta.Classes.Monad
Eta.Classes.MonadTrans
Eta.Classes.MonadTrans.Except
Eta.Classes.Monoid
Eta.Classes.Num
Eta.Classes.Ord
Expand All @@ -59,6 +61,7 @@ library
default-extensions: NoImplicitPrelude
build-depends:
base >=4 && <5
, transformers
hs-source-dirs:
src
default-language: Haskell2010
6 changes: 4 additions & 2 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: eta-prelude
version: 0.2.0
version: 0.3.0
synopsis: The Eta prelude
description: Please see README.md
homepage: https://github.com/typelead/eta
Expand All @@ -12,5 +12,7 @@ category: Language
library:
exposed-modules: Eta
default-extensions: NoImplicitPrelude
dependencies: base >= 4 && < 5
dependencies:
- base >= 4 && < 5
- transformers
source-dirs: src
1 change: 1 addition & 0 deletions src/Eta/Classes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Eta.Classes.Generic as Exported
import Eta.Classes.Integral as Exported hiding (quot, rem, div, mod, quotRem, divMod)
import Eta.Classes.IsString as Exported hiding (fromString)
import Eta.Classes.Monad as Exported hiding ((>>=))
import Eta.Classes.MonadTrans as Exported
import Eta.Classes.Monoid as Exported
import Eta.Classes.Num as Exported hiding (abs, signum)
import Eta.Classes.Ord as Exported
Expand Down
46 changes: 46 additions & 0 deletions src/Eta/Classes/MonadTrans.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module Eta.Classes.MonadTrans
( {-|
A Monad Transformer is a typeclass that
allows to execute functions of one Monad
inside of another by providing a 'lift'
operation:
@
wontWork :: Maybe (IO Int)
wontWork = do
someString <- getLine -- Compile error: getLine returns an IO action, not Maybe
if someString == ""
then Nothing
else length someString |> Just
ok :: MaybeT IO Int
ok = do
someString <- lift getLine
if someString == ""
then Nothing
else length someString |> Just
@
There are quite a lot of transformers available:
* ExceptT
* IdentityT
* MaybeT
* ReaderT
* StateT
* WriterT
-}
module Control.Monad.Trans.Class
, module Exported
)
where

import Control.Monad.Trans.Class

import Control.Monad.Trans.Except as Exported hiding (liftCallCC, liftListen, liftPass, liftCatch)
import Control.Monad.Trans.Identity as Exported hiding (liftCallCC, liftListen, liftPass, liftCatch)
import Control.Monad.Trans.Maybe as Exported hiding (liftCallCC, liftListen, liftPass, liftCatch)
import Control.Monad.Trans.Reader as Exported hiding (liftCallCC, liftListen, liftPass, liftCatch)
import Control.Monad.Trans.State as Exported hiding (liftCallCC, liftListen, liftPass, liftCatch)
import Control.Monad.Trans.Writer as Exported hiding (liftCallCC, liftListen, liftPass, liftCatch)

0 comments on commit 649af6a

Please sign in to comment.