@@ -1,4 +1,4 @@
1−module Yoga.Fetch.Om.ClientFn
1+module Yoga.Fetch.Om.ClientFunction
2 ( class BuildClientFn
2 ( class BuildClientFn
3 , buildClientFn
3 , buildClientFn
4 , class CheckBodyIsUnit
4 , class CheckBodyIsUnit
@@ -10,7 +10,6 @@ import Data.Unit (Unit, unit)
10import Prim.RowList (RowList)
10import Prim.RowList (RowList)
11import Prim.RowList as RL
11import Prim.RowList as RL
12import Type.Proxy (Proxy)
12import Type.Proxy (Proxy)
13−import Unsafe.Coerce (unsafeCoerce)
14import Yoga.Om (Om)
13import Yoga.Om (Om)
16data IsUnit
15data IsUnit
@@ -26,7 +25,9 @@ class BuildClientFn
26 :: RowList Type -> RowList Type -> Type -> Type -> Row Type -> Row Type -> Row Type -> Type -> Type -> Constraint
25 :: RowList Type -> RowList Type -> Type -> Type -> Row Type -> Row Type -> Row Type -> Type -> Type -> Constraint
28 BuildClientFn pathQueryRL headersRL bodyFlag body pathQuery headers errorRow result fn
27 BuildClientFn pathQueryRL headersRL bodyFlag body pathQuery headers errorRow result fn
28+ | pathQueryRL -> pathQuery
29+ , headersRL -> headers
29− | pathQueryRL headersRL bodyFlag body pathQuery headers errorRow result -> fn where
30+ , pathQueryRL headersRL bodyFlag body errorRow result -> fn where
30 buildClientFn
31 buildClientFn
31 :: Proxy pathQueryRL
32 :: Proxy pathQueryRL
32 -> Proxy headersRL
33 -> Proxy headersRL
@@ -40,12 +41,12 @@ instance
47 (Om (Record ()) errorRow result) where
48 (Om (Record ()) errorRow result) where
48− buildClientFn _ _ _ f = unsafeCoerce (f (unsafeCoerce {}) (unsafeCoerce {}) unit)
49+ buildClientFn _ _ _ f = f {} {} unit
50-- No path/query, no headers, with body
51-- No path/query, no headers, with body
@@ -53,12 +54,12 @@ instance
60 (body -> Om (Record ()) errorRow result) where
61 (body -> Om (Record ()) errorRow result) where
61− buildClientFn _ _ _ f = unsafeCoerce (\b -> f (unsafeCoerce {}) (unsafeCoerce {}) b)
62+ buildClientFn _ _ _ f b = f {} {} b
63-- No path/query, with headers, no body
64-- No path/query, with headers, no body
@@ -66,12 +67,12 @@ instance
66 (RL.Cons n t tl)
67 (RL.Cons n t tl)
73 (Record h -> Om (Record ()) errorRow result) where
74 (Record h -> Om (Record ()) errorRow result) where
74− buildClientFn _ _ _ f = unsafeCoerce (\hdrs -> f (unsafeCoerce {}) hdrs unit)
75+ buildClientFn _ _ _ f hdrs = f {} hdrs unit
76-- No path/query, with headers, with body
77-- No path/query, with headers, with body
@@ -79,12 +80,12 @@ instance
79 (RL.Cons n t tl)
80 (RL.Cons n t tl)
86 (Record h -> body -> Om (Record ()) errorRow result) where
87 (Record h -> body -> Om (Record ()) errorRow result) where
87− buildClientFn _ _ _ f = unsafeCoerce (\hdrs b -> f (unsafeCoerce {}) hdrs b)
88+ buildClientFn _ _ _ f hdrs b = f {} hdrs b
89-- With path/query, no headers, no body
90-- With path/query, no headers, no body
@@ -93,11 +94,11 @@ instance
99 (Record pq -> Om (Record ()) errorRow result) where
100 (Record pq -> Om (Record ()) errorRow result) where
100− buildClientFn _ _ _ f = unsafeCoerce (\pqr -> f pqr (unsafeCoerce {}) unit)
101+ buildClientFn _ _ _ f pqr = f pqr {} unit
102-- With path/query, no headers, with body
103-- With path/query, no headers, with body
@@ -106,11 +107,11 @@ instance
106 IsNotUnit
107 IsNotUnit
112 (Record pq -> body -> Om (Record ()) errorRow result) where
113 (Record pq -> body -> Om (Record ()) errorRow result) where
113− buildClientFn _ _ _ f = unsafeCoerce (\pqr b -> f pqr (unsafeCoerce {}) b)
114+ buildClientFn _ _ _ f pqr b = f pqr {} b
115-- With path/query, with headers, no body
116-- With path/query, with headers, no body
@@ -123,7 +124,7 @@ instance
125 (Record pq -> Record h -> Om (Record ()) errorRow result) where
126 (Record pq -> Record h -> Om (Record ()) errorRow result) where
126− buildClientFn _ _ _ f = unsafeCoerce (\pqr hdrs -> f pqr hdrs unit)
127+ buildClientFn _ _ _ f pqr hdrs = f pqr hdrs unit
128-- With path/query, with headers, with body
129-- With path/query, with headers, with body
@@ -136,4 +137,4 @@ instance
138 (Record pq -> Record h -> body -> Om (Record ()) errorRow result) where
139 (Record pq -> Record h -> body -> Om (Record ()) errorRow result) where
139− buildClientFn _ _ _ f = unsafeCoerce f
140+ buildClientFn _ _ _ f = f