@@ -7,13 +7,12 @@ module Data.Bounded
7
7
) where
8
8
9
9
import Data.Ord (class Ord , class OrdRecord , Ordering (..), compare , (<), (<=), (>), (>=))
10
- import Data.Symbol (class IsSymbol , SProxy (..), reflectSymbol )
10
+ import Data.Symbol (class IsSymbol , reflectSymbol )
11
11
import Data.Unit (Unit , unit )
12
12
import Prim.Row as Row
13
13
import Prim.RowList as RL
14
14
import Record.Unsafe (unsafeSet )
15
- import Type.Data.Row (RProxy (..))
16
- import Type.Data.RowList (RLProxy (..))
15
+ import Type.Proxy (Proxy (..), Proxy2 (..), Proxy3 (..))
17
16
18
17
-- | The `Bounded` type class represents totally ordered types that have an
19
18
-- | upper and lower boundary.
@@ -62,9 +61,22 @@ instance boundedNumber :: Bounded Number where
62
61
top = topNumber
63
62
bottom = bottomNumber
64
63
64
+ instance boundedProxy :: Bounded (Proxy a ) where
65
+ bottom = Proxy
66
+ top = Proxy
67
+
68
+ instance boundedProxy2 :: Bounded (Proxy2 a ) where
69
+ bottom = Proxy2
70
+ top = Proxy2
71
+
72
+ instance boundedProxy3 :: Bounded (Proxy3 a ) where
73
+ bottom = Proxy3
74
+ top = Proxy3
75
+
76
+ class BoundedRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint
65
77
class OrdRecord rowlist row <= BoundedRecord rowlist row subrow | rowlist -> subrow where
66
- topRecord :: RLProxy rowlist -> RProxy row -> Record subrow
67
- bottomRecord :: RLProxy rowlist -> RProxy row -> Record subrow
78
+ topRecord :: forall rlproxy rproxy . rlproxy rowlist -> rproxy row -> Record subrow
79
+ bottomRecord :: forall rlproxy rproxy . rlproxy rowlist -> rproxy row -> Record subrow
68
80
69
81
instance boundedRecordNil :: BoundedRecord RL.Nil row () where
70
82
topRecord _ _ = {}
@@ -81,21 +93,21 @@ instance boundedRecordCons
81
93
topRecord _ rowProxy
82
94
= insert top tail
83
95
where
84
- key = reflectSymbol (SProxy :: SProxy key )
96
+ key = reflectSymbol (Proxy :: Proxy key )
85
97
insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
86
- tail = topRecord (RLProxy :: RLProxy rowlistTail ) rowProxy
98
+ tail = topRecord (Proxy :: Proxy rowlistTail ) rowProxy
87
99
88
100
bottomRecord _ rowProxy
89
101
= insert bottom tail
90
102
where
91
- key = reflectSymbol (SProxy :: SProxy key )
103
+ key = reflectSymbol (Proxy :: Proxy key )
92
104
insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
93
- tail = bottomRecord (RLProxy :: RLProxy rowlistTail ) rowProxy
105
+ tail = bottomRecord (Proxy :: Proxy rowlistTail ) rowProxy
94
106
95
107
instance boundedRecord
96
108
:: ( RL.RowToList row list
97
109
, BoundedRecord list row row
98
110
)
99
111
=> Bounded (Record row ) where
100
- top = topRecord (RLProxy :: RLProxy list ) (RProxy :: RProxy row )
101
- bottom = bottomRecord (RLProxy :: RLProxy list ) (RProxy :: RProxy row )
112
+ top = topRecord (Proxy :: Proxy list ) (Proxy :: Proxy row )
113
+ bottom = bottomRecord (Proxy :: Proxy list ) (Proxy :: Proxy row )
0 commit comments