bluefin-contrib (empty) → 0.0.16.0
raw patch · 4 files changed
+129/−0 lines, 4 filesdep +basedep +bluefin
Dependencies added: base, bluefin
Files
- CHANGELOG.md +3/−0
- LICENSE +20/−0
- bluefin-contrib.cabal +81/−0
- src/Bluefin/Contrib/State.hs +25/−0
+ CHANGELOG.md view
@@ -0,0 +1,3 @@+# 0.16.0.0++* Add `runManyStates`, thanks to Kari Pahula
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2024 Tom Ellis++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ bluefin-contrib.cabal view
@@ -0,0 +1,81 @@+cabal-version: 3.0+name: bluefin-contrib+version: 0.0.16.0+license: MIT+license-file: LICENSE+author: Tom Ellis+maintainer: Tom Ellis+build-type: Simple+extra-doc-files: CHANGELOG.md+description: The Bluefin effect system, user contributions+synopsis: The Bluefin effect system, user contributions+homepage: https://github.com/tomjaguarpaw/bluefin+bug-reports: https://github.com/tomjaguarpaw/bluefin/issues++common defaults+ ghc-options: -Wall+ default-extensions:+ -- GHC2021+ BangPatterns+ BinaryLiterals+ ConstrainedClassMethods+ ConstraintKinds+ DeriveDataTypeable+ DeriveFoldable+ DeriveFunctor+ DeriveGeneric+ DeriveLift+ DeriveTraversable+ DoAndIfThenElse+ EmptyCase+ EmptyDataDecls+ EmptyDataDeriving+ ExistentialQuantification+ ExplicitForAll+ -- Not available until 9.2+ -- FieldSelectors+ FlexibleContexts+ FlexibleInstances+ ForeignFunctionInterface+ GADTSyntax+ GeneralisedNewtypeDeriving+ HexFloatLiterals+ ImplicitPrelude+ ImportQualifiedPost+ InstanceSigs+ KindSignatures+ MonomorphismRestriction+ MultiParamTypeClasses+ NamedFieldPuns+ NamedWildCards+ NumericUnderscores+ PatternGuards+ PolyKinds+ PostfixOperators+ RankNTypes+ RelaxedPolyRec+ ScopedTypeVariables+ StandaloneDeriving+ StandaloneKindSignatures+ StarIsType+ TraditionalRecordSyntax+ TupleSections+ TypeApplications+ TypeOperators+ TypeSynonymInstances+ NoExplicitNamespaces+ -- Others+ DataKinds+ DerivingStrategies+ GADTs+ LambdaCase++library+ import: defaults+ default-language: Haskell2010+ hs-source-dirs: src+ build-depends:+ base >= 4.12 && < 4.22,+ bluefin >= 0.0.16.0 && < 0.1+ exposed-modules:+ Bluefin.Contrib.State
+ src/Bluefin/Contrib/State.hs view
@@ -0,0 +1,25 @@+module Bluefin.Contrib.State where++import Bluefin.Eff (Eff, Effects, (:&))+import Bluefin.State (State, get)+import Bluefin.StateSource (newState, withStateSource)++-- |+-- @+-- >>> 'Bluefin.EFf.runPureEff' $ runManyStates [10,15,20] $ 'Data.Traversable.traverse' $ \\st -> do+-- n <- 'Bluefin.State.get' st+-- pure (2 * n)+-- ([20,30,40],[10,15,20])+-- @+runManyStates ::+ (Traversable t) =>+ t s ->+ (forall (e :: Effects). t (State s e) -> Eff (e :& es) a) ->+ -- | ͘+ Eff es (a, t s)+runManyStates ss f =+ withStateSource $ \source -> do+ states <- traverse (newState source) ss+ a <- f states+ ss' <- traverse get states+ pure (a, ss')