Make some minor tweaks to the example and change maintainer in comments

This commit is contained in:
Alexis King 2017-12-06 16:20:46 -08:00
parent 207be8e9d7
commit 6cf9abcf88
16 changed files with 32 additions and 41 deletions

View File

@ -1,15 +1,12 @@
module Capitalize
( Capitalize
, capitalize
, runCapitalizeM
, runCapitalizeM'
, runCapitalize
) where
import Data.Char (toUpper)
import Control.Monad.Freer (Member, interpret, send)
import Control.Monad.Freer.Internal (Eff(Val, E), decomp, qApp, tsingleton)
import Control.Monad.Freer (Eff, Member, interpret, send)
data Capitalize v where
Capitalize :: String -> Capitalize String
@ -17,11 +14,5 @@ data Capitalize v where
capitalize :: Member Capitalize r => String -> Eff r String
capitalize = send . Capitalize
runCapitalizeM :: Eff (Capitalize ': r) w -> Eff r w
runCapitalizeM (Val x) = pure x
runCapitalizeM (E u q) = case decomp u of
Right (Capitalize s) -> runCapitalizeM (qApp q (map toUpper s))
Left u' -> E u' (tsingleton (runCapitalizeM . qApp q))
runCapitalizeM' :: Eff (Capitalize ': r) w -> Eff r w
runCapitalizeM' = interpret $ \(Capitalize s) -> pure (map toUpper s)
runCapitalize :: Eff (Capitalize ': r) w -> Eff r w
runCapitalize = interpret $ \(Capitalize s) -> pure (map toUpper s)

View File

@ -7,7 +7,7 @@ import System.Environment (getArgs)
import Control.Monad.Freer (Eff, Member, run, runM)
import Capitalize (Capitalize, capitalize, runCapitalizeM)
import Capitalize (Capitalize, capitalize, runCapitalize)
import Console
( Console
, exitSuccess'
@ -34,23 +34,23 @@ capitalizingService = forever $ do
mainPure :: IO ()
mainPure = print . run
. runConsolePureM ["cat", "fish", "dog", "bird", ""]
$ runCapitalizeM capitalizingService
$ runCapitalize capitalizingService
mainConsoleA :: IO ()
mainConsoleA = runM (runConsoleM (runCapitalizeM capitalizingService))
-- | | | |
-- IO () -' | | |
-- Eff '[IO] () -' | |
-- Eff '[Console, IO] () -' |
-- Eff '[Capitalize, Console, IO] () -'
mainConsoleA = runM (runConsoleM (runCapitalize capitalizingService))
-- | | | |
-- IO () -' | | |
-- Eff '[IO] () -' | |
-- Eff '[Console, IO] () -' |
-- Eff '[Capitalize, Console, IO] () -'
mainConsoleB :: IO ()
mainConsoleB = runM (runCapitalizeM (runConsoleM capitalizingService))
-- | | | |
-- IO () -' | | |
-- Eff '[IO] () -' | |
-- Eff '[Capitalize, IO] () -' |
-- Eff '[Console, Capitalize, IO] () -'
mainConsoleB = runM (runCapitalize (runConsoleM capitalizingService))
-- | | | |
-- IO () -' | | |
-- Eff '[IO] () -' | |
-- Eff '[Capitalize, IO] () -' |
-- Eff '[Console, Capitalize, IO] () -'
examples :: [(String, IO ())]
examples =

View File

@ -5,7 +5,7 @@
-- Description: Freer - an extensible effects library
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
module Control.Monad.Freer

View File

@ -3,7 +3,7 @@
-- Description: Composable coroutine effects layer.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: An Error effect and handler.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: Generation of fresh integers as an effect.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -15,7 +15,7 @@
-- Description: Mechanisms to make effects work.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: Non deterministic effects
-- Copyright: 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: Reader effects, for encapsulating an environment.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -5,7 +5,7 @@
-- Description: State effects, for state-carrying computations.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: State effects in terms of Reader and Writer.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: Composable Trace effects.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: Composable Writer effects.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -3,7 +3,7 @@
-- Description: Fast type-aligned queue optimized to effectful functions.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -7,7 +7,7 @@
-- Description: Open unions (type-indexed co-products) for extensible effects.
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--

View File

@ -11,7 +11,7 @@
--
-- Copyright: (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
-- License: BSD3
-- Maintainer: ixcom-core@ixperta.com
-- Maintainer: Alexis King <lexi.lambda@gmail.com>
-- Stability: experimental
-- Portability: GHC specific language extensions.
--