packages feed

polytropos-lens 0.1.0.3 → 0.1.0.4

raw patch · API changes only · 3 files changed · show whitespace changes · browse polytropos-lens-0.1.0.4

+20/−15 lines, 3 filesdep ~polytropos-coredep ~polytropos-pluginPVP: major bump suggested

Dependency ranges changed: polytropos-core, polytropos-plugin

API changes (from Hackage documentation)

1 removed, 1 added, 1 changed

API removals or changes: PVP suggests a major version bump

- Polytropos.Lens: instance (GHC.TypeLits.KnownSymbol n, Polytropos.Lens.FieldNames r) => Polytropos.Lens.FieldNames ((n 'Polytropos.Core.:= a) : r)
+ Polytropos.Lens: instance (GHC.Internal.TypeLits.KnownSymbol n, Polytropos.Lens.FieldNames r) => Polytropos.Lens.FieldNames ((n 'Polytropos.Core.:= a) : r)
- Polytropos.Lens: prismVariant :: forall (c :: Symbol) (s :: SumRow) (fs :: Row). ConstructorIndex c s => Field c -> Prism' (Variant s) (Record fs)
+ Polytropos.Lens: prismVariant :: forall (c :: Symbol) (s :: SumRow). ConstructorIndex c s => Field c -> Prism' (Variant s) (Record (ConstructorPayload c s))

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for polytropos-lens +## 0.1.0.4 — 2026-11-22++- Constrain `prismVariant` constructor payload type to `ConstructorPayload c s`.+- Require `polytropos-core >= 0.1.2.0 && < 0.2` and `polytropos-plugin >= 0.1.2.0 && < 0.2`.+ ## 0.1.0.0 — Initial Release  - Full `Control.Lens` optics integration for open records and variants
polytropos-lens.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: polytropos-lens-version: 0.1.0.3+version: 0.1.0.4 synopsis: Comprehensive lens-suite integration for polytropos open records and variants description:   Comprehensive optics integration between <https://hackage.haskell.org/package/polytropos polytropos> open records and variants@@ -42,8 +42,8 @@     base >= 4.14 && < 5,     lens >= 5.2 && < 5.4,     profunctors >= 5.6 && < 5.7,-    polytropos-core >= 0.1 && < 0.2,-    polytropos-plugin >= 0.1 && < 0.2+    polytropos-core >= 0.1.2.0 && < 0.2,+    polytropos-plugin >= 0.1.2.0 && < 0.2  test-suite polytropos-lens-test   type: exitcode-stdio-1.0@@ -54,9 +54,9 @@   build-depends:     base,     lens,-    polytropos-core,+    polytropos-core >= 0.1.2.0 && < 0.2,     polytropos-lens,-    polytropos-plugin,+    polytropos-plugin >= 0.1.2.0 && < 0.2,     profunctors,     tasty,     tasty-hunit
src/Polytropos/Lens.hs view
@@ -104,7 +104,8 @@                               Prism', preview, prism, set, (<&>)) import GHC.Exts              (toList) import GHC.TypeLits          (KnownSymbol, symbolVal)-import Polytropos            (Record, Variant, Field (..), injectVariant)+import Polytropos            (ConstructorPayload, Record, Variant,+                              Field (..), injectVariant) import Polytropos.Core       (ConstructorIndex (..), FieldIndex (..), Pair (..),                               Row, fieldAt, noInlineUnsafeCo, productRep,                               projectRep, repVals, setFieldAt, RowRep (..))@@ -277,12 +278,11 @@ -- Built from 'Polytropos.injectVariant' and 'Polytropos.Core.projectRep': the -- 'ConstructorIndex' dictionary carries the constructor's tag as a literal, -- so matching is a single runtime tag comparison.-prismVariant :: forall c s fs. ConstructorIndex c s-             => Field c -> Prism' (Variant s) (Record fs)-prismVariant f = prism (injectVariant f) project-  where+prismVariant :: forall c s. ConstructorIndex c s+             => Field c -> Prism' (Variant s) (Record (ConstructorPayload c s))+prismVariant f = prism (injectVariant f) project where+  -- maybeToEither from extra would be nice   project :: Variant s -> Either (Variant s) (Record fs)-    project (RowRep rep) =-      case projectRep (constructorIndex @_ @c @s) rep of-        Just prodRep -> Right (RowRep prodRep)-        Nothing      -> Left (RowRep rep)+  project rowRep@(RowRep rep)+    = maybe (Left rowRep) (Right . RowRep)+    $ projectRep (constructorIndex @_ @c @s) rep