@@ -3,7 +3,9 @@ module Data.Bounded
33 , bottom
44 , top
55 , module Data.Ord
6- , class BoundedRecord , bottomRecord , topRecord
6+ , class BoundedRecord
7+ , bottomRecord
8+ , topRecord
79 ) where
810
911import Data.Ord (class Ord , class OrdRecord , Ordering (..), compare , (<), (<=), (>), (>=))
@@ -12,7 +14,7 @@ import Data.Unit (Unit, unit)
1214import Prim.Row as Row
1315import Prim.RowList as RL
1416import Record.Unsafe (unsafeSet )
15- import Type.Proxy (Proxy (..), Proxy2 (..), Proxy3 (..) )
17+ import Type.Proxy (Proxy (..))
1618
1719-- | The `Bounded` type class represents totally ordered types that have an
1820-- | upper and lower boundary.
@@ -65,49 +67,39 @@ instance boundedProxy :: Bounded (Proxy a) where
6567 bottom = Proxy
6668 top = Proxy
6769
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-
7670class BoundedRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint
7771class OrdRecord rowlist row <= BoundedRecord rowlist row subrow | rowlist -> subrow where
78- topRecord :: forall rlproxy rproxy . rlproxy rowlist -> rproxy row -> Record subrow
79- bottomRecord :: forall rlproxy rproxy . rlproxy rowlist -> rproxy row -> Record subrow
72+ topRecord :: Proxy rowlist -> Proxy row -> Record subrow
73+ bottomRecord :: Proxy rowlist -> Proxy row -> Record subrow
8074
8175instance boundedRecordNil :: BoundedRecord RL.Nil row () where
8276 topRecord _ _ = {}
8377 bottomRecord _ _ = {}
8478
85- instance boundedRecordCons
86- :: ( IsSymbol key
87- , Bounded focus
88- , Row.Cons key focus rowTail row
89- , Row.Cons key focus subrowTail subrow
90- , BoundedRecord rowlistTail row subrowTail
91- )
92- => BoundedRecord (RL.Cons key focus rowlistTail ) row subrow where
93- topRecord _ rowProxy
94- = insert top tail
79+ instance boundedRecordCons ::
80+ ( IsSymbol key
81+ , Bounded focus
82+ , Row.Cons key focus rowTail row
83+ , Row.Cons key focus subrowTail subrow
84+ , BoundedRecord rowlistTail row subrowTail
85+ ) =>
86+ BoundedRecord (RL.Cons key focus rowlistTail ) row subrow where
87+ topRecord _ rowProxy = insert top tail
9588 where
96- key = reflectSymbol (Proxy :: Proxy key )
97- insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
98- tail = topRecord (Proxy :: Proxy rowlistTail ) rowProxy
89+ key = reflectSymbol (Proxy :: Proxy key )
90+ insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
91+ tail = topRecord (Proxy :: Proxy rowlistTail ) rowProxy
9992
100- bottomRecord _ rowProxy
101- = insert bottom tail
93+ bottomRecord _ rowProxy = insert bottom tail
10294 where
103- key = reflectSymbol (Proxy :: Proxy key )
104- insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
105- tail = bottomRecord (Proxy :: Proxy rowlistTail ) rowProxy
106-
107- instance boundedRecord
108- :: ( RL.RowToList row list
109- , BoundedRecord list row row
110- )
111- => Bounded (Record row ) where
95+ key = reflectSymbol (Proxy :: Proxy key )
96+ insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
97+ tail = bottomRecord (Proxy :: Proxy rowlistTail ) rowProxy
98+
99+ instance boundedRecord ::
100+ ( RL.RowToList row list
101+ , BoundedRecord list row row
102+ ) =>
103+ Bounded (Record row ) where
112104 top = topRecord (Proxy :: Proxy list ) (Proxy :: Proxy row )
113105 bottom = bottomRecord (Proxy :: Proxy list ) (Proxy :: Proxy row )
0 commit comments