list-witnesses 0.1.1.0 → 0.1.1.1
raw patch · 4 files changed
+28/−57 lines, 4 filesdep +microlensPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: microlens
API changes (from Hackage documentation)
- Data.Type.List.Edit: recLens :: forall as bs x y g f. Functor f => Substitute as bs x y -> (g x -> f (g y)) -> Rec g as -> f (Rec g bs)
+ Data.Type.List.Edit: recLens :: forall as bs x y f. () => Substitute as bs x y -> Lens (Rec f as) (Rec f bs) (f x) (f y)
- Data.Type.List.Sublist: prefixLens :: forall as bs g f. Functor f => Prefix as bs -> (Rec g as -> f (Rec g as)) -> Rec g bs -> f (Rec g bs)
+ Data.Type.List.Sublist: prefixLens :: Prefix as bs -> Lens' (Rec f bs) (Rec f as)
- Data.Type.List.Sublist: suffixLens :: forall as bs g f. Functor f => Suffix as bs -> (Rec g as -> f (Rec g as)) -> Rec g bs -> f (Rec g bs)
+ Data.Type.List.Sublist: suffixLens :: Suffix as bs -> Lens' (Rec f bs) (Rec f as)
Files
- CHANGELOG.md +10/−0
- list-witnesses.cabal +5/−3
- src/Data/Type/List/Edit.hs +7/−17
- src/Data/Type/List/Sublist.hs +6/−37
CHANGELOG.md view
@@ -1,6 +1,16 @@ Changelog ========= +Version 0.1.1.1+---------------++*August 3, 2019*++<https://github.com/mstksg/list-witnesses/releases/tag/v0.1.1.1>++* Add *microlens* as a dependency, and use actual type synonyms for lenses.+ Also got rid of re-implementations of over and view.+ Version 0.1.1.0 ---------------
list-witnesses.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 784d1aade7631704441e88a915802c6f9bcdec2f07af75df75f043d1380a6dd1+-- hash: a6892eb45e6aae7a7e7c3f4b23c95bdd2299a3a95a190137567cd326e5045529 name: list-witnesses-version: 0.1.1.0+version: 0.1.1.1 synopsis: Witnesses for working with type-level lists description: Collection of assorted inductive witnesses and functions for working with type-level lists.@@ -24,6 +24,7 @@ copyright: (c) Justin Le 2018 license: BSD3 license-file: LICENSE+tested-with: GHC >= 8.4 build-type: Simple extra-source-files: README.md@@ -45,6 +46,7 @@ build-depends: base >=4.7 && <5 , decidable >=0.1.5+ , microlens , profunctors , singletons , vinyl
src/Data/Type/List/Edit.hs view
@@ -59,11 +59,11 @@ , SubstituteIndexSym0, SubstituteIndexSym ) where -import Data.Functor.Identity import Data.Kind import Data.Singletons import Data.Type.Universe import Data.Vinyl.Core+import Lens.Micro import qualified Control.Category as C -- | An @'Insert' as bs x@ is a witness that you can insert @x@ into some@@ -230,14 +230,6 @@ -- | A type-changing lens into a value in a 'Rec', given a 'Substitute' -- indicating which value. ----- Read this type signature as:------ @--- 'recLens'--- :: 'Substitute' as bs x y--- -> Lens ('Rec' f as) (Rec f bs) (f x) (f y)--- @--- -- For example: -- -- @@@ -252,16 +244,14 @@ -- This is similar to 'rlensC' from /vinyl/, but is built explicitly and -- inductively, instead of using typeclass magic. recLens- :: forall as bs x y g f. Functor f+ :: forall as bs x y f. () => Substitute as bs x y- -> (g x -> f (g y))- -> Rec g as- -> f (Rec g bs)-recLens s0 f = go s0+ -> Lens (Rec f as) (Rec f bs) (f x) (f y)+recLens s0 (f :: f x -> g (f y)) = go s0 where go :: Substitute cs ds x y- -> Rec g cs- -> f (Rec g ds)+ -> Rec f cs+ -> g (Rec f ds) go = \case SubZ -> \case x :& xs -> (:& xs) <$> f x@@ -275,7 +265,7 @@ -> (f x -> f y) -> Rec f as -> Rec f bs-substituteRec s f = runIdentity . recLens s (Identity . f)+substituteRec s = over (recLens s) -- | If you add an item to @as@ to create @bs@, you also need to shift an -- @'Index' as y@ to @Index bs y@. This shifts the 'Index' in @as@ to
src/Data/Type/List/Sublist.hs view
@@ -40,12 +40,13 @@ , injectIndexL, injectIndexR, unweaveIndex ) where -import Control.Applicative import Data.Bifunctor import Data.Kind import Data.Profunctor import Data.Type.Universe import Data.Vinyl.Core+import Lens.Micro+import Lens.Micro.Extras -- | A @'Prefix' as bs@ witnesses that @as@ is a prefix of @bs@. --@@ -70,28 +71,12 @@ deriving instance Show (Prefix as bs) -- | A lens into the prefix of a 'Rec'.------ Read this type signature as:------ @--- 'prefixLens'--- :: Prefix as bs--- -> Lens' (Rec f bs) (Rec f as)--- @-prefixLens- :: forall as bs g f. Functor f- => Prefix as bs- -> (Rec g as -> f (Rec g as))- -> Rec g bs- -> f (Rec g bs)+prefixLens :: Prefix as bs -> Lens' (Rec f bs) (Rec f as) prefixLens p = prefixToAppend p $ \a -> splitRecIso a . _1- where- _1 :: (a -> f b) -> (a, c) -> f (b, c)- _1 f (x, y) = (, y) <$> f x -- | Take items from a 'Rec' corresponding to a given 'Prefix'. takeRec :: Prefix as bs -> Rec f bs -> Rec f as-takeRec p = getConst . prefixLens p Const+takeRec p = view (prefixLens p) -- | A @'Suffix' as bs@ witnesses that @as@ is a suffix of @bs@. --@@ -116,28 +101,12 @@ deriving instance Show (Suffix as bs) -- | A lens into the suffix of a 'Rec'.------ Read this type signature as:------ @--- 'suffixLens'--- :: Suffix as bs--- -> Lens' (Rec f bs) (Rec f as)--- @-suffixLens- :: forall as bs g f. Functor f- => Suffix as bs- -> (Rec g as -> f (Rec g as))- -> Rec g bs- -> f (Rec g bs)+suffixLens :: Suffix as bs -> Lens' (Rec f bs) (Rec f as) suffixLens p = suffixToAppend p $ \a -> splitRecIso a . _2- where- _2 :: (a -> f b) -> (c, a) -> f (c, b)- _2 f (x, y) = (x ,) <$> f y -- | Drop items from a 'Rec' corresponding to a given 'Suffix'. dropRec :: Suffix as bs -> Rec f bs -> Rec f as-dropRec p = getConst . suffixLens p Const+dropRec p = view (suffixLens p) -- | An @'Append' as bs cs@ witnesses that @cs@ is the result of appending -- @as@ and @bs@.