Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 99b3a6a

Browse files
committed
Add primed constructors for record-based arguments
Basically just save an `embed` elsewhere, but πŸ€·β€β™‚οΈ
1 parent de682fe commit 99b3a6a

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

β€Žsrc/SqlSquared/Constructors.pursβ€Ž

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,28 @@ ident' ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.Ident β†’ t
6060
ident' = embed ∘ Sig.Identifier
6161

6262
match ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ t β†’ L.List (Sig.Case t) β†’ Maybe t β†’ t
63-
match expr cases else_ = embed $ Sig.Match { expr, cases, else_ }
63+
match expr cases else_ = match' { expr, cases, else_ }
64+
65+
match' ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.MatchR t β†’ t
66+
match' = embed ∘ Sig.Match
6467

6568
switch ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ L.List (Sig.Case t) β†’ Maybe t β†’ t
66-
switch cases else_ = embed $ Sig.Switch { cases, else_ }
69+
switch cases else_ = switch' { cases, else_ }
70+
71+
switch' ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.SwitchR t β†’ t
72+
switch' = embed ∘ Sig.Switch
6773

6874
let_ ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.Ident β†’ t β†’ t β†’ t
6975
let_ id bindTo in_ = embed $ Sig.Let { ident: id, bindTo, in_ }
7076

77+
let' ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.LetR t β†’ t
78+
let' = embed ∘ Sig.Let
79+
7180
invokeFunction ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.Ident β†’ L.List t β†’ t
72-
invokeFunction name args = embed $ Sig.InvokeFunction {name, args}
81+
invokeFunction name args = invokeFunction' { name, args }
82+
83+
invokeFunction' ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.InvokeFunctionR t β†’ t
84+
invokeFunction' = embed ∘ Sig.InvokeFunction
7385

7486
-- when (bool true) # then_ (num 1.0) :P
7587
when ∷ βˆ€ t. t β†’ (t β†’ Sig.Case t)
@@ -90,8 +102,7 @@ select
90102
β†’ Maybe (Sig.OrderBy t)
91103
β†’ t
92104
select isDistinct projections relations filter gb orderBy =
93-
embed
94-
$ Sig.Select
105+
select'
95106
{ isDistinct
96107
, projections: L.fromFoldable projections
97108
, relations
@@ -100,6 +111,8 @@ select isDistinct projections relations filter gb orderBy =
100111
, orderBy
101112
}
102113

114+
select' ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ Sig.SelectR t β†’ t
115+
select' = embed ∘ Sig.Select
103116

104117
-- project (ident "foo") # as "bar"
105118
-- project (ident "foo")
@@ -120,9 +133,8 @@ having t (Sig.GroupBy r) = Sig.GroupBy r{ having = Just t }
120133

121134
buildSelect ∷ βˆ€ t f. Corecursive t (Sig.SqlF f) β‡’ (Sig.SelectR t β†’ Sig.SelectR t) β†’ t
122135
buildSelect f =
123-
embed
124-
$ Sig.Select
125-
$ f { isDistinct: false
136+
select' $
137+
f { isDistinct: false
126138
, projections: L.Nil
127139
, relations: Nothing
128140
, filter: Nothing

0 commit comments

Comments
Β (0)