selective 0.7 → 0.7.0.1
raw patch · 16 files changed
+47/−46 lines, 16 filesdep ~base
Dependency ranges changed: base
Files
- CHANGES.md +4/−0
- LICENSE +1/−1
- README.md +3/−3
- examples/Build.hs +1/−2
- examples/Parser.hs +1/−2
- examples/Processor.hs +1/−2
- examples/Teletype.hs +1/−2
- examples/Teletype/Rigid.hs +1/−2
- examples/Validation.hs +1/−2
- selective.cabal +8/−8
- src/Control/Selective.hs +10/−4
- src/Control/Selective/Free.hs +2/−3
- src/Control/Selective/Multi.hs +2/−3
- src/Control/Selective/Rigid/Free.hs +2/−3
- src/Control/Selective/Rigid/Freer.hs +2/−3
- src/Control/Selective/Trans/Except.hs +7/−6
CHANGES.md view
@@ -1,5 +1,9 @@ # Change log +## 0.7.0.1++* Start supporting GHC 9.6. See #72.+ ## 0.7 * Drop `MonadTrans (ExceptT e)` instance to allow `transformers-0.6.1`.
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2023 Andrey Mokhov+Copyright (c) 2018-2024 Andrey Mokhov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
README.md view
@@ -1,10 +1,10 @@ # Selective applicative functors -[](https://hackage.haskell.org/package/selective) [](https://github.com/snowleopard/selective/actions)+[](https://hackage.haskell.org/package/selective) [](https://github.com/snowleopard/selective/actions) This is a library for *selective applicative functors*, or just *selective functors* for short, an abstraction between applicative functors and monads, introduced in-[this paper](https://dl.acm.org/ft_gateway.cfm?id=3341694).+[this paper](https://dl.acm.org/doi/10.1145/3341694). ## What are selective functors? @@ -287,5 +287,5 @@ ## Further reading -* A paper introducing selective functors: https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+* An ICFP'19 paper introducing selective functors: https://doi.org/10.1145/3341694. * An older blog post introducing selective functors: https://blogs.ncl.ac.uk/andreymokhov/selective.
examples/Build.hs view
@@ -4,8 +4,7 @@ import Control.Selective import Control.Selective.Rigid.Free --- See Section 3 of the paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf+-- See Section 3 of the paper: https://dl.acm.org/doi/10.1145/3341694. -- | Selective build tasks. -- See "Build Systems à la Carte": https://dl.acm.org/citation.cfm?id=3236774.
examples/Parser.hs view
@@ -5,8 +5,7 @@ import Control.Monad import Control.Selective --- See Section 7.2 of the paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf+-- See Section 7.2 of the paper: https://dl.acm.org/doi/10.1145/3341694. newtype Parser a = Parser { parse :: String -> [(a, String)] }
examples/Processor.hs view
@@ -16,8 +16,7 @@ import qualified Control.Monad.Trans.State as S import qualified Data.Map.Strict as Map --- See Section 5.3 of the paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf+-- See Section 5.3 of the paper: https://dl.acm.org/doi/10.1145/3341694. -- Note that we have changed the naming. -- | A standard @MonadState@ class extended with the 'Selective' interface.
examples/Teletype.hs view
@@ -7,8 +7,7 @@ import Control.Selective import Control.Selective.Free --- See Section 5.2 of the paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf+-- See Section 5.2 of the paper: https://dl.acm.org/doi/10.1145/3341694. -- | The classic @Teletype@ base functor. data TeletypeF a = Read (String -> a) | Write String a deriving Functor
examples/Teletype/Rigid.hs view
@@ -7,8 +7,7 @@ import Control.Selective import Control.Selective.Rigid.Free --- See Section 5.2 of the paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf+-- See Section 5.2 of the paper: https://dl.acm.org/doi/10.1145/3341694. -- | The classic @Teletype@ base functor. data TeletypeF a = Read (String -> a) | Write String a deriving Functor
examples/Validation.hs view
@@ -3,8 +3,7 @@ import Control.Selective --- See Section 2.2 of the paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf+-- See Section 2.2 of the paper: https://dl.acm.org/doi/10.1145/3341694. type Radius = Word type Width = Word
selective.cabal view
@@ -1,24 +1,24 @@ name: selective-version: 0.7+version: 0.7.0.1 synopsis: Selective applicative functors license: MIT license-file: LICENSE author: Andrey Mokhov <andrey.mokhov@gmail.com>, github: @snowleopard maintainer: Andrey Mokhov <andrey.mokhov@gmail.com>, github: @snowleopard-copyright: Andrey Mokhov, 2018-2023+copyright: Andrey Mokhov, 2018-2024 homepage: https://github.com/snowleopard/selective bug-reports: https://github.com/snowleopard/selective/issues category: Control build-type: Simple cabal-version: 1.18-tested-with: GHC==9.4.4, GHC==9.2.6, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5+tested-with: GHC==9.8.2, GHC==9.6.3, GHC==9.4.7, GHC==9.2.8, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5 description: Selective applicative functors: declare your effects statically, select which to execute dynamically. . This is a library for /selective applicative functors/, or just /selective functors/ for short, an abstraction between applicative functors and monads, introduced in- <https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf this paper>.+ <https://dl.acm.org/doi/10.1145/3341694 this paper>. extra-doc-files: CHANGES.md@@ -36,8 +36,7 @@ Control.Selective.Rigid.Free, Control.Selective.Rigid.Freer, Control.Selective.Trans.Except- build-depends: base >= 4.9 && < 5,- containers >= 0.5.5.1 && < 0.7,+ build-depends: base >= 4.12 && < 5, transformers >= 0.4.2.0 && < 0.7 default-language: Haskell2010 other-extensions: DeriveFunctor,@@ -46,7 +45,8 @@ GeneralizedNewtypeDeriving, RankNTypes, StandaloneDeriving,- TupleSections+ TupleSections,+ DerivingVia ghc-options: -Wall -fno-warn-name-shadowing -Wcompat@@ -71,7 +71,7 @@ type: exitcode-stdio-1.0 main-is: Main.hs build-depends: base >= 4.7 && < 5,- containers >= 0.5.5.1 && < 0.7,+ containers >= 0.5.5.1 && < 0.8, QuickCheck >= 2.8 && < 2.15, selective, transformers >= 0.4.2.0 && < 0.7
src/Control/Selective.hs view
@@ -4,15 +4,14 @@ ----------------------------------------------------------------------------- -- | -- Module : Control.Selective--- Copyright : (c) Andrey Mokhov 2018-2023+-- Copyright : (c) Andrey Mokhov 2018-2024 -- License : MIT (see the file LICENSE) -- Maintainer : andrey.mokhov@gmail.com -- Stability : experimental -- -- This is a library for /selective applicative functors/, or just -- /selective functors/ for short, an abstraction between applicative functors--- and monads, introduced in this paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+-- and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694. -- ----------------------------------------------------------------------------- module Control.Selective (@@ -297,7 +296,14 @@ -- | A lifted version of 'Data.Maybe.fromMaybe'. fromMaybeS :: Selective f => f a -> f (Maybe a) -> f a-fromMaybeS x mx = select (maybe (Left ()) Right <$> mx) (const <$> x)+fromMaybeS fNothing fMaybe =+ select (toEither <$> fMaybe) (toUnitFunction <$> fNothing)+ where+ toEither :: Maybe a -> Either () a+ toEither Nothing = Left ()+ toEither (Just a) = Right a+ toUnitFunction :: a -> () -> a+ toUnitFunction x () = x -- | Return the first @Right@ value. If both are @Left@'s, accumulate errors. orElse :: (Selective f, Semigroup e) => f (Either e a) -> f (Either e a) -> f (Either e a)
src/Control/Selective/Free.hs view
@@ -2,15 +2,14 @@ ----------------------------------------------------------------------------- -- | -- Module : Control.Selective.Free--- Copyright : (c) Andrey Mokhov 2018-2023+-- Copyright : (c) Andrey Mokhov 2018-2024 -- License : MIT (see the file LICENSE) -- Maintainer : andrey.mokhov@gmail.com -- Stability : experimental -- -- This is a library for /selective applicative functors/, or just -- /selective functors/ for short, an abstraction between applicative functors--- and monads, introduced in this paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+-- and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694. -- -- This module defines /free selective functors/ using the ideas from the -- Sjoerd Visscher's package 'free-functors':
src/Control/Selective/Multi.hs view
@@ -3,15 +3,14 @@ ----------------------------------------------------------------------------- -- | -- Module : Control.Selective.Multi--- Copyright : (c) Andrey Mokhov 2018-2023+-- Copyright : (c) Andrey Mokhov 2018-2024 -- License : MIT (see the file LICENSE) -- Maintainer : andrey.mokhov@gmail.com -- Stability : experimental -- -- This is a library for /selective applicative functors/, or just -- /selective functors/ for short, an abstraction between applicative functors--- and monads, introduced in this paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+-- and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694. -- -- This module defines /multi-way selective functors/, which are more efficient -- when selecting from a large number of options. They also fully subsume the
src/Control/Selective/Rigid/Free.hs view
@@ -2,15 +2,14 @@ ----------------------------------------------------------------------------- -- | -- Module : Control.Selective.Rigid.Free--- Copyright : (c) Andrey Mokhov 2018-2023+-- Copyright : (c) Andrey Mokhov 2018-2024 -- License : MIT (see the file LICENSE) -- Maintainer : andrey.mokhov@gmail.com -- Stability : experimental -- -- This is a library for /selective applicative functors/, or just -- /selective functors/ for short, an abstraction between applicative functors--- and monads, introduced in this paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+-- and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694. -- -- This module defines /free rigid selective functors/. Rigid selective functors -- are those that satisfy the property @\<*\> = apS@.
src/Control/Selective/Rigid/Freer.hs view
@@ -2,15 +2,14 @@ ----------------------------------------------------------------------------- -- | -- Module : Control.Selective.Rigid.Freer--- Copyright : (c) Andrey Mokhov 2018-2023+-- Copyright : (c) Andrey Mokhov 2018-2024 -- License : MIT (see the file LICENSE) -- Maintainer : andrey.mokhov@gmail.com -- Stability : experimental -- -- This is a library for /selective applicative functors/, or just -- /selective functors/ for short, an abstraction between applicative functors--- and monads, introduced in this paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+-- and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694. -- -- This module defines /freer rigid selective functors/. Rigid selective -- functors are those that satisfy the property @\<*\> = apS@. Compared to the
src/Control/Selective/Trans/Except.hs view
@@ -1,16 +1,16 @@ {-# LANGUAGE CPP, GeneralizedNewtypeDeriving, DeriveTraversable, DerivingVia #-}+{-# OPTIONS_GHC -Wno-redundant-constraints #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Selective.Trans.Except--- Copyright : (c) Andrey Mokhov 2018-2023+-- Copyright : (c) Andrey Mokhov 2018-2024 -- License : MIT (see the file LICENSE) -- Maintainer : andrey.mokhov@gmail.com -- Stability : experimental -- -- This is a library for /selective applicative functors/, or just -- /selective functors/ for short, an abstraction between applicative functors--- and monads, introduced in this paper:--- https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf.+-- and monads, introduced in this paper: https://dl.acm.org/doi/10.1145/3341694. -- -- This module defines a newtype around 'ExceptT' from @transformers@ with less -- restrictive 'Applicative', 'Selective', and 'Alternative' implementations.@@ -45,9 +45,10 @@ -- | A newtype wrapper around 'T.ExceptT' from @transformers@ that provides less -- restrictive 'Applicative', 'Selective' and 'Alternative' instances. newtype ExceptT e f a = ExceptT { unwrap :: T.ExceptT e f a }- deriving- ( Functor, Foldable, Traversable, Monad, Contravariant, Eq, Ord, Read, Show- , MonadFix, MonadFail, MonadZip, MonadIO, MonadPlus, Eq1, Ord1, Read1, Show1 )+ deriving stock (Functor, Foldable, Traversable, Eq, Ord, Read, Show)+ deriving newtype+ (Monad, Contravariant, MonadFix, MonadFail, MonadZip, MonadIO, MonadPlus+ , Eq1, Ord1, Read1, Show1 ) -- These require -Wno-redundant-constraints deriving (Applicative, Selective, Alternative) via (ComposeEither f e) {- Why don't we provide a `MonadTrans (ExceptT e)` instance?