{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Copilot.Language.Operators.Struct
( Projectable(..)
, (#)
, (##)
) where
import Copilot.Core.Type
import Copilot.Core.Operators
import Copilot.Language.Operators.Projection
import Copilot.Language.Stream (Stream (..))
import GHC.TypeLits (KnownSymbol)
(#) :: (KnownSymbol f, Typed t, Typed s, Struct s)
=> Stream s -> (s -> Field f t) -> Stream t
# :: forall (f :: Symbol) t s.
(KnownSymbol f, Typed t, Typed s, Struct s) =>
Stream s -> (s -> Field f t) -> Stream t
(#) Stream s
s s -> Field f t
f = Op1 s t -> Stream s -> Stream t
forall a1 a.
(Typed a1, Typed a) =>
Op1 a1 a -> Stream a1 -> Stream a
Op1 (Type s -> Type t -> (s -> Field f t) -> Op1 s t
forall (s :: Symbol) a b.
KnownSymbol s =>
Type a -> Type b -> (a -> Field s b) -> Op1 a b
GetField Type s
forall a. Typed a => Type a
typeOf Type t
forall a. Typed a => Type a
typeOf s -> Field f t
f) Stream s
s
(##) :: (KnownSymbol f, Typed t, Typed s, Struct s)
=> Stream s -> (s -> Field f t) -> Projection s (s -> Field f t) t
## :: forall (f :: Symbol) t s.
(KnownSymbol f, Typed t, Typed s, Struct s) =>
Stream s -> (s -> Field f t) -> Projection s (s -> Field f t) t
(##) = Stream s -> (s -> Field f t) -> Projection s (s -> Field f t) t
forall s (f :: Symbol) t.
Stream s -> (s -> Field f t) -> Projection s (s -> Field f t) t
ProjectionS
instance (KnownSymbol f, Typed s, Typed t, Struct s)
=> Projectable s (s -> Field f t) t
where
data Projection s (s -> Field f t) t = ProjectionS (Stream s) (s -> Field f t)
=: :: Projection s (s -> Field f t) t -> Stream t -> Stream s
(=:) (ProjectionS Stream s
s s -> Field f t
f) Stream t
v = Op2 s t s -> Stream s -> Stream t -> Stream s
forall a1 b a.
(Typed a1, Typed b, Typed a) =>
Op2 a1 b a -> Stream a1 -> Stream b -> Stream a
Op2 (Type s -> Type t -> (s -> Field f t) -> Op2 s t s
forall b (s :: Symbol) a.
(Typeable b, KnownSymbol s, Show b) =>
Type a -> Type b -> (a -> Field s b) -> Op2 a b a
UpdateField Type s
forall a. Typed a => Type a
typeOf Type t
forall a. Typed a => Type a
typeOf s -> Field f t
f) Stream s
s Stream t
v
=$ :: Projection s (s -> Field f t) t
-> (Stream t -> Stream t) -> Stream s
(=$) (ProjectionS Stream s
s s -> Field f t
f) Stream t -> Stream t
op = Op2 s t s -> Stream s -> Stream t -> Stream s
forall a1 b a.
(Typed a1, Typed b, Typed a) =>
Op2 a1 b a -> Stream a1 -> Stream b -> Stream a
Op2 (Type s -> Type t -> (s -> Field f t) -> Op2 s t s
forall b (s :: Symbol) a.
(Typeable b, KnownSymbol s, Show b) =>
Type a -> Type b -> (a -> Field s b) -> Op2 a b a
UpdateField Type s
forall a. Typed a => Type a
typeOf Type t
forall a. Typed a => Type a
typeOf s -> Field f t
f) Stream s
s (Stream t -> Stream t
op (Stream s
s Stream s -> (s -> Field f t) -> Stream t
forall (f :: Symbol) t s.
(KnownSymbol f, Typed t, Typed s, Struct s) =>
Stream s -> (s -> Field f t) -> Stream t
# s -> Field f t
f))