control-dsl 0.2.0.2 → 0.2.1.0
raw patch · 5 files changed
+15/−11 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Dsl.Cont: toCont :: PolyCont k r a => k r' a -> Cont r a
Files
- ChangeLog.md +2/−1
- control-dsl.cabal +2/−2
- src/Control/Dsl/Cont.hs +4/−1
- src/Control/Dsl/Dsl.hs +3/−2
- src/Control/Dsl/State/State.hs +4/−5
ChangeLog.md view
@@ -1,4 +1,5 @@-# Changelog for `Control.Dsl`+## 0.2.1.0+* Add `toCont` function ## 0.2.0.2 * Fix tests in GHC 8.6.1
control-dsl.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5145c09041be36dede5eb015ca73b5f9145b7f4d1a765ed3b53e12d6e6337d50+-- hash: f05825e0fb61758589eb055402af39aa7e945df86d2b987417ec5f74ecd2f3ab name: control-dsl-version: 0.2.0.2+version: 0.2.1.0 synopsis: An alternative to monads description: This \"control-dsl\" package is a toolkit to create extensible Domain Specific Languages in @do@-notation. .
src/Control/Dsl/Cont.hs view
@@ -34,8 +34,11 @@ -} type (!!) = Cont --- ! A delimited continuation that can be used in a @do@ block.+-- | A delimited continuation that can be used in a @do@ block. newtype Cont r a = Cont { runCont :: (a -> r) -> r }++-- | Convert a 'PolyCont' to a 'Cont'.+toCont k = Cont (runPolyCont k) when :: Bool -> Cont r () -> Cont r () when True k = k
src/Control/Dsl/Dsl.hs view
@@ -14,9 +14,10 @@ == Allowed statements in DSL @do@ blocks -Statements in a DSL @do@ block is a delimited continuation+Statements in a DSL @do@ block are delimited continuations (except the last statement),-which can be a GADT keyword, a control flow operator.+which can be either ad-hoc polymorphic GADT keywords,+or monomorphic control flow operators. The last statement is the final result of the @do@ block, or the /answer type/ of other delimited continuation statements.
src/Control/Dsl/State/State.hs view
@@ -32,17 +32,16 @@ The following @append@ function 'Control.Dsl.State.Get's a @Seq String@ state, appends @s@ to the 'Data.Sequence.Seq',-and 'Control.Dsl.State.Put's the new 'Data.Sequence.Seq' to the updated state.+and 'Control.Dsl.State.Put's the new 'Data.Sequence.Seq' as the updated state. >>> :{ append s = do buffer <- Get @(Seq String)- Put $ buffer |> s- Cont ($ ())+ toCont $ Put $ buffer |> s :} -@($ ())@ creates a CPS function ,-which can be then converted to 'Control.Dsl.Cont.Cont's.+@append@ returns a 'Control.Dsl.Cont.Cont',+which can be used in other @do@ blocks. A @formatter@ @append@s 'String' to its internal buffer, and 'Control.Dsl.return' the concatenated buffer.