{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Registry.Registry where
import Data.Dynamic
import Data.Registry.Internal.Types
import Data.Registry.Lift
import Data.Registry.Solver
import Data.Semigroup ((<>))
import Data.Type.Equality
import Protolude as P hiding ((<>))
import Type.Reflection
import qualified Prelude (show)
data Registry (inputs :: [Type]) (outputs :: [Type]) = Registry
{ forall (inputs :: [*]) (outputs :: [*]).
Registry inputs outputs -> Entries
_entries :: Entries,
forall (inputs :: [*]) (outputs :: [*]).
Registry inputs outputs -> Specializations
_specializations :: Specializations,
forall (inputs :: [*]) (outputs :: [*]).
Registry inputs outputs -> Modifiers
_modifiers :: Modifiers
}
instance Show (Registry inputs outputs) where
show :: Registry inputs outputs -> String
show (Registry Entries
es ss :: Specializations
ss@(Specializations [Specialization]
ss') ms :: Modifiers
ms@(Modifiers [(SomeTypeRep, ModifierFunction)]
ms')) =
Text -> String
forall a b. ConvertText a b => a -> b
toS (Text -> String) -> ([Text] -> Text) -> [Text] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
unlines ([Text] -> String) -> [Text] -> String
forall a b. (a -> b) -> a -> b
$
[ Text
"Values\n",
Entries -> Text
describeValues Entries
es,
Text
"Constructors\n",
Entries -> Text
describeFunctions Entries
es
]
[Text] -> [Text] -> [Text]
forall a. Semigroup a => a -> a -> a
<> ( if Bool -> Bool
not ([Specialization] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Specialization]
ss')
then
[ Text
"Specializations\n",
Specializations -> Text
describeSpecializations Specializations
ss
]
else []
)
[Text] -> [Text] -> [Text]
forall a. Semigroup a => a -> a -> a
<> ( if Bool -> Bool
not ([(SomeTypeRep, ModifierFunction)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(SomeTypeRep, ModifierFunction)]
ms')
then
[ Text
"Modifiers\n",
Modifiers -> Text
describeModifiers Modifiers
ms
]
else []
)
instance Semigroup (Registry inputs outputs) where
<> :: Registry inputs outputs
-> Registry inputs outputs -> Registry inputs outputs
(<>) (Registry Entries
fs1 Specializations
ss1 Modifiers
ms1) (Registry Entries
fs2 Specializations
ss2 Modifiers
ms2) =
Entries -> Specializations -> Modifiers -> Registry inputs outputs
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry (Entries
fs1 Entries -> Entries -> Entries
forall a. Semigroup a => a -> a -> a
<> Entries
fs2) (Specializations
ss1 Specializations -> Specializations -> Specializations
forall a. Semigroup a => a -> a -> a
<> Specializations
ss2) (Modifiers
ms1 Modifiers -> Modifiers -> Modifiers
forall a. Semigroup a => a -> a -> a
<> Modifiers
ms2)
instance Semigroup (Registry inputs outputs) => Monoid (Registry inputs outputs) where
mempty :: Registry inputs outputs
mempty = Entries -> Specializations -> Modifiers -> Registry inputs outputs
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
forall a. Monoid a => a
mempty Specializations
forall a. Monoid a => a
mempty Modifiers
forall a. Monoid a => a
mempty
mappend :: Registry inputs outputs
-> Registry inputs outputs -> Registry inputs outputs
mappend = Registry inputs outputs
-> Registry inputs outputs -> Registry inputs outputs
forall a. Semigroup a => a -> a -> a
(<>)
infixr 4 <+>
(<+>) :: Registry is1 os1 -> Registry is2 os2 -> Registry (is1 :++ is2) (os1 :++ os2)
<+> :: forall (is1 :: [*]) (os1 :: [*]) (is2 :: [*]) (os2 :: [*]).
Registry is1 os1
-> Registry is2 os2 -> Registry (is1 :++ is2) (os1 :++ os2)
(<+>)(Registry Entries
fs1 Specializations
ss1 Modifiers
ms1) (Registry Entries
fs2 Specializations
ss2 Modifiers
ms2) =
Entries
-> Specializations
-> Modifiers
-> Registry (is1 :++ is2) (os1 :++ os2)
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry (Entries
fs1 Entries -> Entries -> Entries
forall a. Semigroup a => a -> a -> a
<> Entries
fs2) (Specializations
ss1 Specializations -> Specializations -> Specializations
forall a. Semigroup a => a -> a -> a
<> Specializations
ss2) (Modifiers
ms1 Modifiers -> Modifiers -> Modifiers
forall a. Semigroup a => a -> a -> a
<> Modifiers
ms2)
register :: (Typeable a, IsSubset (Inputs a) out a) => Typed a -> Registry ins out -> Registry (Inputs a :++ ins) (Output a ': out)
register :: forall a (out :: [*]) (ins :: [*]).
(Typeable a, IsSubset (Inputs a) out a) =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
register = Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
registerUnchecked
registerUnchecked :: (Typeable a) => Typed a -> Registry ins out -> Registry (Inputs a :++ ins) (Output a ': out)
registerUnchecked :: forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
registerUnchecked Typed a
t (Registry Entries
entries Specializations
specializations Modifiers
modifiers) =
Entries
-> Specializations
-> Modifiers
-> Registry (Inputs a :++ ins) (Output a : out)
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry (Typed a -> Entries -> Entries
forall {k} (a :: k). Typed a -> Entries -> Entries
addEntry Typed a
t Entries
entries) Specializations
specializations Modifiers
modifiers
appendUnchecked :: (Typeable a) => Registry ins out -> Typed a -> Registry (ins :++ Inputs a) (out :++ '[Output a])
appendUnchecked :: forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Registry ins out
-> Typed a -> Registry (ins :++ Inputs a) (out :++ '[Output a])
appendUnchecked (Registry Entries
entries Specializations
specializations Modifiers
modifiers) Typed a
t =
Entries
-> Specializations
-> Modifiers
-> Registry (ins :++ Inputs a) (out :++ '[Output a])
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry (Typed a -> Entries -> Entries
forall {k} (a :: k). Typed a -> Entries -> Entries
appendEntry Typed a
t Entries
entries) Specializations
specializations Modifiers
modifiers
addTypedUnchecked :: (Typeable a, Typeable b, ins ~ (Inputs a :++ Inputs b), out ~ '[Output a, Output b]) => Typed a -> Typed b -> Registry ins out
addTypedUnchecked :: forall a b (ins :: [*]) (out :: [*]).
(Typeable a, Typeable b, ins ~ (Inputs a :++ Inputs b),
out ~ '[Output a, Output b]) =>
Typed a -> Typed b -> Registry ins out
addTypedUnchecked Typed a
t1 Typed b
t2 = Entries -> Specializations -> Modifiers -> Registry ins out
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry ([Untyped] -> Entries
fromUntyped [Typed a -> Untyped
forall {k} (a :: k). Typed a -> Untyped
untype Typed a
t1, Typed b -> Untyped
forall {k} (a :: k). Typed a -> Untyped
untype Typed b
t2]) Specializations
forall a. Monoid a => a
mempty Modifiers
forall a. Monoid a => a
mempty
infixr 5 +:
(+:) :: (Typeable a) => Typed a -> Registry ins out -> Registry (Inputs a :++ ins) (Output a ': out)
+: :: forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
(+:) = Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
registerUnchecked
infixr 5 <:
class AddRegistryLike a b c | a b -> c where
(<:) :: a -> b -> c
instance (insr ~ (ins1 :++ ins2), outr ~ (out1 :++ out2), AreSubset ins1 outr out1) => AddRegistryLike (Registry ins1 out1) (Registry ins2 out2) (Registry insr outr) where
<: :: Registry ins1 out1 -> Registry ins2 out2 -> Registry insr outr
(<:) = Registry ins1 out1 -> Registry ins2 out2 -> Registry insr outr
Registry ins1 out1
-> Registry ins2 out2 -> Registry (ins1 :++ ins2) (out1 :++ out2)
forall (is1 :: [*]) (os1 :: [*]) (is2 :: [*]) (os2 :: [*]).
Registry is1 os1
-> Registry is2 os2 -> Registry (is1 :++ is2) (os1 :++ os2)
(<+>)
instance
(Typeable a, IsSubset (Inputs a) out2 a, insr ~ (Inputs a :++ ins2), outr ~ (Output a : out2)) =>
AddRegistryLike (Typed a) (Registry ins2 out2) (Registry insr outr)
where
<: :: Typed a -> Registry ins2 out2 -> Registry insr outr
(<:) = Typed a -> Registry ins2 out2 -> Registry insr outr
Typed a
-> Registry ins2 out2
-> Registry (Inputs a :++ ins2) (Output a : out2)
forall a (out :: [*]) (ins :: [*]).
(Typeable a, IsSubset (Inputs a) out a) =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
register
instance
(Typeable a, AreSubset ins2 outr out2, insr ~ (ins2 :++ Inputs a), outr ~ (out2 :++ '[Output a])) =>
AddRegistryLike (Registry ins2 out2) (Typed a) (Registry insr outr)
where
<: :: Registry ins2 out2 -> Typed a -> Registry insr outr
(<:) = Registry ins2 out2 -> Typed a -> Registry insr outr
Registry ins2 out2
-> Typed a -> Registry (ins2 :++ Inputs a) (out2 :++ '[Output a])
forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Registry ins out
-> Typed a -> Registry (ins :++ Inputs a) (out :++ '[Output a])
appendUnchecked
instance
(Typeable a, IsSubset (Inputs a) '[Output b] a, Typeable b, insr ~ (Inputs a :++ Inputs b), outr ~ (Output a : '[Output b])) =>
AddRegistryLike (Typed a) (Typed b) (Registry insr outr)
where
<: :: Typed a -> Typed b -> Registry insr outr
(<:) = Typed a -> Typed b -> Registry insr outr
forall a b (ins :: [*]) (out :: [*]).
(Typeable a, Typeable b, ins ~ (Inputs a :++ Inputs b),
out ~ '[Output a, Output b]) =>
Typed a -> Typed b -> Registry ins out
addTypedUnchecked
infixr 5 <+
class AddRegistryUncheckedLike a b c | a b -> c where
(<+) :: a -> b -> c
instance (insr ~ (ins1 :++ ins2), outr ~ (out1 :++ out2)) => AddRegistryUncheckedLike (Registry ins1 out1) (Registry ins2 out2) (Registry insr outr) where
<+ :: Registry ins1 out1 -> Registry ins2 out2 -> Registry insr outr
(<+) = Registry ins1 out1 -> Registry ins2 out2 -> Registry insr outr
Registry ins1 out1
-> Registry ins2 out2 -> Registry (ins1 :++ ins2) (out1 :++ out2)
forall (is1 :: [*]) (os1 :: [*]) (is2 :: [*]) (os2 :: [*]).
Registry is1 os1
-> Registry is2 os2 -> Registry (is1 :++ is2) (os1 :++ os2)
(<+>)
instance
(Typeable a, insr ~ (Inputs a :++ ins2), outr ~ (Output a : out2)) =>
AddRegistryUncheckedLike (Typed a) (Registry ins2 out2) (Registry insr outr)
where
<+ :: Typed a -> Registry ins2 out2 -> Registry insr outr
(<+) = Typed a -> Registry ins2 out2 -> Registry insr outr
Typed a
-> Registry ins2 out2
-> Registry (Inputs a :++ ins2) (Output a : out2)
forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Typed a
-> Registry ins out -> Registry (Inputs a :++ ins) (Output a : out)
registerUnchecked
instance
(Typeable a, insr ~ (ins2 :++ Inputs a), outr ~ (out2 :++ '[Output a])) =>
AddRegistryUncheckedLike (Registry ins2 out2) (Typed a) (Registry insr outr)
where
<+ :: Registry ins2 out2 -> Typed a -> Registry insr outr
(<+) = Registry ins2 out2 -> Typed a -> Registry insr outr
Registry ins2 out2
-> Typed a -> Registry (ins2 :++ Inputs a) (out2 :++ '[Output a])
forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Registry ins out
-> Typed a -> Registry (ins :++ Inputs a) (out :++ '[Output a])
appendUnchecked
instance
(Typeable a, Typeable b, insr ~ (Inputs a :++ Inputs b), outr ~ '[Output a, Output b]) =>
AddRegistryUncheckedLike (Typed a) (Typed b) (Registry insr outr)
where
<+ :: Typed a -> Typed b -> Registry insr outr
(<+) = Typed a -> Typed b -> Registry insr outr
forall a b (ins :: [*]) (out :: [*]).
(Typeable a, Typeable b, ins ~ (Inputs a :++ Inputs b),
out ~ '[Output a, Output b]) =>
Typed a -> Typed b -> Registry ins out
addTypedUnchecked
normalize :: Registry ins out -> Registry (Normalized ins) (Normalized out)
normalize :: forall (ins :: [*]) (out :: [*]).
Registry ins out -> Registry (Normalized ins) (Normalized out)
normalize (Registry Entries
es Specializations
ss Modifiers
ms) = Entries
-> Specializations
-> Modifiers
-> Registry (Normalized ins) (Normalized out)
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
es Specializations
ss Modifiers
ms
eraseTypes :: Registry ins out -> Registry '[ERASED_TYPES] '[ERASED_TYPES]
eraseTypes :: forall (ins :: [*]) (out :: [*]).
Registry ins out -> Registry '[ERASED_TYPES] '[ERASED_TYPES]
eraseTypes (Registry Entries
entries Specializations
specializations Modifiers
modifiers) = Entries
-> Specializations
-> Modifiers
-> Registry '[ERASED_TYPES] '[ERASED_TYPES]
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
entries Specializations
specializations Modifiers
modifiers
data ERASED_TYPES
safeCoerce :: (IsSameSet out out1) => Registry ins out -> Registry ins1 out1
safeCoerce :: forall (out :: [*]) (out1 :: [*]) (ins :: [*]) (ins1 :: [*]).
IsSameSet out out1 =>
Registry ins out -> Registry ins1 out1
safeCoerce (Registry Entries
a Specializations
b Modifiers
c) = Entries -> Specializations -> Modifiers -> Registry ins1 out1
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
a Specializations
b Modifiers
c
unsafeCoerce :: Registry ins out -> Registry ins1 out1
unsafeCoerce :: forall (ins :: [*]) (out :: [*]) (ins1 :: [*]) (out1 :: [*]).
Registry ins out -> Registry ins1 out1
unsafeCoerce (Registry Entries
a Specializations
b Modifiers
c) = Entries -> Specializations -> Modifiers -> Registry ins1 out1
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
a Specializations
b Modifiers
c
end :: Registry '[] '[]
end :: Registry '[] '[]
end = Entries -> Specializations -> Modifiers -> Registry '[] '[]
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
forall a. Monoid a => a
mempty Specializations
forall a. Monoid a => a
mempty Modifiers
forall a. Monoid a => a
mempty
val :: (Typeable a, Show a) => a -> Typed a
val :: forall a. (Typeable a, Show a) => a -> Typed a
val a
a = Value -> Typed a
forall {k} (a :: k). Value -> Typed a
TypedValue (Dynamic -> ValueDescription -> Value
ProvidedValue (a -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn a
a) (a -> ValueDescription
forall a. (Typeable a, Show a) => a -> ValueDescription
describeValue a
a))
valTo :: forall m a. (Applicative m, Typeable a, Typeable (m a), Show a) => a -> Typed (m a)
valTo :: forall (m :: * -> *) a.
(Applicative m, Typeable a, Typeable (m a), Show a) =>
a -> Typed (m a)
valTo a
a = Value -> Typed (m a)
forall {k} (a :: k). Value -> Typed a
TypedValue (forall (m :: * -> *) a.
(Applicative m, Typeable a, Typeable (m a), Show a) =>
a -> Value
liftProvidedValue @m a
a)
liftProvidedValue :: forall m a. (Applicative m, Typeable a, Typeable (m a), Show a) => a -> Value
liftProvidedValue :: forall (m :: * -> *) a.
(Applicative m, Typeable a, Typeable (m a), Show a) =>
a -> Value
liftProvidedValue a
a = Dynamic -> ValueDescription -> Value
ProvidedValue (m a -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn (a -> m a
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a :: m a)) (a -> ValueDescription
forall a. (Typeable a, Show a) => a -> ValueDescription
describeValue a
a)
fun :: (Typeable a) => a -> Typed a
fun :: forall a. Typeable a => a -> Typed a
fun a
a = Function -> Typed a
forall {k} (a :: k). Function -> Typed a
TypedFunction (a -> Function
forall f. Typeable f => f -> Function
createFunction a
a)
funTo :: forall m a b. (ApplyVariadic m a b, Typeable a, Typeable b) => a -> Typed b
funTo :: forall (m :: * -> *) a b.
(ApplyVariadic m a b, Typeable a, Typeable b) =>
a -> Typed b
funTo a
a = b -> Typed b
forall a. Typeable a => a -> Typed a
fun (forall (f :: * -> *) a b. ApplyVariadic f a b => a -> b
allTo @m a
a)
funAs :: forall m a b. (ApplyVariadic1 m a b, Typeable a, Typeable b) => a -> Typed b
funAs :: forall (m :: * -> *) a b.
(ApplyVariadic1 m a b, Typeable a, Typeable b) =>
a -> Typed b
funAs a
a = b -> Typed b
forall a. Typeable a => a -> Typed a
fun (forall (f :: * -> *) a b. ApplyVariadic1 f a b => a -> b
argsTo @m a
a)
specialize :: forall a b ins out. (Typeable a) => Typed b -> Registry ins out -> Registry ins out
specialize :: forall {k} {k} (a :: k) (b :: k) (ins :: [*]) (out :: [*]).
Typeable a =>
Typed b -> Registry ins out -> Registry ins out
specialize Typed b
b (Registry Entries
entries (Specializations [Specialization]
c) Modifiers
modifiers) = do
let ss :: Specializations
ss = [Specialization] -> Specializations
Specializations (SpecializationPath -> Untyped -> Specialization
Specialization (SomeTypeRep -> SpecializationPath
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeTypeRep -> SpecializationPath)
-> SomeTypeRep -> SpecializationPath
forall a b. (a -> b) -> a -> b
$ Proxy a -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (Proxy a
forall {k} (t :: k). Proxy t
Proxy :: Proxy a)) (Typed b -> Untyped
forall {k} (a :: k). Typed a -> Untyped
untype Typed b
b) Specialization -> [Specialization] -> [Specialization]
forall a. a -> [a] -> [a]
: [Specialization]
c)
Entries -> Specializations -> Modifiers -> Registry ins out
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
entries Specializations
ss Modifiers
modifiers
specializePath :: forall path b ins out. (PathToTypeReps path) => Typed b -> Registry ins out -> Registry ins out
specializePath :: forall {k} (path :: [*]) (b :: k) (ins :: [*]) (out :: [*]).
PathToTypeReps path =>
Typed b -> Registry ins out -> Registry ins out
specializePath Typed b
b (Registry Entries
entries (Specializations [Specialization]
c) Modifiers
modifiers) = do
let ss :: Specializations
ss = [Specialization] -> Specializations
Specializations (SpecializationPath -> Untyped -> Specialization
Specialization (Proxy path -> SpecializationPath
forall (path :: [*]).
PathToTypeReps path =>
Proxy path -> SpecializationPath
someTypeReps (Proxy path
forall {k} (t :: k). Proxy t
Proxy :: Proxy path)) (Typed b -> Untyped
forall {k} (a :: k). Typed a -> Untyped
untype Typed b
b) Specialization -> [Specialization] -> [Specialization]
forall a. a -> [a] -> [a]
: [Specialization]
c)
Entries -> Specializations -> Modifiers -> Registry ins out
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry Entries
entries Specializations
ss Modifiers
modifiers
class PathToTypeReps (path :: [Type]) where
someTypeReps :: Proxy path -> NonEmpty SomeTypeRep
instance {-# OVERLAPPING #-} (Typeable a) => PathToTypeReps '[a] where
someTypeReps :: Proxy '[a] -> SpecializationPath
someTypeReps = SpecializationPath -> Proxy '[a] -> SpecializationPath
forall a b. a -> b -> a
const (SpecializationPath -> Proxy '[a] -> SpecializationPath)
-> SpecializationPath -> Proxy '[a] -> SpecializationPath
forall a b. (a -> b) -> a -> b
$ SomeTypeRep -> SpecializationPath
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Proxy a -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (Proxy a
forall {k} (t :: k). Proxy t
Proxy :: Proxy a))
instance (Typeable a, PathToTypeReps rest) => PathToTypeReps (a : rest) where
someTypeReps :: Proxy (a : rest) -> SpecializationPath
someTypeReps = SpecializationPath -> Proxy (a : rest) -> SpecializationPath
forall a b. a -> b -> a
const (SpecializationPath -> Proxy (a : rest) -> SpecializationPath)
-> SpecializationPath -> Proxy (a : rest) -> SpecializationPath
forall a b. (a -> b) -> a -> b
$ Proxy a -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (Proxy a
forall {k} (t :: k). Proxy t
Proxy :: Proxy a) SomeTypeRep -> [SomeTypeRep] -> SpecializationPath
forall a. a -> [a] -> NonEmpty a
:| SpecializationPath -> [SomeTypeRep]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Proxy rest -> SpecializationPath
forall (path :: [*]).
PathToTypeReps path =>
Proxy path -> SpecializationPath
someTypeReps (Proxy rest
forall {k} (t :: k). Proxy t
Proxy :: Proxy rest))
tweak :: forall a ins out. (Typeable a) => (a -> a) -> Registry ins out -> Registry ins out
tweak :: forall a (ins :: [*]) (out :: [*]).
Typeable a =>
(a -> a) -> Registry ins out -> Registry ins out
tweak a -> a
f (Registry Entries
entries Specializations
specializations (Modifiers [(SomeTypeRep, ModifierFunction)]
mf)) =
Entries -> Specializations -> Modifiers -> Registry ins out
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry
Entries
entries
Specializations
specializations
([(SomeTypeRep, ModifierFunction)] -> Modifiers
Modifiers ((Proxy a -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (Proxy a
forall {k} (t :: k). Proxy t
Proxy :: Proxy a), (a -> a) -> ModifierFunction
forall f. Typeable f => f -> ModifierFunction
createConstModifierFunction a -> a
f) (SomeTypeRep, ModifierFunction)
-> [(SomeTypeRep, ModifierFunction)]
-> [(SomeTypeRep, ModifierFunction)]
forall a. a -> [a] -> [a]
: [(SomeTypeRep, ModifierFunction)]
mf))
tweakUnspecialized :: forall a ins out. (Typeable a) => (a -> a) -> Registry ins out -> Registry ins out
tweakUnspecialized :: forall a (ins :: [*]) (out :: [*]).
Typeable a =>
(a -> a) -> Registry ins out -> Registry ins out
tweakUnspecialized a -> a
f (Registry Entries
entries Specializations
specializations (Modifiers [(SomeTypeRep, ModifierFunction)]
mf)) =
Entries -> Specializations -> Modifiers -> Registry ins out
forall (inputs :: [*]) (outputs :: [*]).
Entries -> Specializations -> Modifiers -> Registry inputs outputs
Registry
Entries
entries
Specializations
specializations
([(SomeTypeRep, ModifierFunction)] -> Modifiers
Modifiers ((Proxy a -> SomeTypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> SomeTypeRep
someTypeRep (Proxy a
forall {k} (t :: k). Proxy t
Proxy :: Proxy a), forall a f.
(Typeable f, Typeable a, Typeable (a -> a)) =>
f -> ModifierFunction
createUnspecializedModifierFunction @a a -> a
f) (SomeTypeRep, ModifierFunction)
-> [(SomeTypeRep, ModifierFunction)]
-> [(SomeTypeRep, ModifierFunction)]
forall a. a -> [a] -> [a]
: [(SomeTypeRep, ModifierFunction)]
mf))