@@ -7,13 +7,12 @@ module Data.Bounded
77 ) where
88
99import Data.Ord (class Ord , class OrdRecord , Ordering (..), compare , (<), (<=), (>), (>=))
10- import Data.Symbol (class IsSymbol , SProxy (..), reflectSymbol )
10+ import Data.Symbol (class IsSymbol , reflectSymbol )
1111import Data.Unit (Unit , unit )
1212import Prim.Row as Row
1313import Prim.RowList as RL
1414import Record.Unsafe (unsafeSet )
15- import Type.Data.Row (RProxy (..))
16- import Type.Data.RowList (RLProxy (..))
15+ import Type.Proxy (Proxy (..), Proxy2 (..), Proxy3 (..))
1716
1817-- | The `Bounded` type class represents totally ordered types that have an
1918-- | upper and lower boundary.
@@ -62,9 +61,22 @@ instance boundedNumber :: Bounded Number where
6261 top = topNumber
6362 bottom = bottomNumber
6463
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
6577class 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
6880
6981instance boundedRecordNil :: BoundedRecord RL.Nil row () where
7082 topRecord _ _ = {}
@@ -81,21 +93,21 @@ instance boundedRecordCons
8193 topRecord _ rowProxy
8294 = insert top tail
8395 where
84- key = reflectSymbol (SProxy :: SProxy key )
96+ key = reflectSymbol (Proxy :: Proxy key )
8597 insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
86- tail = topRecord (RLProxy :: RLProxy rowlistTail ) rowProxy
98+ tail = topRecord (Proxy :: Proxy rowlistTail ) rowProxy
8799
88100 bottomRecord _ rowProxy
89101 = insert bottom tail
90102 where
91- key = reflectSymbol (SProxy :: SProxy key )
103+ key = reflectSymbol (Proxy :: Proxy key )
92104 insert = unsafeSet key :: focus -> Record subrowTail -> Record subrow
93- tail = bottomRecord (RLProxy :: RLProxy rowlistTail ) rowProxy
105+ tail = bottomRecord (Proxy :: Proxy rowlistTail ) rowProxy
94106
95107instance boundedRecord
96108 :: ( RL.RowToList row list
97109 , BoundedRecord list row row
98110 )
99111 => 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