BoomBoom.Generic.Interpret
- Package
- purescript-boomboom
- Repository
- paluh/purescript-boomboom
#R Source
data R a
Here we are defining machinery for "tree of records" interpretation. As we are defining this tree on the type level and operating on it through type classes this stragegy should not suffer from the "expression problem" and should be extensible - you should be able to extend given node set but also interpretation set for predefined nodes.
This interpreting machinery allows to run transformations similar to catamorphisms but also less elegant/simple scenarios which require information about parent node too.
Constructors
Instances
(Alg interpreter field (R r) r' r'', RowToList r rl, MapRecord interpreter "R" rl r r') => Interpret interpreter field (R r) r''
Alg "unwrap" Root (R o) (Builder (Record ()) (Record r)) (Record r)
(IsSymbol fieldName, RowLacks fieldName prs, RowCons fieldName (Record r) prs prs') => Alg "unwrap" (Field parent fieldName) (R o) (Builder (Record ()) (Record r)) (Builder (Record prs) (Record prs'))
Alg "boomboom" Root (R o) (ProductBuilder tok r (Record ()) r) (BoomBoom tok r)
"boomboom" interpreter which builds a BoomBoom from our tree where
V
represents variant,R
represents record andB
holdsBoomBoom
.(AddField parent fieldName (BoomBoom tok (Record r)) b) => Alg "boomboom" (Field parent fieldName) (R o) (ProductBuilder tok (Record r) (Record ()) (Record r)) b
(RowToList output ol, SameLabels ol builder) => Alg "builder" Root (R o) (ApplicativeCat (Function (Record builder)) Builder (Record ()) (Record output)) (Record builder -> Record output)
"builder" interpreter - it produces helper function or record which can be used to produce value for serialization. In other words it simplifies nested variants generation. Check
tests/BoomBoom/Generic/Intepret.purs
for examples.(RowCons fieldName (Record subbuilder) builder builder', IsSymbol fieldName, RowCons fieldName (Record suboutput) output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder -> result) output output', RowLacks fieldName output, IsSymbol fieldName, RowCons fieldName (Record suboutput) v v', RowToList suboutput ol, SameLabels ol subbuilder) => Alg "builder" (Field "V" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record output) (Record output'))
#V Source
data V a
Constructors
Instances
(Alg interpreter field (V r) r' r'', RowToList r rl, MapRecord interpreter "V" rl r r') => Interpret interpreter field (V r) r''
Alg "unwrap" Root (V o) (Builder (Record ()) (Record r)) (Record r)
(IsSymbol fieldName, RowLacks fieldName prs, RowCons fieldName (Record r) prs prs') => Alg "unwrap" (Field parent fieldName) (V o) (Builder (Record ()) (Record r)) (Builder (Record prs) (Record prs'))
Alg "boomboom" Root (V o) (CoproductBuilder tok (Variant r) (Either (Variant r) tok) (Either (Variant ()) tok)) (BoomBoom tok (Variant r))
(AddField parent fieldName (BoomBoom tok (Variant r)) b) => Alg "boomboom" (Field parent fieldName) (V o) (CoproductBuilder tok (Variant r) (Either (Variant r) tok) (Either (Variant ()) tok)) b
(RowToList builder bl, SameLabels bl input) => Alg "builder" Root (V o) (ApplicativeCat (Function (Variant input -> Variant input)) Builder (Record ()) (Record builder)) (Record builder)
(RowCons fieldName (Record subbuilder -> Variant v) builder builder', IsSymbol fieldName, RowCons fieldName (Variant v) output output', RowLacks fieldName output, RowToList subbuilder bl, SameLabels bl v) => Alg "builder" (Field "R" fieldName) (V o) (ApplicativeCat (Function (Variant v -> Variant v)) Builder (Record ()) (Record subbuilder)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (Record r) n n', RowLacks fieldName n) => Alg "builder" (Field "V" fieldName) (V o) (ApplicativeCat (Function (a -> result)) Builder (Record ()) (Record r)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record n) (Record n'))
#B Source
data B t
Constructors
B t
Instances
(Alg interpreter field (B a) a a') => Interpret interpreter field (B a) a'
Alg "unwrap" Root (B o) a a
(IsSymbol fieldName, RowCons fieldName a prs prs', RowLacks fieldName prs) => Alg "unwrap" (Field parent fieldName) (B o) a (Builder (Record prs) (Record prs'))
Alg "boomboom" Root (B o) (BoomBoom tok a) (BoomBoom tok a)
(AddField parent fieldName (BoomBoom tok a) b) => Alg "boomboom" (Field parent fieldName) (B o) (BoomBoom tok a) b
(RowCons fieldName a builder builder', IsSymbol fieldName, RowCons fieldName a output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (a -> result) r r', RowLacks fieldName r) => Alg "builder" (Field "V" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record r) (Record r'))
#Root Source
data Root :: Field
Instances
Alg "unwrap" Root (R o) (Builder (Record ()) (Record r)) (Record r)
"unwrap" interpreter which just drops "R", "V" and "B" construtors
Alg "unwrap" Root (V o) (Builder (Record ()) (Record r)) (Record r)
Alg "unwrap" Root (B o) a a
Alg "boomboom" Root (R o) (ProductBuilder tok r (Record ()) r) (BoomBoom tok r)
"boomboom" interpreter which builds a BoomBoom from our tree where
V
represents variant,R
represents record andB
holdsBoomBoom
.Alg "boomboom" Root (V o) (CoproductBuilder tok (Variant r) (Either (Variant r) tok) (Either (Variant ()) tok)) (BoomBoom tok (Variant r))
Alg "boomboom" Root (B o) (BoomBoom tok a) (BoomBoom tok a)
(RowToList output ol, SameLabels ol builder) => Alg "builder" Root (R o) (ApplicativeCat (Function (Record builder)) Builder (Record ()) (Record output)) (Record builder -> Record output)
"builder" interpreter - it produces helper function or record which can be used to produce value for serialization. In other words it simplifies nested variants generation. Check
tests/BoomBoom/Generic/Intepret.purs
for examples.(RowToList builder bl, SameLabels bl input) => Alg "builder" Root (V o) (ApplicativeCat (Function (Variant input -> Variant input)) Builder (Record ()) (Record builder)) (Record builder)
#Field Source
data Field :: Symbol -> Symbol -> Field
Allow case analysis on constrctor:
- Parent name - it will be changed to parent type soon. It provides a way to break usual "locality" of *morphisms algebras which is required in case of BoomBooms generation.
- Field name which we are in.
Instances
(IsSymbol fieldName, RowLacks fieldName prs, RowCons fieldName (Record r) prs prs') => Alg "unwrap" (Field parent fieldName) (V o) (Builder (Record ()) (Record r)) (Builder (Record prs) (Record prs'))
(IsSymbol fieldName, RowLacks fieldName prs, RowCons fieldName (Record r) prs prs') => Alg "unwrap" (Field parent fieldName) (R o) (Builder (Record ()) (Record r)) (Builder (Record prs) (Record prs'))
(IsSymbol fieldName, RowCons fieldName a prs prs', RowLacks fieldName prs) => Alg "unwrap" (Field parent fieldName) (B o) a (Builder (Record prs) (Record prs'))
(AddField parent fieldName (BoomBoom tok (Record r)) b) => Alg "boomboom" (Field parent fieldName) (R o) (ProductBuilder tok (Record r) (Record ()) (Record r)) b
(AddField parent fieldName (BoomBoom tok (Variant r)) b) => Alg "boomboom" (Field parent fieldName) (V o) (CoproductBuilder tok (Variant r) (Either (Variant r) tok) (Either (Variant ()) tok)) b
(AddField parent fieldName (BoomBoom tok a) b) => Alg "boomboom" (Field parent fieldName) (B o) (BoomBoom tok a) b
(RowCons fieldName a builder builder', IsSymbol fieldName, RowCons fieldName a output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder) builder builder', IsSymbol fieldName, RowCons fieldName (Record suboutput) output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder -> Variant v) builder builder', IsSymbol fieldName, RowCons fieldName (Variant v) output output', RowLacks fieldName output, RowToList subbuilder bl, SameLabels bl v) => Alg "builder" (Field "R" fieldName) (V o) (ApplicativeCat (Function (Variant v -> Variant v)) Builder (Record ()) (Record subbuilder)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (a -> result) r r', RowLacks fieldName r) => Alg "builder" (Field "V" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record r) (Record r'))
(RowCons fieldName (Record subbuilder -> result) output output', RowLacks fieldName output, IsSymbol fieldName, RowCons fieldName (Record suboutput) v v', RowToList suboutput ol, SameLabels ol subbuilder) => Alg "builder" (Field "V" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (Record r) n n', RowLacks fieldName n) => Alg "builder" (Field "V" fieldName) (V o) (ApplicativeCat (Function (a -> result)) Builder (Record ()) (Record r)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record n) (Record n'))
#MapRecord Source
class MapRecord interpreter parent il i o | interpreter il -> o where
Members
Instances
(Category builder) => MapRecord interpreter parent Nil i (builder o o)
(Interpret interpreter (Field parent fieldName) field (builder o o'), IsSymbol interpreter, IsSymbol fieldName, RowCons fieldName field i' i, Semigroupoid builder) => MapRecord interpreter parent (Cons fieldName field Nil) i (builder o o')
(Interpret interpreter (Field parent fieldName) field (builder o o'), IsSymbol interpreter, IsSymbol fieldName, RowCons fieldName field i' i, MapRecord interpreter parent tail i (builder o' o''), Semigroupoid builder) => MapRecord interpreter parent (Cons fieldName field tail) i (builder o o'')
#Interpret Source
class Interpret interpreter field a b | interpreter field a -> b where
Members
interpretImpl :: InterpretProxy interpreter field -> a -> b
Instances
(Alg interpreter field (R r) r' r'', RowToList r rl, MapRecord interpreter "R" rl r r') => Interpret interpreter field (R r) r''
(Alg interpreter field (V r) r' r'', RowToList r rl, MapRecord interpreter "V" rl r r') => Interpret interpreter field (V r) r''
(Alg interpreter field (B a) a a') => Interpret interpreter field (B a) a'
#Alg Source
class Alg interpreter field term a b | interpreter field term -> a, interpreter field term a -> b where
I'm not sure about these functional dependencies but without them we have a problem...
Members
Instances
Alg "unwrap" Root (R o) (Builder (Record ()) (Record r)) (Record r)
"unwrap" interpreter which just drops "R", "V" and "B" construtors
Alg "unwrap" Root (V o) (Builder (Record ()) (Record r)) (Record r)
Alg "unwrap" Root (B o) a a
(IsSymbol fieldName, RowLacks fieldName prs, RowCons fieldName (Record r) prs prs') => Alg "unwrap" (Field parent fieldName) (V o) (Builder (Record ()) (Record r)) (Builder (Record prs) (Record prs'))
(IsSymbol fieldName, RowLacks fieldName prs, RowCons fieldName (Record r) prs prs') => Alg "unwrap" (Field parent fieldName) (R o) (Builder (Record ()) (Record r)) (Builder (Record prs) (Record prs'))
(IsSymbol fieldName, RowCons fieldName a prs prs', RowLacks fieldName prs) => Alg "unwrap" (Field parent fieldName) (B o) a (Builder (Record prs) (Record prs'))
Alg "boomboom" Root (R o) (ProductBuilder tok r (Record ()) r) (BoomBoom tok r)
"boomboom" interpreter which builds a BoomBoom from our tree where
V
represents variant,R
represents record andB
holdsBoomBoom
.Alg "boomboom" Root (V o) (CoproductBuilder tok (Variant r) (Either (Variant r) tok) (Either (Variant ()) tok)) (BoomBoom tok (Variant r))
Alg "boomboom" Root (B o) (BoomBoom tok a) (BoomBoom tok a)
(AddField parent fieldName (BoomBoom tok (Record r)) b) => Alg "boomboom" (Field parent fieldName) (R o) (ProductBuilder tok (Record r) (Record ()) (Record r)) b
(AddField parent fieldName (BoomBoom tok (Variant r)) b) => Alg "boomboom" (Field parent fieldName) (V o) (CoproductBuilder tok (Variant r) (Either (Variant r) tok) (Either (Variant ()) tok)) b
(AddField parent fieldName (BoomBoom tok a) b) => Alg "boomboom" (Field parent fieldName) (B o) (BoomBoom tok a) b
(RowToList output ol, SameLabels ol builder) => Alg "builder" Root (R o) (ApplicativeCat (Function (Record builder)) Builder (Record ()) (Record output)) (Record builder -> Record output)
"builder" interpreter - it produces helper function or record which can be used to produce value for serialization. In other words it simplifies nested variants generation. Check
tests/BoomBoom/Generic/Intepret.purs
for examples.(RowToList builder bl, SameLabels bl input) => Alg "builder" Root (V o) (ApplicativeCat (Function (Variant input -> Variant input)) Builder (Record ()) (Record builder)) (Record builder)
(RowCons fieldName a builder builder', IsSymbol fieldName, RowCons fieldName a output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder) builder builder', IsSymbol fieldName, RowCons fieldName (Record suboutput) output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder -> Variant v) builder builder', IsSymbol fieldName, RowCons fieldName (Variant v) output output', RowLacks fieldName output, RowToList subbuilder bl, SameLabels bl v) => Alg "builder" (Field "R" fieldName) (V o) (ApplicativeCat (Function (Variant v -> Variant v)) Builder (Record ()) (Record subbuilder)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (a -> result) r r', RowLacks fieldName r) => Alg "builder" (Field "V" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record r) (Record r'))
(RowCons fieldName (Record subbuilder -> result) output output', RowLacks fieldName output, IsSymbol fieldName, RowCons fieldName (Record suboutput) v v', RowToList suboutput ol, SameLabels ol subbuilder) => Alg "builder" (Field "V" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (Record r) n n', RowLacks fieldName n) => Alg "builder" (Field "V" fieldName) (V o) (ApplicativeCat (Function (a -> result)) Builder (Record ()) (Record r)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record n) (Record n'))
#AddField Source
class AddField parent name a b | parent a -> b where
Members
Instances
(RowCons name a s' s, RowLacks name s', RowCons name a p p', RowLacks name p, IsSymbol name) => AddField "R" name (BoomBoom tok a) (ProductBuilder tok (Record s) (Record p) (Record p'))
(RowCons name a r' r, RowLacks name r', RowCons name a s' s, RowLacks name s', IsSymbol name, Monoid tok, Eq tok, Prefix tok) => AddField "V" name (BoomBoom tok a) (CoproductBuilder tok (Variant s) (Either (Variant r) tok) (Either (Variant r') tok))
#ApplicativeCat Source
newtype ApplicativeCat appl cat a b
Constructors
ApplicativeCat (appl (cat a b))
Instances
(Apply appl, Semigroupoid cat) => Semigroupoid (ApplicativeCat appl cat)
(RowToList output ol, SameLabels ol builder) => Alg "builder" Root (R o) (ApplicativeCat (Function (Record builder)) Builder (Record ()) (Record output)) (Record builder -> Record output)
"builder" interpreter - it produces helper function or record which can be used to produce value for serialization. In other words it simplifies nested variants generation. Check
tests/BoomBoom/Generic/Intepret.purs
for examples.(RowToList builder bl, SameLabels bl input) => Alg "builder" Root (V o) (ApplicativeCat (Function (Variant input -> Variant input)) Builder (Record ()) (Record builder)) (Record builder)
(RowCons fieldName a builder builder', IsSymbol fieldName, RowCons fieldName a output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder) builder builder', IsSymbol fieldName, RowCons fieldName (Record suboutput) output output', RowLacks fieldName output) => Alg "builder" (Field "R" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName (Record subbuilder -> Variant v) builder builder', IsSymbol fieldName, RowCons fieldName (Variant v) output output', RowLacks fieldName output, RowToList subbuilder bl, SameLabels bl v) => Alg "builder" (Field "R" fieldName) (V o) (ApplicativeCat (Function (Variant v -> Variant v)) Builder (Record ()) (Record subbuilder)) (ApplicativeCat (Function (Record builder')) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (a -> result) r r', RowLacks fieldName r) => Alg "builder" (Field "V" fieldName) (B o) (BoomBoom tok a) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record r) (Record r'))
(RowCons fieldName (Record subbuilder -> result) output output', RowLacks fieldName output, IsSymbol fieldName, RowCons fieldName (Record suboutput) v v', RowToList suboutput ol, SameLabels ol subbuilder) => Alg "builder" (Field "V" fieldName) (R o) (ApplicativeCat (Function (Record subbuilder)) Builder (Record ()) (Record suboutput)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record output) (Record output'))
(RowCons fieldName a v v', IsSymbol fieldName, RowCons fieldName (Record r) n n', RowLacks fieldName n) => Alg "builder" (Field "V" fieldName) (V o) (ApplicativeCat (Function (a -> result)) Builder (Record ()) (Record r)) (ApplicativeCat (Function (Variant v' -> result)) Builder (Record n) (Record n'))
#ReaderCat Source
type ReaderCat v cat a b = ApplicativeCat (Function v) cat a b
#SameLabels Source
class SameLabels (list :: RowList) (row :: Row Type) | list -> row
Instances
SameLabels Nil ()
(RowCons name a row' row, SameLabels tail row') => SameLabels (Cons name x tail) row
"unwrap" interpreter which just drops "R", "V" and "B" construtors