@@ -2,15 +2,12 @@ module Yoga.Fetch.Om.ClientFn
22 ( class BuildClientFn
33 , buildClientFn
44 , class CheckBodyIsUnit
5− , class CheckRowEmpty
65 , IsUnit
76 , IsNotUnit
8− , IsEmpty
9− , IsNonEmpty
107 ) where
118
129import Data.Unit (Unit, unit)
13−import Prim.RowList (class RowToList, RowList)
10+import Prim.RowList (RowList)
1411import Prim.RowList as RL
1512import Type.Proxy (Proxy)
1613import Unsafe.Coerce (unsafeCoerce)
@@ -18,8 +15,6 @@ import Yoga.Om (Om)
1815
1916data IsUnit
2017data IsNotUnit
21−data IsEmpty
22−data IsNonEmpty
2318
2419class CheckBodyIsUnit :: Type -> Type -> Constraint
2520class CheckBodyIsUnit body flag | body -> flag
@@ -27,27 +22,22 @@ class CheckBodyIsUnit body flag | body -> flag
2722instance CheckBodyIsUnit Unit IsUnit
2823else instance CheckBodyIsUnit body IsNotUnit
2924
30−class CheckRowEmpty :: Row Type -> Type -> Constraint
31−class CheckRowEmpty row flag | row -> flag
32−
33−instance RowToList row RL.Nil => CheckRowEmpty row IsEmpty
34−else instance CheckRowEmpty row IsNonEmpty
35−
3625class BuildClientFn
37− :: RowList Type -> Type -> Type -> Type -> Row Type -> Row Type -> Row Type -> Type -> Type -> Constraint
26+ :: RowList Type -> RowList Type -> Type -> Type -> Row Type -> Row Type -> Row Type -> Type -> Type -> Constraint
3827class
39− BuildClientFn pathQueryRL headersFlag bodyFlag body pathQuery headers errorRow result fn
40− | pathQueryRL headersFlag bodyFlag body pathQuery headers errorRow result -> fn where
28+ BuildClientFn pathQueryRL headersRL bodyFlag body pathQuery headers errorRow result fn
29+ | pathQueryRL headersRL bodyFlag body pathQuery headers errorRow result -> fn where
4130 buildClientFn
4231 :: Proxy pathQueryRL
43− -> Proxy headersFlag
32+ -> Proxy headersRL
4433 -> Proxy bodyFlag
4534 -> (Record pathQuery -> Record headers -> body -> Om {} errorRow result)
4635 -> fn
4736
37+-- No path/query, no headers, no body
4838instance
4939 BuildClientFn RL.Nil
50− IsEmpty
40+ RL.Nil
5141 IsUnit
5242 Unit
5343 pq
@@ -57,9 +47,10 @@ instance
5747 (Om {} errorRow result) where
5848 buildClientFn _ _ _ f = f (unsafeCoerce {}) (unsafeCoerce {}) unit
5949
50+-- No path/query, no headers, with body
6051instance
6152 BuildClientFn RL.Nil
62− IsEmpty
53+ RL.Nil
6354 IsNotUnit
6455 body
6556 pq
@@ -69,9 +60,10 @@ instance
6960 (body -> Om {} errorRow result) where
7061 buildClientFn _ _ _ f = \b -> f (unsafeCoerce {}) (unsafeCoerce {}) b
7162
63+-- No path/query, with headers, no body
7264instance
7365 BuildClientFn RL.Nil
74− IsNonEmpty
66+ (RL.Cons n t tl)
7567 IsUnit
7668 Unit
7769 pq
@@ -81,9 +73,10 @@ instance
8173 (Record h -> Om {} errorRow result) where
8274 buildClientFn _ _ _ f = \hdrs -> f (unsafeCoerce {}) hdrs unit
8375
76+-- No path/query, with headers, with body
8477instance
8578 BuildClientFn RL.Nil
86− IsNonEmpty
79+ (RL.Cons n t tl)
8780 IsNotUnit
8881 body
8982 pq
@@ -93,9 +86,10 @@ instance
9386 (Record h -> body -> Om {} errorRow result) where
9487 buildClientFn _ _ _ f = \hdrs b -> f (unsafeCoerce {}) hdrs b
9588
89+-- With path/query, no headers, no body
9690instance
9791 BuildClientFn (RL.Cons n t tl)
98− IsEmpty
92+ RL.Nil
9993 IsUnit
10094 Unit
10195 pq
@@ -105,9 +99,10 @@ instance
10599 (Record pq -> Om {} errorRow result) where
106100 buildClientFn _ _ _ f = \pqr -> f pqr (unsafeCoerce {}) unit
107101
102+-- With path/query, no headers, with body
108103instance
109104 BuildClientFn (RL.Cons n t tl)
110− IsEmpty
105+ RL.Nil
111106 IsNotUnit
112107 body
113108 pq
@@ -117,9 +112,10 @@ instance
117112 (Record pq -> body -> Om {} errorRow result) where
118113 buildClientFn _ _ _ f = \pqr b -> f pqr (unsafeCoerce {}) b
119114
115+-- With path/query, with headers, no body
120116instance
121117 BuildClientFn (RL.Cons n t tl)
122− IsNonEmpty
118+ (RL.Cons hn ht htl)
123119 IsUnit
124120 Unit
125121 pq
@@ -129,9 +125,10 @@ instance
129125 (Record pq -> Record h -> Om {} errorRow result) where
130126 buildClientFn _ _ _ f = \pqr hdrs -> f pqr hdrs unit
131127
128+-- With path/query, with headers, with body
132129instance
133130 BuildClientFn (RL.Cons n t tl)
134− IsNonEmpty
131+ (RL.Cons hn ht htl)
135132 IsNotUnit
136133 body
137134 pq