{-# language AllowAmbiguousTypes    #-}
{-# language DataKinds              #-}
{-# language FlexibleInstances      #-}
{-# language FunctionalDependencies #-}
{-# language GADTs                  #-}
{-# language LambdaCase             #-}
{-# language PolyKinds              #-}
{-# language ScopedTypeVariables    #-}
{-# language TypeApplications       #-}
{-# language TypeOperators          #-}
{-# language UndecidableInstances   #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-|
Description : Optics-based interface for @mu-schema@ terms

This module provides instances of 'LabelOptic' to be
used in conjunction with the @optics@ package.
In particular, there are two kind of optics to access
different parts of a 'Term':

* With @#field@ you obtain the lens (that is, a getter
  and a setter) for the corresponding field in a record.
* With @#choice@ you obtain the prism for the
  desired choice in an enumeration. You can use then
  'review' to construct a term with the value.

In addition, we provide a utility function 'record' to
build a record out of the inner values. We intend the
interface to be very simple, so this function is overloaded
to take tuples of different size, with as many components
as values in the schema type.
-}
module Mu.Schema.Optics (
  -- * Build a term
  record, record1, enum
, _U0, _Next, _U1, _U2, _U3
  -- * Re-exported for convenience.
, module Optics.Core
) where

import           Data.Functor.Identity
import           Data.Kind
import           Data.Map
import           Data.Proxy
import           GHC.TypeLits
import           Optics.Core

import           Mu.Schema

instance {-# OVERLAPS #-}
         (FieldLabel Identity sch args fieldName r)
         => LabelOptic fieldName A_Lens
                       (Term Identity sch ('DRecord name args))
                       (Term Identity sch ('DRecord name args))
                       r r where
  labelOptic :: Optic
  A_Lens
  NoIx
  (Term Identity sch ('DRecord name args))
  (Term Identity sch ('DRecord name args))
  r
  r
labelOptic = (Term Identity sch ('DRecord name args) -> r)
-> (Term Identity sch ('DRecord name args)
    -> r -> Term Identity sch ('DRecord name args))
-> Optic
     A_Lens
     NoIx
     (Term Identity sch ('DRecord name args))
     (Term Identity sch ('DRecord name args))
     r
     r
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (\(TRecord r :: NP (Field Identity sch) args
r) -> Identity r -> r
forall a. Identity a -> a
runIdentity (Identity r -> r) -> Identity r -> r
forall a b. (a -> b) -> a -> b
$ Proxy fieldName -> NP (Field Identity sch) args -> Identity r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) (fieldName :: Symbol) r.
FieldLabel w sch args fieldName r =>
Proxy fieldName -> NP (Field w sch) args -> w r
fieldLensGet (Proxy fieldName
forall k (t :: k). Proxy t
Proxy @fieldName) NP (Field Identity sch) args
NP (Field Identity sch) args
r)
                    (\(TRecord r :: NP (Field Identity sch) args
r) x :: r
x -> NP (Field Identity sch) args
-> Term Identity sch ('DRecord name args)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName)
       (args :: [FieldDef typeName fieldName]) (name :: typeName).
NP (Field w sch) args -> Term w sch ('DRecord name args)
TRecord (NP (Field Identity sch) args
 -> Term Identity sch ('DRecord name args))
-> NP (Field Identity sch) args
-> Term Identity sch ('DRecord name args)
forall a b. (a -> b) -> a -> b
$ Proxy fieldName
-> NP (Field Identity sch) args
-> Identity r
-> NP (Field Identity sch) args
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) (fieldName :: Symbol) r.
FieldLabel w sch args fieldName r =>
Proxy fieldName
-> NP (Field w sch) args -> w r -> NP (Field w sch) args
fieldLensSet (Proxy fieldName
forall k (t :: k). Proxy t
Proxy @fieldName) NP (Field Identity sch) args
NP (Field Identity sch) args
r (r -> Identity r
forall a. a -> Identity a
Identity r
x))

instance {-# OVERLAPPABLE #-}
         (FieldLabel w sch args fieldName r, t ~ w r)
         => LabelOptic fieldName A_Lens
                       (Term w sch ('DRecord name args))
                       (Term w sch ('DRecord name args))
                       t t where
  labelOptic :: Optic
  A_Lens
  NoIx
  (Term w sch ('DRecord name args))
  (Term w sch ('DRecord name args))
  t
  t
labelOptic = (Term w sch ('DRecord name args) -> t)
-> (Term w sch ('DRecord name args)
    -> t -> Term w sch ('DRecord name args))
-> Optic
     A_Lens
     NoIx
     (Term w sch ('DRecord name args))
     (Term w sch ('DRecord name args))
     t
     t
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (\(TRecord r :: NP (Field w sch) args
r) -> Proxy fieldName -> NP (Field w sch) args -> w r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) (fieldName :: Symbol) r.
FieldLabel w sch args fieldName r =>
Proxy fieldName -> NP (Field w sch) args -> w r
fieldLensGet (Proxy fieldName
forall k (t :: k). Proxy t
Proxy @fieldName) NP (Field w sch) args
NP (Field w sch) args
r)
                    (\(TRecord r :: NP (Field w sch) args
r) x :: t
x -> NP (Field w sch) args -> Term w sch ('DRecord name args)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName)
       (args :: [FieldDef typeName fieldName]) (name :: typeName).
NP (Field w sch) args -> Term w sch ('DRecord name args)
TRecord (NP (Field w sch) args -> Term w sch ('DRecord name args))
-> NP (Field w sch) args -> Term w sch ('DRecord name args)
forall a b. (a -> b) -> a -> b
$ Proxy fieldName
-> NP (Field w sch) args -> w r -> NP (Field w sch) args
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) (fieldName :: Symbol) r.
FieldLabel w sch args fieldName r =>
Proxy fieldName
-> NP (Field w sch) args -> w r -> NP (Field w sch) args
fieldLensSet (Proxy fieldName
forall k (t :: k). Proxy t
Proxy @fieldName) NP (Field w sch) args
NP (Field w sch) args
r t
w r
x)

record :: BuildRecord w sch args r => r -> Term w sch ('DRecord name args)
record :: r -> Term w sch ('DRecord name args)
record values :: r
values = NP (Field w sch) args -> Term w sch ('DRecord name args)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName)
       (args :: [FieldDef typeName fieldName]) (name :: typeName).
NP (Field w sch) args -> Term w sch ('DRecord name args)
TRecord (NP (Field w sch) args -> Term w sch ('DRecord name args))
-> NP (Field w sch) args -> Term w sch ('DRecord name args)
forall a b. (a -> b) -> a -> b
$ r -> NP (Field w sch) args
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) r.
BuildRecord w sch args r =>
r -> NP (Field w sch) args
buildR r
values

record1 :: BuildRecord1 w sch arg r => r -> Term w sch ('DRecord name '[arg])
record1 :: r -> Term w sch ('DRecord name '[arg])
record1 value :: r
value = NP (Field w sch) '[arg] -> Term w sch ('DRecord name '[arg])
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName)
       (args :: [FieldDef typeName fieldName]) (name :: typeName).
NP (Field w sch) args -> Term w sch ('DRecord name args)
TRecord (NP (Field w sch) '[arg] -> Term w sch ('DRecord name '[arg]))
-> NP (Field w sch) '[arg] -> Term w sch ('DRecord name '[arg])
forall a b. (a -> b) -> a -> b
$ r -> NP (Field w sch) '[arg]
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (arg :: FieldDef Symbol Symbol) r.
BuildRecord1 w sch arg r =>
r -> NP (Field w sch) '[arg]
buildR1 r
value

class BuildRecord1 (w :: Type -> Type)
                   (sch :: Schema Symbol Symbol)
                   (arg :: FieldDef Symbol Symbol)
                   (r :: Type) | w sch arg -> r where
  buildR1 :: r -> NP (Field w sch) '[arg]

instance {-# OVERLAPPABLE #-} (Functor w, TypeLabel w sch t1 r1)
         => BuildRecord1 w sch ('FieldDef x1 t1) (w r1) where
  buildR1 :: w r1 -> NP (Field w sch) '[ 'FieldDef x1 t1]
buildR1 v :: w r1
v = w (FieldValue w sch t1) -> Field w sch ('FieldDef x1 t1)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r1 -> FieldValue w sch t1
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r1 -> FieldValue w sch t1) -> w r1 -> w (FieldValue w sch t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r1
v) Field w sch ('FieldDef x1 t1)
-> NP (Field w sch) '[] -> NP (Field w sch) '[ 'FieldDef x1 t1]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field w sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

instance {-# OVERLAPS #-} (TypeLabel Identity sch t1 r1)
         => BuildRecord1 Identity sch ('FieldDef x1 t1) r1 where
  buildR1 :: r1 -> NP (Field Identity sch) '[ 'FieldDef x1 t1]
buildR1 v :: r1
v = Identity (FieldValue Identity sch t1)
-> Field Identity sch ('FieldDef x1 t1)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r1 -> FieldValue Identity sch t1
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r1 -> FieldValue Identity sch t1)
-> Identity r1 -> Identity (FieldValue Identity sch t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r1 -> Identity r1
forall a. a -> Identity a
Identity r1
v) Field Identity sch ('FieldDef x1 t1)
-> NP (Field Identity sch) '[]
-> NP (Field Identity sch) '[ 'FieldDef x1 t1]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field Identity sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

class BuildRecord (w :: Type -> Type)
                  (sch :: Schema Symbol Symbol)
                  (args :: [FieldDef Symbol Symbol])
                  (r :: Type) | w sch args -> r where
  buildR :: r -> NP (Field w sch) args

instance BuildRecord w sch '[] () where
  buildR :: () -> NP (Field w sch) '[]
buildR _ = NP (Field w sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

instance {-# OVERLAPPABLE #-} (Functor w, TypeLabel w sch t1 r1, TypeLabel w sch t2 r2)
         => BuildRecord w sch '[ 'FieldDef x1 t1, 'FieldDef x2 t2 ] (w r1, w r2) where
  buildR :: (w r1, w r2)
-> NP (Field w sch) '[ 'FieldDef x1 t1, 'FieldDef x2 t2]
buildR (v1 :: w r1
v1, v2 :: w r2
v2) = w (FieldValue w sch t1) -> Field w sch ('FieldDef x1 t1)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r1 -> FieldValue w sch t1
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r1 -> FieldValue w sch t1) -> w r1 -> w (FieldValue w sch t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r1
v1)
                  Field w sch ('FieldDef x1 t1)
-> NP (Field w sch) '[ 'FieldDef x2 t2]
-> NP (Field w sch) '[ 'FieldDef x1 t1, 'FieldDef x2 t2]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* w (FieldValue w sch t2) -> Field w sch ('FieldDef x2 t2)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r2 -> FieldValue w sch t2
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r2 -> FieldValue w sch t2) -> w r2 -> w (FieldValue w sch t2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r2
v2) Field w sch ('FieldDef x2 t2)
-> NP (Field w sch) '[] -> NP (Field w sch) '[ 'FieldDef x2 t2]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field w sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

instance {-# OVERLAPS #-} (TypeLabel Identity sch t1 r1, TypeLabel Identity sch t2 r2)
         => BuildRecord Identity sch '[ 'FieldDef x1 t1, 'FieldDef x2 t2 ] (r1, r2) where
  buildR :: (r1, r2)
-> NP (Field Identity sch) '[ 'FieldDef x1 t1, 'FieldDef x2 t2]
buildR (v1 :: r1
v1, v2 :: r2
v2) = Identity (FieldValue Identity sch t1)
-> Field Identity sch ('FieldDef x1 t1)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r1 -> FieldValue Identity sch t1
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r1 -> FieldValue Identity sch t1)
-> Identity r1 -> Identity (FieldValue Identity sch t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r1 -> Identity r1
forall a. a -> Identity a
Identity r1
v1)
                  Field Identity sch ('FieldDef x1 t1)
-> NP (Field Identity sch) '[ 'FieldDef x2 t2]
-> NP (Field Identity sch) '[ 'FieldDef x1 t1, 'FieldDef x2 t2]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* Identity (FieldValue Identity sch t2)
-> Field Identity sch ('FieldDef x2 t2)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r2 -> FieldValue Identity sch t2
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r2 -> FieldValue Identity sch t2)
-> Identity r2 -> Identity (FieldValue Identity sch t2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r2 -> Identity r2
forall a. a -> Identity a
Identity r2
v2) Field Identity sch ('FieldDef x2 t2)
-> NP (Field Identity sch) '[]
-> NP (Field Identity sch) '[ 'FieldDef x2 t2]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field Identity sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

instance {-# OVERLAPPABLE #-} (Functor w, TypeLabel w sch t1 r1, TypeLabel w sch t2 r2, TypeLabel w sch t3 r3)
         => BuildRecord w sch
                        '[ 'FieldDef x1 t1, 'FieldDef x2 t2, 'FieldDef x3 t3 ]
                        (w r1, w r2, w r3) where
  buildR :: (w r1, w r2, w r3)
-> NP
     (Field w sch) '[ 'FieldDef x1 t1, 'FieldDef x2 t2, 'FieldDef x3 t3]
buildR (v1 :: w r1
v1, v2 :: w r2
v2, v3 :: w r3
v3) = w (FieldValue w sch t1) -> Field w sch ('FieldDef x1 t1)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r1 -> FieldValue w sch t1
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r1 -> FieldValue w sch t1) -> w r1 -> w (FieldValue w sch t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r1
v1)
                      Field w sch ('FieldDef x1 t1)
-> NP (Field w sch) '[ 'FieldDef x2 t2, 'FieldDef x3 t3]
-> NP
     (Field w sch) '[ 'FieldDef x1 t1, 'FieldDef x2 t2, 'FieldDef x3 t3]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* w (FieldValue w sch t2) -> Field w sch ('FieldDef x2 t2)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r2 -> FieldValue w sch t2
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r2 -> FieldValue w sch t2) -> w r2 -> w (FieldValue w sch t2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r2
v2)
                      Field w sch ('FieldDef x2 t2)
-> NP (Field w sch) '[ 'FieldDef x3 t3]
-> NP (Field w sch) '[ 'FieldDef x2 t2, 'FieldDef x3 t3]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* w (FieldValue w sch t3) -> Field w sch ('FieldDef x3 t3)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r3 -> FieldValue w sch t3
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r3 -> FieldValue w sch t3) -> w r3 -> w (FieldValue w sch t3)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r3
v3) Field w sch ('FieldDef x3 t3)
-> NP (Field w sch) '[] -> NP (Field w sch) '[ 'FieldDef x3 t3]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field w sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

instance {-# OVERLAPS #-} (TypeLabel Identity sch t1 r1, TypeLabel Identity sch t2 r2, TypeLabel Identity sch t3 r3)
         => BuildRecord Identity sch
                        '[ 'FieldDef x1 t1, 'FieldDef x2 t2, 'FieldDef x3 t3 ] (r1, r2, r3) where
  buildR :: (r1, r2, r3)
-> NP
     (Field Identity sch)
     '[ 'FieldDef x1 t1, 'FieldDef x2 t2, 'FieldDef x3 t3]
buildR (v1 :: r1
v1, v2 :: r2
v2, v3 :: r3
v3) = Identity (FieldValue Identity sch t1)
-> Field Identity sch ('FieldDef x1 t1)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r1 -> FieldValue Identity sch t1
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r1 -> FieldValue Identity sch t1)
-> Identity r1 -> Identity (FieldValue Identity sch t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r1 -> Identity r1
forall a. a -> Identity a
Identity r1
v1)
                      Field Identity sch ('FieldDef x1 t1)
-> NP (Field Identity sch) '[ 'FieldDef x2 t2, 'FieldDef x3 t3]
-> NP
     (Field Identity sch)
     '[ 'FieldDef x1 t1, 'FieldDef x2 t2, 'FieldDef x3 t3]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* Identity (FieldValue Identity sch t2)
-> Field Identity sch ('FieldDef x2 t2)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r2 -> FieldValue Identity sch t2
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r2 -> FieldValue Identity sch t2)
-> Identity r2 -> Identity (FieldValue Identity sch t2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r2 -> Identity r2
forall a. a -> Identity a
Identity r2
v2)
                      Field Identity sch ('FieldDef x2 t2)
-> NP (Field Identity sch) '[ 'FieldDef x3 t3]
-> NP (Field Identity sch) '[ 'FieldDef x2 t2, 'FieldDef x3 t3]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* Identity (FieldValue Identity sch t3)
-> Field Identity sch ('FieldDef x3 t3)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r3 -> FieldValue Identity sch t3
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r3 -> FieldValue Identity sch t3)
-> Identity r3 -> Identity (FieldValue Identity sch t3)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r3 -> Identity r3
forall a. a -> Identity a
Identity r3
v3) Field Identity sch ('FieldDef x3 t3)
-> NP (Field Identity sch) '[]
-> NP (Field Identity sch) '[ 'FieldDef x3 t3]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field Identity sch) '[]
forall k (a :: k -> *). NP a '[]
Nil

class FieldLabel (w :: Type -> Type)
                 (sch :: Schema Symbol Symbol)
                 (args :: [FieldDef Symbol Symbol])
                 (fieldName :: Symbol) (r :: Type)
                 | w sch args fieldName -> r where
  fieldLensGet :: Proxy fieldName -> NP (Field w sch) args -> w r
  fieldLensSet :: Proxy fieldName -> NP (Field w sch) args -> w r -> NP (Field w sch) args

{- Removed due to FunDeps
instance TypeError ('Text "cannot find field " ':<>: 'ShowType f)
         => FieldLabel w sch '[] f t where
  fieldLensGet = error "this should never be run"
  fieldLensSet = error "this should never be run"
-}
instance {-# OVERLAPS #-} (Functor w, TypeLabel w sch t r)
         => FieldLabel w sch ('FieldDef f t ': rest) f r where
  fieldLensGet :: Proxy f -> NP (Field w sch) ('FieldDef f t : rest) -> w r
fieldLensGet _ (Field x :: w (FieldValue w sch t)
x :* _) = FieldValue w sch t -> r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
FieldValue w sch t -> r
typeLensGet (FieldValue w sch t -> r) -> w (FieldValue w sch t) -> w r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w (FieldValue w sch t)
x
  fieldLensSet :: Proxy f
-> NP (Field w sch) ('FieldDef f t : rest)
-> w r
-> NP (Field w sch) ('FieldDef f t : rest)
fieldLensSet _ (_ :* r :: NP (Field w sch) xs
r) new :: w r
new = w (FieldValue w sch t) -> Field w sch ('FieldDef f t)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t :: FieldType typeName)
       (name :: fieldName).
w (FieldValue w sch t) -> Field w sch ('FieldDef name t)
Field (r -> FieldValue w sch t
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r -> FieldValue w sch t) -> w r -> w (FieldValue w sch t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> w r
new) Field w sch ('FieldDef f t)
-> NP (Field w sch) xs -> NP (Field w sch) ('FieldDef f t : xs)
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (Field w sch) xs
r
instance {-# OVERLAPPABLE #-} FieldLabel w sch rest g t
         => FieldLabel w sch (f ': rest) g t where
  fieldLensGet :: Proxy g -> NP (Field w sch) (f : rest) -> w t
fieldLensGet p :: Proxy g
p (_ :* r :: NP (Field w sch) xs
r) = Proxy g -> NP (Field w sch) xs -> w t
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) (fieldName :: Symbol) r.
FieldLabel w sch args fieldName r =>
Proxy fieldName -> NP (Field w sch) args -> w r
fieldLensGet Proxy g
p NP (Field w sch) xs
r
  fieldLensSet :: Proxy g
-> NP (Field w sch) (f : rest)
-> w t
-> NP (Field w sch) (f : rest)
fieldLensSet p :: Proxy g
p (x :: Field w sch x
x :* r :: NP (Field w sch) xs
r) new :: w t
new = Field w sch x
x Field w sch x -> NP (Field w sch) xs -> NP (Field w sch) (x : xs)
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* Proxy g -> NP (Field w sch) xs -> w t -> NP (Field w sch) xs
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (args :: [FieldDef Symbol Symbol]) (fieldName :: Symbol) r.
FieldLabel w sch args fieldName r =>
Proxy fieldName
-> NP (Field w sch) args -> w r -> NP (Field w sch) args
fieldLensSet Proxy g
p NP (Field w sch) xs
r w t
new

class TypeLabel w (sch :: Schema Symbol Symbol) (t :: FieldType Symbol) (r :: Type)
      | w sch t -> r where
  typeLensGet :: FieldValue w sch t -> r
  typeLensSet :: r -> FieldValue w sch t

instance TypeLabel w sch ('TPrimitive t) t where
  typeLensGet :: FieldValue w sch ('TPrimitive t) -> t
typeLensGet (FPrimitive x :: t1
x) = t
t1
x
  typeLensSet :: t -> FieldValue w sch ('TPrimitive t)
typeLensSet = t -> FieldValue w sch ('TPrimitive t)
forall typeName fieldName t1 (w :: * -> *)
       (sch :: Schema typeName fieldName).
t1 -> FieldValue w sch ('TPrimitive t1)
FPrimitive

instance (r ~ (sch :/: t)) => TypeLabel w sch ('TSchematic t) (Term w sch r) where
  typeLensGet :: FieldValue w sch ('TSchematic t) -> Term w sch r
typeLensGet (FSchematic x :: Term w sch (sch :/: t1)
x) = Term w sch r
Term w sch (sch :/: t1)
x
  typeLensSet :: Term w sch r -> FieldValue w sch ('TSchematic t)
typeLensSet = Term w sch r -> FieldValue w sch ('TSchematic t)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t1 :: typeName).
Term w sch (sch :/: t1) -> FieldValue w sch ('TSchematic t1)
FSchematic

instance (TypeLabel w sch o r', r ~ Maybe r')
         => TypeLabel w sch ('TOption o) r where
  typeLensGet :: FieldValue w sch ('TOption o) -> r
typeLensGet (FOption x :: Maybe (FieldValue w sch t1)
x) = FieldValue w sch t1 -> r'
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
FieldValue w sch t -> r
typeLensGet (FieldValue w sch t1 -> r')
-> Maybe (FieldValue w sch t1) -> Maybe r'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (FieldValue w sch t1)
x
  typeLensSet :: r -> FieldValue w sch ('TOption o)
typeLensSet new :: r
new = Maybe (FieldValue w sch o) -> FieldValue w sch ('TOption o)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t1 :: FieldType typeName).
Maybe (FieldValue w sch t1) -> FieldValue w sch ('TOption t1)
FOption (r' -> FieldValue w sch o
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r' -> FieldValue w sch o)
-> Maybe r' -> Maybe (FieldValue w sch o)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r
Maybe r'
new)

instance (TypeLabel w sch o r', r ~ [r'])
         => TypeLabel w sch ('TList o) r where
  typeLensGet :: FieldValue w sch ('TList o) -> r
typeLensGet (FList x :: [FieldValue w sch t1]
x) = FieldValue w sch t1 -> r'
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
FieldValue w sch t -> r
typeLensGet (FieldValue w sch t1 -> r') -> [FieldValue w sch t1] -> [r']
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [FieldValue w sch t1]
x
  typeLensSet :: r -> FieldValue w sch ('TList o)
typeLensSet new :: r
new = [FieldValue w sch o] -> FieldValue w sch ('TList o)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (t1 :: FieldType typeName).
[FieldValue w sch t1] -> FieldValue w sch ('TList t1)
FList (r' -> FieldValue w sch o
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (r' -> FieldValue w sch o) -> [r'] -> [FieldValue w sch o]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r
[r']
new)

instance ( TypeLabel w sch k k', TypeLabel w sch v v'
         , r ~ Map k' v', Ord k', Ord (FieldValue w sch k) )
         => TypeLabel w sch ('TMap k v) r where
  typeLensGet :: FieldValue w sch ('TMap k v) -> r
typeLensGet (FMap x :: Map (FieldValue w sch k) (FieldValue w sch v)
x) = (FieldValue w sch k -> k')
-> Map (FieldValue w sch k) v' -> Map k' v'
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
mapKeys FieldValue w sch k -> k'
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
FieldValue w sch t -> r
typeLensGet (FieldValue w sch v -> v'
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
FieldValue w sch t -> r
typeLensGet (FieldValue w sch v -> v')
-> Map (FieldValue w sch k) (FieldValue w sch v)
-> Map (FieldValue w sch k) v'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map (FieldValue w sch k) (FieldValue w sch v)
x)
  typeLensSet :: r -> FieldValue w sch ('TMap k v)
typeLensSet new :: r
new = Map (FieldValue w sch k) (FieldValue w sch v)
-> FieldValue w sch ('TMap k v)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName) (k :: FieldType typeName)
       (v :: FieldType typeName).
Ord (FieldValue w sch k) =>
Map (FieldValue w sch k) (FieldValue w sch v)
-> FieldValue w sch ('TMap k v)
FMap ((k' -> FieldValue w sch k)
-> Map k' (FieldValue w sch v)
-> Map (FieldValue w sch k) (FieldValue w sch v)
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
mapKeys k' -> FieldValue w sch k
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (v' -> FieldValue w sch v
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet (v' -> FieldValue w sch v)
-> Map k' v' -> Map k' (FieldValue w sch v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r
Map k' v'
new))

instance (r ~ NS (FieldValue w sch) choices)
         => TypeLabel w sch ('TUnion choices) r where
  typeLensGet :: FieldValue w sch ('TUnion choices) -> r
typeLensGet (FUnion x :: NS (FieldValue w sch) choices
x) = r
NS (FieldValue w sch) choices
x
  typeLensSet :: r -> FieldValue w sch ('TUnion choices)
typeLensSet = r -> FieldValue w sch ('TUnion choices)
forall typeName fieldName (w :: * -> *)
       (sch :: Schema typeName fieldName)
       (choices :: [FieldType typeName]).
NS (FieldValue w sch) choices -> FieldValue w sch ('TUnion choices)
FUnion

enum :: forall (choiceName :: Symbol) choices w sch name.
        EnumLabel choices choiceName
     => Term w sch ('DEnum name choices)
enum :: Term w sch ('DEnum name choices)
enum = NS Proxy choices -> Term w sch ('DEnum name choices)
forall fieldName typeName (choices :: [ChoiceDef fieldName])
       (w :: * -> *) (sch :: Schema typeName fieldName)
       (name :: typeName).
NS Proxy choices -> Term w sch ('DEnum name choices)
TEnum (NS Proxy choices -> Term w sch ('DEnum name choices))
-> NS Proxy choices -> Term w sch ('DEnum name choices)
forall a b. (a -> b) -> a -> b
$ Proxy choiceName -> NS Proxy choices
forall (choices :: [ChoiceDef Symbol]) (choiceName :: Symbol).
EnumLabel choices choiceName =>
Proxy choiceName -> NS Proxy choices
enumPrismBuild (Proxy choiceName
forall k (t :: k). Proxy t
Proxy @choiceName)

instance (EnumLabel choices choiceName, r ~ ())
         => LabelOptic choiceName A_Prism
                       (Term w sch ('DEnum name choices))
                       (Term w sch ('DEnum name choices))
                       r r where
  labelOptic :: Optic
  A_Prism
  NoIx
  (Term w sch ('DEnum name choices))
  (Term w sch ('DEnum name choices))
  r
  r
labelOptic = (r -> Term w sch ('DEnum name choices))
-> (Term w sch ('DEnum name choices) -> Maybe r)
-> Optic
     A_Prism
     NoIx
     (Term w sch ('DEnum name choices))
     (Term w sch ('DEnum name choices))
     r
     r
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (\_ -> NS Proxy choices -> Term w sch ('DEnum name choices)
forall fieldName typeName (choices :: [ChoiceDef fieldName])
       (w :: * -> *) (sch :: Schema typeName fieldName)
       (name :: typeName).
NS Proxy choices -> Term w sch ('DEnum name choices)
TEnum (NS Proxy choices -> Term w sch ('DEnum name choices))
-> NS Proxy choices -> Term w sch ('DEnum name choices)
forall a b. (a -> b) -> a -> b
$ Proxy choiceName -> NS Proxy choices
forall (choices :: [ChoiceDef Symbol]) (choiceName :: Symbol).
EnumLabel choices choiceName =>
Proxy choiceName -> NS Proxy choices
enumPrismBuild (Proxy choiceName
forall k (t :: k). Proxy t
Proxy @choiceName))
                     (\(TEnum r :: NS Proxy choices
r) -> Proxy choiceName -> NS Proxy choices -> Maybe ()
forall (choices :: [ChoiceDef Symbol]) (choiceName :: Symbol).
EnumLabel choices choiceName =>
Proxy choiceName -> NS Proxy choices -> Maybe ()
enumPrismMatch (Proxy choiceName
forall k (t :: k). Proxy t
Proxy @choiceName) NS Proxy choices
r)

class EnumLabel (choices :: [ChoiceDef Symbol])
                (choiceName :: Symbol) where
  enumPrismBuild :: Proxy choiceName -> NS Proxy choices
  enumPrismMatch :: Proxy choiceName -> NS Proxy choices -> Maybe ()

instance TypeError ('Text "cannot find choice " ':<>: 'ShowType c)
         => EnumLabel '[] c where
  enumPrismBuild :: Proxy c -> NS Proxy '[]
enumPrismBuild = [Char] -> Proxy c -> NS Proxy '[]
forall a. HasCallStack => [Char] -> a
error "this should never be run"
  enumPrismMatch :: Proxy c -> NS Proxy '[] -> Maybe ()
enumPrismMatch = [Char] -> Proxy c -> NS Proxy '[] -> Maybe ()
forall a. HasCallStack => [Char] -> a
error "this should never be run"
instance {-# OVERLAPS #-} EnumLabel ('ChoiceDef c ': rest) c where
  enumPrismBuild :: Proxy c -> NS Proxy ('ChoiceDef c : rest)
enumPrismBuild _ = Proxy ('ChoiceDef c) -> NS Proxy ('ChoiceDef c : rest)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z Proxy ('ChoiceDef c)
forall k (t :: k). Proxy t
Proxy
  enumPrismMatch :: Proxy c -> NS Proxy ('ChoiceDef c : rest) -> Maybe ()
enumPrismMatch _ (Z _) = () -> Maybe ()
forall a. a -> Maybe a
Just ()
  enumPrismMatch _ _     = Maybe ()
forall a. Maybe a
Nothing
instance {-# OVERLAPPABLE #-} EnumLabel rest c
         => EnumLabel (d ': rest) c where
  enumPrismBuild :: Proxy c -> NS Proxy (d : rest)
enumPrismBuild p :: Proxy c
p = NS Proxy rest -> NS Proxy (d : rest)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (Proxy c -> NS Proxy rest
forall (choices :: [ChoiceDef Symbol]) (choiceName :: Symbol).
EnumLabel choices choiceName =>
Proxy choiceName -> NS Proxy choices
enumPrismBuild Proxy c
p)
  enumPrismMatch :: Proxy c -> NS Proxy (d : rest) -> Maybe ()
enumPrismMatch _ (Z _) = Maybe ()
forall a. Maybe a
Nothing
  enumPrismMatch p :: Proxy c
p (S x :: NS Proxy xs
x) = Proxy c -> NS Proxy xs -> Maybe ()
forall (choices :: [ChoiceDef Symbol]) (choiceName :: Symbol).
EnumLabel choices choiceName =>
Proxy choiceName -> NS Proxy choices -> Maybe ()
enumPrismMatch Proxy c
p NS Proxy xs
x

_U0 :: forall w (sch :: Schema') x xs r. TypeLabel w sch x r
    => Prism' (NS (FieldValue w sch) (x ': xs)) r
_U0 :: Prism' (NS (FieldValue w sch) (x : xs)) r
_U0 = (r -> NS (FieldValue w sch) (x : xs))
-> (NS (FieldValue w sch) (x : xs) -> Maybe r)
-> Prism' (NS (FieldValue w sch) (x : xs)) r
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (FieldValue w sch x -> NS (FieldValue w sch) (x : xs)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (FieldValue w sch x -> NS (FieldValue w sch) (x : xs))
-> (r -> FieldValue w sch x) -> r -> NS (FieldValue w sch) (x : xs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> FieldValue w sch x
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
r -> FieldValue w sch t
typeLensSet)
             (\case (Z x :: FieldValue w sch x
x) -> r -> Maybe r
forall a. a -> Maybe a
Just (r -> Maybe r) -> r -> Maybe r
forall a b. (a -> b) -> a -> b
$ FieldValue w sch x -> r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (t :: FieldType Symbol) r.
TypeLabel w sch t r =>
FieldValue w sch t -> r
typeLensGet FieldValue w sch x
x
                    (S _) -> Maybe r
forall a. Maybe a
Nothing)

_Next :: forall w (sch :: Schema') x xs.
         Prism' (NS (FieldValue w sch) (x ': xs))
                (NS (FieldValue w sch) xs)
_Next :: Prism' (NS (FieldValue w sch) (x : xs)) (NS (FieldValue w sch) xs)
_Next = (NS (FieldValue w sch) xs -> NS (FieldValue w sch) (x : xs))
-> (NS (FieldValue w sch) (x : xs)
    -> Maybe (NS (FieldValue w sch) xs))
-> Prism'
     (NS (FieldValue w sch) (x : xs)) (NS (FieldValue w sch) xs)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' NS (FieldValue w sch) xs -> NS (FieldValue w sch) (x : xs)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S
               (\case (Z _) -> Maybe (NS (FieldValue w sch) xs)
forall a. Maybe a
Nothing
                      (S x :: NS (FieldValue w sch) xs
x) -> NS (FieldValue w sch) xs -> Maybe (NS (FieldValue w sch) xs)
forall a. a -> Maybe a
Just NS (FieldValue w sch) xs
x)

_U1 :: forall w (sch :: Schema') a b xs r. TypeLabel w sch b r
    => Prism' (NS (FieldValue w sch) (a ': b ': xs)) r
_U1 :: Prism' (NS (FieldValue w sch) (a : b : xs)) r
_U1 = Prism'
  (NS (FieldValue w sch) (a : b : xs))
  (NS (FieldValue w sch) (b : xs))
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (x :: FieldType Symbol) (xs :: [FieldType Symbol]).
Prism' (NS (FieldValue w sch) (x : xs)) (NS (FieldValue w sch) xs)
_Next Prism'
  (NS (FieldValue w sch) (a : b : xs))
  (NS (FieldValue w sch) (b : xs))
-> Optic
     A_Prism
     NoIx
     (NS (FieldValue w sch) (b : xs))
     (NS (FieldValue w sch) (b : xs))
     r
     r
-> Prism' (NS (FieldValue w sch) (a : b : xs)) r
forall k m l (ks :: IxList) (is :: IxList) (js :: IxList) s t u v a
       b.
(Is k m, Is l m, m ~ Join k l, ks ~ Append is js) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic
  A_Prism
  NoIx
  (NS (FieldValue w sch) (b : xs))
  (NS (FieldValue w sch) (b : xs))
  r
  r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (x :: FieldType Symbol) (xs :: [FieldType Symbol]) r.
TypeLabel w sch x r =>
Prism' (NS (FieldValue w sch) (x : xs)) r
_U0

_U2 :: forall w (sch :: Schema') a b c xs r. TypeLabel w sch c r
    => Prism' (NS (FieldValue w sch) (a ': b ': c ': xs)) r
_U2 :: Prism' (NS (FieldValue w sch) (a : b : c : xs)) r
_U2 = Prism'
  (NS (FieldValue w sch) (a : b : c : xs))
  (NS (FieldValue w sch) (b : c : xs))
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (x :: FieldType Symbol) (xs :: [FieldType Symbol]).
Prism' (NS (FieldValue w sch) (x : xs)) (NS (FieldValue w sch) xs)
_Next Prism'
  (NS (FieldValue w sch) (a : b : c : xs))
  (NS (FieldValue w sch) (b : c : xs))
-> Optic
     A_Prism
     NoIx
     (NS (FieldValue w sch) (b : c : xs))
     (NS (FieldValue w sch) (b : c : xs))
     r
     r
-> Prism' (NS (FieldValue w sch) (a : b : c : xs)) r
forall k m l (ks :: IxList) (is :: IxList) (js :: IxList) s t u v a
       b.
(Is k m, Is l m, m ~ Join k l, ks ~ Append is js) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic
  A_Prism
  NoIx
  (NS (FieldValue w sch) (b : c : xs))
  (NS (FieldValue w sch) (b : c : xs))
  r
  r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (a :: FieldType Symbol) (b :: FieldType Symbol)
       (xs :: [FieldType Symbol]) r.
TypeLabel w sch b r =>
Prism' (NS (FieldValue w sch) (a : b : xs)) r
_U1

_U3 :: forall w (sch :: Schema') a b c d xs r. TypeLabel w sch d r
    => Prism' (NS (FieldValue w sch) (a ': b ': c ': d ': xs)) r
_U3 :: Prism' (NS (FieldValue w sch) (a : b : c : d : xs)) r
_U3 = Prism'
  (NS (FieldValue w sch) (a : b : c : d : xs))
  (NS (FieldValue w sch) (b : c : d : xs))
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (x :: FieldType Symbol) (xs :: [FieldType Symbol]).
Prism' (NS (FieldValue w sch) (x : xs)) (NS (FieldValue w sch) xs)
_Next Prism'
  (NS (FieldValue w sch) (a : b : c : d : xs))
  (NS (FieldValue w sch) (b : c : d : xs))
-> Optic
     A_Prism
     NoIx
     (NS (FieldValue w sch) (b : c : d : xs))
     (NS (FieldValue w sch) (b : c : d : xs))
     r
     r
-> Prism' (NS (FieldValue w sch) (a : b : c : d : xs)) r
forall k m l (ks :: IxList) (is :: IxList) (js :: IxList) s t u v a
       b.
(Is k m, Is l m, m ~ Join k l, ks ~ Append is js) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic
  A_Prism
  NoIx
  (NS (FieldValue w sch) (b : c : d : xs))
  (NS (FieldValue w sch) (b : c : d : xs))
  r
  r
forall (w :: * -> *) (sch :: Schema Symbol Symbol)
       (a :: FieldType Symbol) (b :: FieldType Symbol)
       (c :: FieldType Symbol) (xs :: [FieldType Symbol]) r.
TypeLabel w sch c r =>
Prism' (NS (FieldValue w sch) (a : b : c : xs)) r
_U2