/
RowList.purs
43 lines (36 loc) · 1.14 KB
/
RowList.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module Type.Proxying.RowList
( class GenericRLProxying
, class RLProxying
, genericRLProxy
, rlProxy
) where
import Data.Generic.Rep
( class Generic
, Constructor(Constructor)
, NoArguments(NoArguments)
, to
)
import Prim.RowList (kind RowList)
import Type.Data.RowList (RLProxy(RLProxy))
import Type.Proxy (Proxy(Proxy))
class
Generic (f l) rep
<= GenericRLProxying (rep :: Type) (f :: RowList -> Type) (l :: RowList)
where
genericRLProxy :: Proxy rep -> f l
instance genericRLProxyingConstructor
:: Generic (f l) (Constructor proxyName NoArguments)
=> GenericRLProxying (Constructor proxyName NoArguments) f l
where
genericRLProxy _ = to (Constructor NoArguments)
class RLProxying (f :: RowList -> Type) (l :: RowList) where
rlProxy :: f l
instance rlProxying_TypeDataRowList_RLProxy :: RLProxying RLProxy l where
rlProxy = RLProxy
else instance rlProxying_TypeRow_RLProxy :: RLProxying RLProxy l where
rlProxy = RLProxy
else instance rlProxyingGeneric
:: Generic (f l) (Constructor proxyName NoArguments)
=> RLProxying f l
where
rlProxy = genericRLProxy (Proxy :: Proxy (Constructor proxyName NoArguments))