plan-applicative 2.0.0.0 → 2.0.0.1
raw patch · 6 files changed
+51/−17 lines, 6 filesdep −plan-applicativePVP ok
version bump matches the API change (PVP)
Dependencies removed: plan-applicative
API changes (from Hackage documentation)
Files
- ChangeLog.md +2/−1
- README.md +7/−2
- lib/Control/Plan.hs +1/−1
- lib/Control/Plan/Core.hs +35/−8
- plan-applicative.cabal +5/−4
- tests/doctests.hs +1/−1
ChangeLog.md view
@@ -5,8 +5,9 @@ - *Lasagne* is now *Sylvan*. - runPlanK -> runKPlan-- unliftPlanK -> uliftKPlan+- unliftPlanK -> unliftKPlan - planK -> kplan - planKIO -> kplanIO - Removed non-essential *paths* function.+- Added "obligatoriness".
README.md view
@@ -38,6 +38,11 @@ ## Inspiration -[StaticArrow](http://hackage.haskell.org/package/arrows-0.4.4.1/docs/Control-Arrow-Transformer-Static.html)-from the [arrows](http://hackage.haskell.org/package/arrows) package.+- [StaticArrow](http://hackage.haskell.org/package/arrows-0.4.4.1/docs/Control-Arrow-Transformer-Static.html)+ from the [arrows](http://hackage.haskell.org/package/arrows) package.++- Not exactly an inspiration (as I don't understand the stuff well enough) but+ Tomas Petricek's work on ["coeffects"](http://tomasp.net/coeffects/) seems+ relevant for helping applications to "fail early". See section 1.1 of his+ [thesis](http://tomasp.net/academic/theses/coeffects/thesis.pdf).
lib/Control/Plan.hs view
@@ -12,7 +12,7 @@ step "f" (foretell [4] *> plan (threadDelay 1e6))) in bifoldMap id (foldMap Prelude.show) (getSteps example)-:}+ :} "ab1c2de3f4" Some possible use cases:
lib/Control/Plan/Core.hs view
@@ -37,6 +37,17 @@ import qualified Streaming.Prelude import Streaming.Prelude (Stream,Of(..),yield,next,effects) +{- $setup++>>> :set -XArrows+>>> :set -XTypeApplications+>>> import Control.Applicative+>>> import Control.Plan+>>> import Data.Tree+>>> import Text.Read(readMaybe)++-}+ -- | A computation that takes inputs of type @i@ and produces outputs of type -- @o@ working in the underlying monad @m@. The 'Applicative' instance cares -- only about the outputs, the 'Arrow' instance cares about both inputs and@@ -72,8 +83,10 @@ data Steps s w = Steps !(Seq (w,s,Mandatoriness,Steps s w)) w deriving (Functor,Foldable,Traversable,Eq,Show) --- | Steps of 'Plan's constructed in 'Applicative' fashion are always--- 'Mandatory'. Only steps declared with 'skippable' are optional.+{- Steps of 'Plan's constructed in 'Applicative' fashion are always+ 'Mandatory'. Only steps declared with 'skippable' are optional.++-} data Mandatoriness = Skippable | Mandatory deriving (Show,Eq,Ord)@@ -161,12 +174,26 @@ Plan (Steps (Seq.singleton (mempty,s,Mandatory,forest)) mempty) (Star (\x -> yield Started' *> f x <* yield Finished')) --- | Declare an optional step by wrapping an existing arrow plan. The step will--- only be executed when the input is 'Just'.------ This function only makes sense when using the 'Arrow' instance of 'Plan',--- because for 'Applicative's an effect cannot depend on previously obtained--- values.+{-| Declare an optional step by wrapping an existing arrow plan. The step will only+ be executed when the input is 'Just'.++ This function only makes sense when using the 'Arrow' instance of 'Plan',+ because for 'Applicative's an effect cannot depend on previously obtained+ values.++>>> :{+ let example :: Plan String () IO () ()+ example = proc () -> do + i <- step "reading" (plan (readMaybe @Int <$> getLine)) -< () + skippable "writing" (kplan print) -< i+ in putStr . drawForest . fmap (fmap show) . toForest . mandatoriness . getSteps $ example+ :}+(Mandatory,"reading")+<BLANKLINE>+(Skippable,"writing")+<BLANKLINE>++-} skippable :: (Monoid w,Monad m) => s -> Plan s w m i o -> Plan s w m (Maybe i) () skippable s (Plan forest (Star f)) = Plan (Steps (Seq.singleton (mempty,s,Skippable,forest)) mempty)
plan-applicative.cabal view
@@ -1,5 +1,5 @@ name: plan-applicative-version: 2.0.0.0+version: 2.0.0.1 synopsis: Applicative/Arrow for resource estimation and progress tracking. description: This module contains a writer-like Applicative for giving monoidal annotations to underlying computations. The@@ -43,12 +43,13 @@ test-suite doctests type: exitcode-stdio-1.0 ghc-options: -Wall -threaded- hs-source-dirs: tests+ hs-source-dirs: tests,lib main-is: doctests.hs+ other-modules: Control.Plan+ Control.Plan.Core build-depends: base >= 4.6 && < 5,- doctest >= 0.11,- plan-applicative+ doctest >= 0.11 default-language: Haskell2010 test-suite tests
tests/doctests.hs view
@@ -3,4 +3,4 @@ import Test.DocTest main :: IO ()-main = doctest [ "lib/Control/Plan.hs" ]+main = doctest ["lib/Control/Plan.hs","lib/Control/Plan/Core.hs"]