{-# LANGUAGE PackageImports #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Data.Generics.Product.Typed
(
HasType (..)
) where
import Optics.Core
import Optics.Internal.Optic
import "this" Data.Generics.Internal.Optics
import qualified "generic-lens-core" Data.Generics.Product.Internal.Typed as Core
import "generic-lens-core" Data.Generics.Internal.Void
class HasType a s where
typed :: Lens s s a a
typed
= (s -> a) -> (s -> a -> s) -> Lens s s a a
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (forall s. HasType a s => s -> a
forall a s. HasType a s => s -> a
getTyped @a) ((a -> s -> s) -> s -> a -> s
forall a b c. (a -> b -> c) -> b -> a -> c
flip (forall s. HasType a s => a -> s -> s
forall a s. HasType a s => a -> s -> s
setTyped @a))
{-# INLINE typed #-}
getTyped :: s -> a
getTyped s
s = s
s s -> Lens s s a a -> a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall s. HasType a s => Lens s s a a
forall a s. HasType a s => Lens s s a a
typed @a
setTyped :: a -> s -> s
setTyped = Lens s s a a -> a -> s -> s
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
set (forall s. HasType a s => Lens s s a a
forall a s. HasType a s => Lens s s a a
typed @a)
{-# MINIMAL typed | setTyped, getTyped #-}
instance Core.Context a s => HasType a s where
typed :: Lens s s a a
typed = Lens s s a a -> Lens s s a a
forall s t a b. Lens s t a b -> Lens s t a b
normaliseLens ((forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ A_Lens p i (Curry NoIx i) s s a a)
-> Lens s s a a
forall k (is :: IxList) s t a b.
(forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t a b)
-> Optic k is s t a b
Optic forall a s. Context a s => Lens s s a a
forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ A_Lens p i (Curry NoIx i) s s a a
Core.derived)
{-# INLINE typed #-}
instance {-# OVERLAPPING #-} HasType a a where
getTyped :: a -> a
getTyped = a -> a
forall a. a -> a
id
{-# INLINE getTyped #-}
setTyped :: a -> a -> a
setTyped a
a a
_ = a
a
{-# INLINE setTyped #-}
instance {-# OVERLAPPING #-} HasType a Void where
typed :: Lens Void Void a a
typed = Lens Void Void a a
forall a. HasCallStack => a
undefined