box 0.9.3.2 → 0.9.3.3
raw patch · 4 files changed
+77/−96 lines, 4 filesdep ~containersdep ~doctest-parallelPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: containers, doctest-parallel
API changes (from Hackage documentation)
- Box.Box: Box :: Committer m c -> Emitter m e -> Box m c e
+ Box.Box: Box :: Committer m c -> Emitter m e -> Box (m :: Type -> Type) c e
- Box.Box: CoBoxM :: Codensity m (Box m a b) -> CoBoxM m a b
+ Box.Box: CoBoxM :: Codensity m (Box m a b) -> CoBoxM (m :: Type -> Type) a b
- Box.Box: [committer] :: Box m c e -> Committer m c
+ Box.Box: [committer] :: Box (m :: Type -> Type) c e -> Committer m c
- Box.Box: [emitter] :: Box m c e -> Emitter m e
+ Box.Box: [emitter] :: Box (m :: Type -> Type) c e -> Emitter m e
- Box.Box: [uncobox] :: CoBoxM m a b -> Codensity m (Box m a b)
+ Box.Box: [uncobox] :: CoBoxM (m :: Type -> Type) a b -> Codensity m (Box m a b)
- Box.Box: class (Profunctor p) => DecAlt p
+ Box.Box: class Profunctor p => DecAlt (p :: Type -> Type -> Type)
- Box.Box: class Divap p
+ Box.Box: class Divap (p :: Type -> Type -> Type)
- Box.Box: cobox :: CoCommitter m a -> CoEmitter m b -> CoBox m a b
+ Box.Box: cobox :: forall (m :: Type -> Type) a b. CoCommitter m a -> CoEmitter m b -> CoBox m a b
- Box.Box: data Box m c e
+ Box.Box: data Box (m :: Type -> Type) c e
- Box.Box: foistb :: (forall a. m a -> n a) -> Box m c e -> Box n c e
+ Box.Box: foistb :: (forall a. () => m a -> n a) -> Box m c e -> Box n c e
- Box.Box: newtype CoBoxM m a b
+ Box.Box: newtype CoBoxM (m :: Type -> Type) a b
- Box.Box: seqBox :: Monad m => Box (StateT (Seq a) m) a a
+ Box.Box: seqBox :: forall (m :: Type -> Type) a. Monad m => Box (StateT (Seq a) m) a a
- Box.Box: type CoBox m a b = Codensity m (Box m a b)
+ Box.Box: type CoBox (m :: Type -> Type) a b = Codensity m Box m a b
- Box.Codensity: (<$|>) :: forall a m r. (a -> m r) -> Codensity m a -> m r
+ Box.Codensity: (<$|>) :: forall {k} a m (r :: k). (a -> m r) -> Codensity m a -> m r
- Box.Codensity: (<*|>) :: Codensity m (a -> m r) -> Codensity m a -> m r
+ Box.Codensity: (<*|>) :: forall {k} m a (r :: k). Codensity m (a -> m r) -> Codensity m a -> m r
- Box.Codensity: close :: Codensity m (m r) -> m r
+ Box.Codensity: close :: forall {k} m (r :: k). Codensity m (m r) -> m r
- Box.Codensity: process :: forall a m r. (a -> m r) -> Codensity m a -> m r
+ Box.Codensity: process :: forall {k} a m (r :: k). (a -> m r) -> Codensity m a -> m r
- Box.Committer: Committer :: (a -> m Bool) -> Committer m a
+ Box.Committer: Committer :: (a -> m Bool) -> Committer (m :: Type -> Type) a
- Box.Committer: [commit] :: Committer m a -> a -> m Bool
+ Box.Committer: [commit] :: Committer (m :: Type -> Type) a -> a -> m Bool
- Box.Committer: listC :: Monad m => Committer m a -> Committer m [a]
+ Box.Committer: listC :: forall (m :: Type -> Type) a. Monad m => Committer m a -> Committer m [a]
- Box.Committer: newtype Committer m a
+ Box.Committer: newtype Committer (m :: Type -> Type) a
- Box.Committer: push :: Monad m => Committer (StateT (Seq a) m) a
+ Box.Committer: push :: forall (m :: Type -> Type) a. Monad m => Committer (StateT (Seq a) m) a
- Box.Committer: type CoCommitter m a = Codensity m (Committer m a)
+ Box.Committer: type CoCommitter (m :: Type -> Type) a = Codensity m Committer m a
- Box.Connectors: forkEmit :: Monad m => Emitter m a -> Committer m a -> Emitter m a
+ Box.Connectors: forkEmit :: forall (m :: Type -> Type) a. Monad m => Emitter m a -> Committer m a -> Emitter m a
- Box.Emitter: Emitter :: m (Maybe a) -> Emitter m a
+ Box.Emitter: Emitter :: m (Maybe a) -> Emitter (m :: Type -> Type) a
- Box.Emitter: [emit] :: Emitter m a -> m (Maybe a)
+ Box.Emitter: [emit] :: Emitter (m :: Type -> Type) a -> m (Maybe a)
- Box.Emitter: dropE :: Monad m => Int -> Emitter m a -> CoEmitter m a
+ Box.Emitter: dropE :: forall (m :: Type -> Type) a. Monad m => Int -> Emitter m a -> CoEmitter m a
- Box.Emitter: newtype Emitter m a
+ Box.Emitter: newtype Emitter (m :: Type -> Type) a
- Box.Emitter: pop :: Monad m => Emitter (StateT (Seq a) m) a
+ Box.Emitter: pop :: forall (m :: Type -> Type) a. Monad m => Emitter (StateT (Seq a) m) a
- Box.Emitter: readE :: (Functor m, Read a) => Emitter m Text -> Emitter m (Either Text a)
+ Box.Emitter: readE :: forall (m :: Type -> Type) a. (Functor m, Read a) => Emitter m Text -> Emitter m (Either Text a)
- Box.Emitter: takeE :: Monad m => Int -> Emitter m a -> Emitter (StateT Int m) a
+ Box.Emitter: takeE :: forall (m :: Type -> Type) a. Monad m => Int -> Emitter m a -> Emitter (StateT Int m) a
- Box.Emitter: takeUntilE :: Monad m => (a -> Bool) -> Emitter m a -> Emitter m a
+ Box.Emitter: takeUntilE :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> Emitter m a -> Emitter m a
- Box.Emitter: type CoEmitter m a = Codensity m (Emitter m a)
+ Box.Emitter: type CoEmitter (m :: Type -> Type) a = Codensity m Emitter m a
- Box.Emitter: unlistE :: Monad m => Emitter m [a] -> Emitter (StateT [a] m) a
+ Box.Emitter: unlistE :: forall (m :: Type -> Type) a. Monad m => Emitter m [a] -> Emitter (StateT [a] m) a
- Box.Functor: class FFunctor (h :: (Type -> Type) -> Type -> Type)
+ Box.Functor: class FFunctor (h :: Type -> Type -> Type -> Type)
- Box.Functor: class FoldableM (t :: (Type -> Type) -> Type -> Type)
+ Box.Functor: class FoldableM (t :: Type -> Type -> Type -> Type)
- Box.Functor: foist :: FFunctor h => (forall x. f x -> g x) -> h f a -> h g a
+ Box.Functor: foist :: FFunctor h => (forall x. () => f x -> g x) -> h f a -> h g a
Files
- box.cabal +76/−54
- readme.md +0/−39
- src/Box/Emitter.hs +0/−2
- src/Box/IO.hs +1/−1
box.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: box-version: 0.9.3.2+version: 0.9.3.3 license: BSD-3-Clause license-file: LICENSE copyright: Tony Day (c) 2017@@ -11,68 +11,90 @@ bug-reports: https://github.com/tonyday567/box/issues synopsis: A profunctor effect system? description:- This might be a profunctor effect system, but is unlike all the others, so it's hard to say for sure.+ This might be a profunctor effect system, but is unlike all the others, so it's hard to say for sure.+ build-type: Simple tested-with:- , GHC == 9.10.1- , GHC == 9.8.2- , GHC == 9.6.5+ ghc ==9.6.7+ ghc ==9.8.4+ ghc ==9.10.2+ ghc ==9.12.2+ extra-doc-files:- ChangeLog.md- readme.md+ ChangeLog.md+ readme.md source-repository head- type: git- location: https://github.com/tonyday567/box+ type: git+ location: https://github.com/tonyday567/box common ghc-options-stanza- ghc-options:- -Wall- -Wcompat- -Wincomplete-record-updates- -Wincomplete-uni-patterns- -Wredundant-constraints+ ghc-options:+ -Wall+ -Wcompat+ -Wincomplete-record-updates+ -Wincomplete-uni-patterns+ -Wredundant-constraints -common ghc2021-stanza- default-language: GHC2021+common ghc2024-additions+ default-extensions:+ DataKinds+ DerivingStrategies+ DisambiguateRecordFields+ ExplicitNamespaces+ GADTs+ LambdaCase+ MonoLocalBinds+ RoleAnnotations +common ghc2024-stanza+ if impl(ghc >=9.10)+ default-language:+ GHC2024+ else+ import: ghc2024-additions+ default-language:+ GHC2021+ library- import: ghc-options-stanza- import: ghc2021-stanza- hs-source-dirs: src- build-depends:- , async >=2.2 && <2.3- , base >=4.7 && <5- , bytestring >=0.11.3 && <0.13- , containers >=0.6 && <0.8- , contravariant >=1.5 && <1.6- , dlist >=1.0 && <1.1- , exceptions >=0.10 && <0.11- , kan-extensions >=5.2 && <5.3- , mtl >=2.2.2 && <2.4- , profunctors >=5.6.2 && <5.7- , semigroupoids >=5.3 && <6.1- , stm >=2.5.1 && <2.6- , text >=1.2 && <2.2- , time >=1.10 && <1.15- exposed-modules:- Box- Box.Box- Box.Codensity- Box.Committer- Box.Connectors- Box.Emitter- Box.Functor- Box.IO- Box.Queue- Box.Time+ import: ghc-options-stanza+ import: ghc2024-stanza+ hs-source-dirs: src+ build-depends:+ async >=2.2 && <2.3,+ base >=4.7 && <5,+ bytestring >=0.11.3 && <0.13,+ containers >=0.6 && <0.9,+ contravariant >=1.5 && <1.6,+ dlist >=1.0 && <1.1,+ exceptions >=0.10 && <0.11,+ kan-extensions >=5.2 && <5.3,+ mtl >=2.2.2 && <2.4,+ profunctors >=5.6.2 && <5.7,+ semigroupoids >=5.3 && <6.1,+ stm >=2.5.1 && <2.6,+ text >=1.2 && <2.2,+ time >=1.10 && <1.15, + exposed-modules:+ Box+ Box.Box+ Box.Codensity+ Box.Committer+ Box.Connectors+ Box.Emitter+ Box.Functor+ Box.IO+ Box.Queue+ Box.Time+ test-suite doctests- import: ghc2021-stanza- main-is: doctests.hs- hs-source-dirs: test- build-depends:- , base >=4.14 && <5- , doctest-parallel >=0.3 && <0.4- ghc-options: -threaded- type: exitcode-stdio-1.0+ import: ghc2024-stanza+ main-is: doctests.hs+ hs-source-dirs: test+ build-depends:+ base >=4.14 && <5,+ doctest-parallel >=0.3 && <0.5,++ ghc-options: -threaded+ type: exitcode-stdio-1.0
readme.md view
@@ -6,8 +6,6 @@ > What is all this stuff around me; this stream of experiences that I seem to be having all the time? Throughout history there have been people who say it is all illusion. ~ S Blackmore -<a id="org2ba6799"></a>- # Usage :set -XOverloadedStrings@@ -43,13 +41,8 @@ echo: echo -<a id="orgb128561"></a>- # Library Design --<a id="orgd99cf15"></a>- ### Resource Coinduction Haskell has an affinity with [coinductive functions](https://www.reddit.com/r/haskell/comments/j3kbge/comment/g7foelq/?utm_source=share&utm_medium=web2x&context=3); functions should expose destructors and allow for infinite data.@@ -66,9 +59,6 @@ These are the destructors that need to be transparently exposed if effects are to be good citizens in Haskell. --<a id="org2a2a0b7"></a>- ### What is a Box? A Box is simply the product of a consumer destructor and a producer destructor.@@ -78,9 +68,6 @@ emitter :: Emitter m e } --<a id="org23b3a97"></a>- ### Committer The library denotes a consumer by wrapping a consumption destructor and calling it a Committer. Like much of base, there is failure hidden in the getLine example type. A better approach, for a consumer, is to signal whether consumption actually occurred.@@ -106,9 +93,6 @@ echoC :: Committer IO Text echoC = contramap (Text.unpack . ("echo: "<>)) stdC --<a id="org5a69dab"></a>- ### Emitter The library denotes a producer by wrapping a production destructor and calling it an Emitter.@@ -134,8 +118,6 @@ defined at <interactive>:49:1 -<a id="org7eb6547"></a>- ### Box duality A Box represents a duality in two ways:@@ -164,9 +146,6 @@ fuse (pure . pure) stdIO --<a id="org6c7b1fc"></a>- ### Continuation As with many operators in the library, `qList` is actually a continuation:@@ -231,9 +210,6 @@ b c --<a id="org9d9d756"></a>- # Explicit Continuation Yield-style streaming libraries are [coroutines](https://rubenpieters.github.io/assets/papers/JFP20-pipes.pdf), sum types that embed and mix continuation logic in with other stuff like effect decontruction. `box` sticks to a corner case of a product type representing a consumer and producer. The major drawback of eschewing coroutines is that continuations become explicit and difficult to hide. One example; taking the first n elements of an Emitter:@@ -251,30 +227,18 @@ glueES :: (Monad m) => s -> Committer m a -> Emitter (StateT s m) a -> m () glueES s c e = flip evalStateT s $ glue (foist lift c) e --<a id="orgde76b6e"></a>- # Future directions The design and concepts contained within the box library is a hodge-podge, but an interesting mess, being at quite a busy confluence of recent developments. --<a id="orga1ab71e"></a>- ## Optics A Box is an adapter in the [language of optics](http://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/poptics.pdf) and the relationship between a resource’s committer and emitter could be modelled by other optics. --<a id="org1cf8e47"></a>- ## Categorical Profunctor The deprecation of Box.Functor awaits the development of [categorical functors](https://github.com/haskell/core-libraries-committee/issues/91#issuecomment-1325337471). Similarly to Filterable the type of a Box could be something like `FunctorOf Op(Kleisli Maybe) (Kleisli Maybe) (->)`. Or it could be something like the SISO type in [Programming with Monoidal Profunctors and Semiarrows](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4496714). --<a id="orgedd280b"></a>- ## Wider Types Alternatively, the types could be widened:@@ -303,9 +267,6 @@ type CommitterB m a = Committer (MaybeT m) a type EmitterB m a = Emitter (MaybeT m) a type BoxB m b a = Box (MaybeT m) (MaybeT m) b a---<a id="orgae9938a"></a> ## Introduce a [nucleus](https://golem.ph.utexas.edu/category/2013/08/the_nucleus_of_a_profunctor_so.html)
src/Box/Emitter.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE ExplicitNamespaces #-}- -- | 'Emitter' wraps a producer destructor. -- -- "Every Thought emits a Dice Throw" ~ Stéphane Mallarmé
src/Box/IO.hs view
@@ -46,7 +46,7 @@ import Data.IORef import Data.Sequence qualified as Seq import Data.String-import Data.Text as Text hiding (null)+import Data.Text as Text hiding (null, show) import Data.Text.Encoding import Data.Text.IO as Text import System.IO as IO