Moduleoptics-core-0.4.2Haskell2010
Optics.Internal.Generic.TypeLevel
This module is intended for internal use only, and may change without warning in subsequent releases.
- 2 types
- Packageoptics-core-0.4.2
- Exports9
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceTypeLevel.hs
Pathing
2 declarationsInstances17GAffineFieldMaybe, GSetFieldProd, GConstructorSum, GFieldProd, …
r ~ b => GSetFieldProd '[] (M1 S m (Rec0 a)) (M1 S m (Rec0 b)) rDefined in optics-core-0.4.2 · Optics.Internal.GenericGConstructorTuple g h a b => GConstructorSum '[] (M1 C m g) (M1 C m h) a bDefined in optics-core-0.4.2 · Optics.Internal.Generic(r ~ a, s ~ b) => GFieldProd '[] (M1 S m (Rec0 a)) (M1 S m (Rec0 b)) r sDefined in optics-core-0.4.2 · Optics.Internal.GenericGFieldProd prodPath g h a b => GAffineFieldMaybe ('Right prodPath) g h a bDefined in optics-core-0.4.2 · Optics.Internal.Genericg ~ h => GAffineFieldMaybe ('Left name) g h a bDefined in optics-core-0.4.2 · Optics.Internal.GenericGSetFieldProd path g1 h1 b => GSetFieldProd ('PathLeft ': path) (g1 :*: g2) (h1 :*: g2) bDefined in optics-core-0.4.2 · Optics.Internal.GenericGSetFieldProd path g2 h2 b => GSetFieldProd ('PathRight ': path) (g1 :*: g2) (g1 :*: h2) bDefined in optics-core-0.4.2 · Optics.Internal.Generic(GSetFieldProd path g1 h1 b, g2 ~ h2) => GSetFieldProd ('PathLeft ': path) (g1 :*: g2) (h1 :*: h2) bDefined in optics-core-0.4.2 · Optics.Internal.Generic(GSetFieldProd path g2 h2 b, g1 ~ h1) => GSetFieldProd ('PathRight ': path) (g1 :*: g2) (h1 :*: h2) bDefined in optics-core-0.4.2 · Optics.Internal.GenericGConstructorSum path g1 h1 a b => GConstructorSum ('PathLeft ': path) (g1 :+: g2) (h1 :+: g2) a bDefined in optics-core-0.4.2 · Optics.Internal.GenericGConstructorSum path g2 h2 a b => GConstructorSum ('PathRight ': path) (g1 :+: g2) (g1 :+: h2) a bDefined in optics-core-0.4.2 · Optics.Internal.Generic(GConstructorSum path g1 h1 a b, g2 ~ h2) => GConstructorSum ('PathLeft ': path) (g1 :+: g2) (h1 :+: h2) a bDefined in optics-core-0.4.2 · Optics.Internal.Generic(GConstructorSum path g2 h2 a b, g1 ~ h1) => GConstructorSum ('PathRight ': path) (g1 :+: g2) (h1 :+: h2) a bDefined in optics-core-0.4.2 · Optics.Internal.GenericGFieldProd path g1 h1 a b => GFieldProd ('PathLeft ': path) (g1 :*: g2) (h1 :*: g2) a bDefined in optics-core-0.4.2 · Optics.Internal.GenericGFieldProd path g2 h2 a b => GFieldProd ('PathRight ': path) (g1 :*: g2) (g1 :*: h2) a bDefined in optics-core-0.4.2 · Optics.Internal.Generic(GFieldProd path g1 h1 a b, g2 ~ h2) => GFieldProd ('PathLeft ': path) (g1 :*: g2) (h1 :*: h2) a bDefined in optics-core-0.4.2 · Optics.Internal.Generic(GFieldProd path g2 h2 a b, g1 ~ h1) => GFieldProd ('PathRight ': path) (g1 :*: g2) (h1 :*: h2) a bDefined in optics-core-0.4.2 · Optics.Internal.Generic
Names
family
type family GetFieldPaths (s :: t) (name :: Symbol) (g :: k -> Type) :: PathTree Symbol whereCompute paths to a field with a specific name.
Equations
GetFieldPaths s name (M1 D _1 g) = GetFieldPaths s name gGetFieldPaths s name (g1 :+: g2) = 'PathNode (GetFieldPaths s name g1) (GetFieldPaths s name g2)GetFieldPaths s name (M1 C _1 g) = 'PathLeaf (GetNamePath name g '[])GetFieldPaths s name V1 = TypeError (('Text"Type "
':<>: QuoteType s) ':<>: 'Text" has no data constructors"
)
family
type family GetNamePath (name :: Symbol) (g :: k -> Type) (acc :: [Path]) :: Either Symbol [Path] whereCompute path to a constructor in a sum or a field in a product with a specific name.
Equations
GetNamePath name (M1 D _1 g) acc = GetNamePath name g accGetNamePath name (M1 C ('MetaCons name _1 _2) _3) acc = 'Right (Reverse acc '[])GetNamePath name (g1 :+: g2) acc = FirstRight (GetNamePath name g1 ('PathLeft ': acc)) (GetNamePath name g2 ('PathRight ': acc))GetNamePath name (M1 S ('MetaSel ('Just name) _1 _2 _3) _4) acc = 'Right (Reverse acc '[])GetNamePath name (g1 :*: g2) acc = FirstRight (GetNamePath name g1 ('PathLeft ': acc)) (GetNamePath name g2 ('PathRight ': acc))GetNamePath name _1 _2 = 'Left name
Positions
family
type family GetPositionPaths (s :: t) (pos :: Nat) (g :: k -> Type) :: PathTree (Nat, Nat) whereCompute paths to a field at a specific position.
Equations
GetPositionPaths s pos (M1 D _1 g) = GetPositionPaths s pos gGetPositionPaths s pos (g1 :+: g2) = 'PathNode (GetPositionPaths s pos g1) (GetPositionPaths s pos g2)GetPositionPaths s pos (M1 C _1 g) = 'PathLeaf (GetPositionPath pos g0
'[])GetPositionPaths s pos V1 = TypeError (('Text"Type "
':<>: QuoteType s) ':<>: 'Text" has no data constructors"
)
family
type family GetPositionPath (pos :: Nat) (g :: k -> Type) (k1 :: Nat) (acc :: [Path]) :: Either (Nat, Nat) [Path] whereCompute path to a constructor in a sum or a field in a product at a specific position.
Equations
GetPositionPath pos (M1 D _1 g) k2 acc = GetPositionPath pos g k2 accGetPositionPath pos (M1 C _1 _2) k2 acc = If (pos == (k2 +1
)) ('Right (Reverse acc '[])) ('Left '(pos, k2 +1
))GetPositionPath pos (g1 :+: g2) k2 acc = ContinueWhenLeft (GetPositionPath pos g1 k2 ('PathLeft ': acc)) g2 accGetPositionPath pos (M1 S _1 _2) k2 acc = If (pos == (k2 +1
)) ('Right (Reverse acc '[])) ('Left '(pos, k2 +1
))GetPositionPath pos (g1 :*: g2) k2 acc = ContinueWhenLeft (GetPositionPath pos g1 k2 ('PathLeft ': acc)) g2 accGetPositionPath pos _1 k2 _2 = 'Left '(pos, k2)
Misc
3 declarationsCheck if any leaf in the tree has a '[Path]'.
Equations
AnyHasPath ('PathNode path1 path2) = AnyHasPath path1 || AnyHasPath path2AnyHasPath ('PathLeaf ('Right _1)) = 'TrueAnyHasPath ('PathLeaf ('Left _1)) = 'False