From 31b327406659af17612c926d85f388bb9a848a18 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:06:27 -0700 Subject: [PATCH 1/9] Drop deprecated SProxy --- src/Data/Symbol.purs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Data/Symbol.purs b/src/Data/Symbol.purs index 619b178e..fb2fd4e6 100644 --- a/src/Data/Symbol.purs +++ b/src/Data/Symbol.purs @@ -2,16 +2,10 @@ module Data.Symbol ( class IsSymbol , reflectSymbol , reifySymbol - , SProxy(..) ) where import Type.Proxy (Proxy(..)) --- | A value-level proxy for a type-level symbol. --- | **Deprecated as of v0.14.0 PureScript release**: use `Type.Proxy` instead. -data SProxy :: Symbol -> Type -data SProxy sym = SProxy - -- | A class for known symbols class IsSymbol (sym :: Symbol) where -- Note: Before v0.14.0, we did not have polykinds. Thus, we needed @@ -21,14 +15,14 @@ class IsSymbol (sym :: Symbol) where -- `forall proxy. proxy sym` here so that `SProxy` code will still compile. -- When PureScript makes a new breaking release after the v0.14.0 release, -- this type signature will be updated to `Proxy sym -> String`. - reflectSymbol :: forall proxy. proxy sym -> String + reflectSymbol :: Proxy sym -> String -- local definition for use in `reifySymbol` foreign import unsafeCoerce :: forall a b. a -> b -reifySymbol :: forall proxy r. String -> (forall sym. IsSymbol sym => proxy sym -> r) -> r +reifySymbol :: forall r. String -> (forall sym. IsSymbol sym => Proxy sym -> r) -> r reifySymbol s f = coerce f { reflectSymbol: \_ -> s } Proxy where coerce - :: (forall sym1. IsSymbol sym1 => proxy sym1 -> r) + :: (forall sym1. IsSymbol sym1 => Proxy sym1 -> r) -> { reflectSymbol :: Proxy "" -> String } -> Proxy "" -> r coerce = unsafeCoerce From 49550fbee81114d33b97a27e1d7b98de1ef5b93c Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:06:55 -0700 Subject: [PATCH 2/9] Update changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e937eb..133b4678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: - Migrated FFI to ES Modules (#287 by @kl0tl and @JordanMartinez) +- Replaced polymorphic proxies with monomorphic `Proxy` (#287 by @kl0tl and @JordanMartinez) New features: From e54ec0608e64942c527ca39776ffe7ae5da88a46 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:07:24 -0700 Subject: [PATCH 3/9] Remove RProxy and RLProxy --- src/Type/Data/Row.purs | 22 ---------------------- src/Type/Data/RowList.purs | 8 -------- 2 files changed, 30 deletions(-) delete mode 100644 src/Type/Data/Row.purs delete mode 100644 src/Type/Data/RowList.purs diff --git a/src/Type/Data/Row.purs b/src/Type/Data/Row.purs deleted file mode 100644 index f3f022c5..00000000 --- a/src/Type/Data/Row.purs +++ /dev/null @@ -1,22 +0,0 @@ -module Type.Data.Row where - --- | A proxy data type whose type parameter is a type of kind `Row Type` (a row --- | of types). --- | --- | **Deprecated as of v0.14.0 PureScript release**: use `Type.Proxy` instead. --- | --- | Commonly used for specialising a function with a quantified type. --- | For example, suppose we have an identity function for records of type: --- | ```purescript --- | recordIdentity :: forall row . RProxy row -> Record row -> Record row --- | recordIdentity _ rec = rec --- | ``` --- | Then applying this function to an `RProxy` with a specialised type --- | allows us to specify a concrete type for `row`: --- | ```purescript --- | :t recordIdentity (Proxy :: Proxy ( x :: Int, y :: Int )) --- | { x :: Int, y :: Int } -> { x :: Int, y :: Int } --- | ``` --- | Here `row` has been specialised to `( x :: Int, y :: Int )`. -data RProxy :: Row Type -> Type -data RProxy row = RProxy diff --git a/src/Type/Data/RowList.purs b/src/Type/Data/RowList.purs deleted file mode 100644 index 21bd48af..00000000 --- a/src/Type/Data/RowList.purs +++ /dev/null @@ -1,8 +0,0 @@ -module Type.Data.RowList where - -import Prim.RowList (RowList) - --- | A proxy to carry information about a rowlist. --- | **Deprecated as of v0.14.0 PureScript release**: use `Type.Proxy` instead. -data RLProxy :: RowList Type -> Type -data RLProxy rowlist = RLProxy From 460348cf24e5359b755ea787efa4d1e69db76164 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:08:37 -0700 Subject: [PATCH 4/9] Drop Proxy2 and Proxy3 --- src/Type/Proxy.purs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Type/Proxy.purs b/src/Type/Proxy.purs index 879316fa..a3782fdd 100644 --- a/src/Type/Proxy.purs +++ b/src/Type/Proxy.purs @@ -51,12 +51,3 @@ module Type.Proxy where -- | Proxy type for all `kind`s. data Proxy :: forall k. k -> Type data Proxy a = Proxy - --- | Value proxy for kind `Type -> Type` types. --- | **Deprecated as of v0.14.0 PureScript release**: use `Proxy` instead. -data Proxy2 :: (Type -> Type) -> Type -data Proxy2 f = Proxy2 - --- | Value proxy for kind `Type -> Type -> Type` types. --- | **Deprecated as of v0.14.0 PureScript release**: use `Proxy` instead. -data Proxy3 (a :: Type -> Type -> Type) = Proxy3 From 73a195eb7fdb97370ec67290bbcf9c5092c0cd85 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:08:58 -0700 Subject: [PATCH 5/9] Remove forall proxy workaround comment --- src/Data/Symbol.purs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Data/Symbol.purs b/src/Data/Symbol.purs index fb2fd4e6..2c273079 100644 --- a/src/Data/Symbol.purs +++ b/src/Data/Symbol.purs @@ -8,13 +8,6 @@ import Type.Proxy (Proxy(..)) -- | A class for known symbols class IsSymbol (sym :: Symbol) where - -- Note: Before v0.14.0, we did not have polykinds. Thus, we needed - -- kind-specific proxy types to pass a Symbol around. - -- Once v0.14.0 was released, we could use the kind-generic `Proxy` type - -- instead. However, to reduce code breakage, we're using - -- `forall proxy. proxy sym` here so that `SProxy` code will still compile. - -- When PureScript makes a new breaking release after the v0.14.0 release, - -- this type signature will be updated to `Proxy sym -> String`. reflectSymbol :: Proxy sym -> String -- local definition for use in `reifySymbol` From 7245414210730c8d0bdb20e203623c416ec2e6e5 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:09:34 -0700 Subject: [PATCH 6/9] Drop Proxy2/Proxy3 show instances --- src/Data/Show.purs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Data/Show.purs b/src/Data/Show.purs index 33442378..4b029784 100644 --- a/src/Data/Show.purs +++ b/src/Data/Show.purs @@ -6,7 +6,7 @@ module Data.Show import Data.Symbol (class IsSymbol, reflectSymbol) import Prim.RowList as RL import Record.Unsafe (unsafeGet) -import Type.Proxy (Proxy(..), Proxy2, Proxy3) +import Type.Proxy (Proxy(..)) -- | The `Show` type class represents those types which can be converted into -- | a human-readable `String` representation. @@ -39,12 +39,6 @@ instance showArray :: Show a => Show (Array a) where instance showProxy :: Show (Proxy a) where show _ = "Proxy" -instance showProxy2 :: Show (Proxy2 a) where - show _ = "Proxy2" - -instance showProxy3 :: Show (Proxy3 a) where - show _ = "Proxy3" - instance showRecord :: (RL.RowToList rs ls, ShowRecordFields ls rs) => Show (Record rs) where show record = case showRecordFields (Proxy :: Proxy ls) record of [] -> "{}" From b02aebb6ca1ea76f7f66180c1cf8f1e7839d3043 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:10:05 -0700 Subject: [PATCH 7/9] Fix another forall proxy workaround --- src/Data/Show.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Show.purs b/src/Data/Show.purs index 4b029784..6b490b9e 100644 --- a/src/Data/Show.purs +++ b/src/Data/Show.purs @@ -48,7 +48,7 @@ instance showRecord :: (RL.RowToList rs ls, ShowRecordFields ls rs) => Show (Rec -- | implement the `Show` instance for records. class ShowRecordFields :: RL.RowList Type -> Row Type -> Constraint class ShowRecordFields rowlist row where - showRecordFields :: forall rlproxy. rlproxy rowlist -> Record row -> Array String + showRecordFields :: Proxy rowlist -> Record row -> Array String instance showRecordFieldsNil :: ShowRecordFields RL.Nil row where showRecordFields _ _ = [] From 95146fb67185dcf7febc36e34b802bb928dfae9b Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:18:10 -0700 Subject: [PATCH 8/9] Drop Proxy2/3 instances, forall proxy workaround --- src/Control/Bind.purs | 8 +------- src/Data/BooleanAlgebra.purs | 4 +--- src/Data/Bounded.purs | 14 +++----------- src/Data/CommutativeRing.purs | 4 +--- src/Data/Eq.purs | 10 ++-------- src/Data/HeytingAlgebra.purs | 30 +++++++----------------------- src/Data/Monoid.purs | 2 +- src/Data/Ord.purs | 10 ++-------- src/Data/Ring.purs | 10 ++-------- src/Data/Semigroup.purs | 10 ++-------- src/Data/Semiring.purs | 22 +++++----------------- 11 files changed, 27 insertions(+), 97 deletions(-) diff --git a/src/Control/Bind.purs b/src/Control/Bind.purs index 09d61615..22a10719 100644 --- a/src/Control/Bind.purs +++ b/src/Control/Bind.purs @@ -18,7 +18,7 @@ import Control.Category (identity) import Data.Function (flip) import Data.Functor (class Functor, map, void, ($>), (<#>), (<$), (<$>)) import Data.Unit (Unit) -import Type.Proxy (Proxy(..), Proxy2, Proxy3) +import Type.Proxy (Proxy(..)) -- | The `Bind` type class extends the [`Apply`](#apply) type class with a -- | "bind" operation `(>>=)` which composes computations in sequence, using @@ -107,12 +107,6 @@ instance discardUnit :: Discard Unit where instance discardProxy :: Discard (Proxy a) where discard = bind -instance discardProxy2 :: Discard (Proxy2 a) where - discard = bind - -instance discardProxy3 :: Discard (Proxy3 a) where - discard = bind - -- | Collapse two applications of a monadic type constructor into one. join :: forall a m. Bind m => m (m a) -> m a join m = m >>= identity diff --git a/src/Data/BooleanAlgebra.purs b/src/Data/BooleanAlgebra.purs index acc3617e..04efe151 100644 --- a/src/Data/BooleanAlgebra.purs +++ b/src/Data/BooleanAlgebra.purs @@ -9,7 +9,7 @@ import Data.Symbol (class IsSymbol) import Data.Unit (Unit) import Prim.Row as Row import Prim.RowList as RL -import Type.Proxy (Proxy, Proxy2, Proxy3) +import Type.Proxy (Proxy) -- | The `BooleanAlgebra` type class represents types that behave like boolean -- | values. @@ -26,8 +26,6 @@ instance booleanAlgebraUnit :: BooleanAlgebra Unit instance booleanAlgebraFn :: BooleanAlgebra b => BooleanAlgebra (a -> b) instance booleanAlgebraRecord :: (RL.RowToList row list, BooleanAlgebraRecord list row row) => BooleanAlgebra (Record row) instance booleanAlgebraProxy :: BooleanAlgebra (Proxy a) -instance booleanAlgebraProxy2 :: BooleanAlgebra (Proxy2 a) -instance booleanAlgebraProxy3 :: BooleanAlgebra (Proxy3 a) -- | A class for records where all fields have `BooleanAlgebra` instances, used -- | to implement the `BooleanAlgebra` instance for records. diff --git a/src/Data/Bounded.purs b/src/Data/Bounded.purs index d28fe45e..82f8cc32 100644 --- a/src/Data/Bounded.purs +++ b/src/Data/Bounded.purs @@ -12,7 +12,7 @@ import Data.Unit (Unit, unit) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeSet) -import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) +import Type.Proxy (Proxy(..)) -- | The `Bounded` type class represents totally ordered types that have an -- | upper and lower boundary. @@ -65,18 +65,10 @@ instance boundedProxy :: Bounded (Proxy a) where bottom = Proxy top = Proxy -instance boundedProxy2 :: Bounded (Proxy2 a) where - bottom = Proxy2 - top = Proxy2 - -instance boundedProxy3 :: Bounded (Proxy3 a) where - bottom = Proxy3 - top = Proxy3 - class BoundedRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint class OrdRecord rowlist row <= BoundedRecord rowlist row subrow | rowlist -> subrow where - topRecord :: forall rlproxy rproxy. rlproxy rowlist -> rproxy row -> Record subrow - bottomRecord :: forall rlproxy rproxy. rlproxy rowlist -> rproxy row -> Record subrow + topRecord :: Proxy rowlist -> Proxy row -> Record subrow + bottomRecord :: Proxy rowlist -> Proxy row -> Record subrow instance boundedRecordNil :: BoundedRecord RL.Nil row () where topRecord _ _ = {} diff --git a/src/Data/CommutativeRing.purs b/src/Data/CommutativeRing.purs index 12e8c5d3..d4c0c23b 100644 --- a/src/Data/CommutativeRing.purs +++ b/src/Data/CommutativeRing.purs @@ -11,7 +11,7 @@ import Data.Symbol (class IsSymbol) import Data.Unit (Unit) import Prim.Row as Row import Prim.RowList as RL -import Type.Proxy (Proxy, Proxy2, Proxy3) +import Type.Proxy (Proxy) -- | The `CommutativeRing` class is for rings where multiplication is -- | commutative. @@ -28,8 +28,6 @@ instance commutativeRingUnit :: CommutativeRing Unit instance commutativeRingFn :: CommutativeRing b => CommutativeRing (a -> b) instance commutativeRingRecord :: (RL.RowToList row list, CommutativeRingRecord list row row) => CommutativeRing (Record row) instance commutativeRingProxy :: CommutativeRing (Proxy a) -instance commutativeRingProxy2 :: CommutativeRing (Proxy2 a) -instance commutativeRingProxy3 :: CommutativeRing (Proxy3 a) -- | A class for records where all fields have `CommutativeRing` instances, used -- | to implement the `CommutativeRing` instance for records. diff --git a/src/Data/Eq.purs b/src/Data/Eq.purs index 9452da1f..8e3ab99a 100644 --- a/src/Data/Eq.purs +++ b/src/Data/Eq.purs @@ -11,7 +11,7 @@ import Data.Void (Void) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeGet) -import Type.Proxy (Proxy(..), Proxy2, Proxy3) +import Type.Proxy (Proxy(..)) -- | The `Eq` type class represents types which support decidable equality. -- | @@ -67,12 +67,6 @@ instance eqRec :: (RL.RowToList row list, EqRecord list row) => Eq (Record row) instance eqProxy :: Eq (Proxy a) where eq _ _ = true -instance eqProxy2 :: Eq (Proxy2 a) where - eq _ _ = true - -instance eqProxy3 :: Eq (Proxy3 a) where - eq _ _ = true - foreign import eqBooleanImpl :: Boolean -> Boolean -> Boolean foreign import eqIntImpl :: Int -> Int -> Boolean foreign import eqNumberImpl :: Number -> Number -> Boolean @@ -95,7 +89,7 @@ notEq1 x y = (x `eq1` y) == false -- | the `Eq` instance for records. class EqRecord :: RL.RowList Type -> Row Type -> Constraint class EqRecord rowlist row where - eqRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Boolean + eqRecord :: Proxy rowlist -> Record row -> Record row -> Boolean instance eqRowNil :: EqRecord RL.Nil row where eqRecord _ _ _ = true diff --git a/src/Data/HeytingAlgebra.purs b/src/Data/HeytingAlgebra.purs index 0d4dca48..b48f12e9 100644 --- a/src/Data/HeytingAlgebra.purs +++ b/src/Data/HeytingAlgebra.purs @@ -8,7 +8,7 @@ import Data.Unit (Unit, unit) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeGet, unsafeSet) -import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) +import Type.Proxy (Proxy(..)) -- | The `HeytingAlgebra` type class represents types that are bounded lattices with -- | an implication operator such that the following laws hold: @@ -78,22 +78,6 @@ instance heytingAlgebraProxy :: HeytingAlgebra (Proxy a) where not _ = Proxy tt = Proxy -instance heytingAlgebraProxy2 :: HeytingAlgebra (Proxy2 a) where - conj _ _ = Proxy2 - disj _ _ = Proxy2 - implies _ _ = Proxy2 - ff = Proxy2 - not _ = Proxy2 - tt = Proxy2 - -instance heytingAlgebraProxy3 :: HeytingAlgebra (Proxy3 a) where - conj _ _ = Proxy3 - disj _ _ = Proxy3 - implies _ _ = Proxy3 - ff = Proxy3 - not _ = Proxy3 - tt = Proxy3 - instance heytingAlgebraRecord :: (RL.RowToList row list, HeytingAlgebraRecord list row row) => HeytingAlgebra (Record row) where ff = ffRecord (Proxy :: Proxy list) (Proxy :: Proxy row) tt = ttRecord (Proxy :: Proxy list) (Proxy :: Proxy row) @@ -110,12 +94,12 @@ foreign import boolNot :: Boolean -> Boolean -- | to implement the `HeytingAlgebra` instance for records. class HeytingAlgebraRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint class HeytingAlgebraRecord rowlist row subrow | rowlist -> subrow where - ffRecord :: forall rlproxy rproxy. rlproxy rowlist -> rproxy row -> Record subrow - ttRecord :: forall rlproxy rproxy. rlproxy rowlist -> rproxy row -> Record subrow - impliesRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow - disjRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow - conjRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow - notRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record subrow + ffRecord :: Proxy rowlist -> Proxy row -> Record subrow + ttRecord :: Proxy rowlist -> Proxy row -> Record subrow + impliesRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow + disjRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow + conjRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow + notRecord :: Proxy rowlist -> Record row -> Record subrow instance heytingAlgebraRecordNil :: HeytingAlgebraRecord RL.Nil row () where conjRecord _ _ _ = {} diff --git a/src/Data/Monoid.purs b/src/Data/Monoid.purs index 101b0076..7dc47eff 100644 --- a/src/Data/Monoid.purs +++ b/src/Data/Monoid.purs @@ -99,7 +99,7 @@ guard false _ = mempty -- | implement the `Monoid` instance for records. class MonoidRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint class SemigroupRecord rowlist row subrow <= MonoidRecord rowlist row subrow | rowlist -> row subrow where - memptyRecord :: forall rlproxy. rlproxy rowlist -> Record subrow + memptyRecord :: Proxy rowlist -> Record subrow instance monoidRecordNil :: MonoidRecord RL.Nil row () where memptyRecord _ = {} diff --git a/src/Data/Ord.purs b/src/Data/Ord.purs index c2c60ace..25e10fb1 100644 --- a/src/Data/Ord.purs +++ b/src/Data/Ord.purs @@ -24,7 +24,7 @@ import Data.Void (Void) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeGet) -import Type.Proxy (Proxy(..), Proxy2, Proxy3) +import Type.Proxy (Proxy(..)) -- | The `Ord` type class represents types which support comparisons with a -- | _total order_. @@ -64,12 +64,6 @@ instance ordVoid :: Ord Void where instance ordProxy :: Ord (Proxy a) where compare _ _ = EQ -instance ordProxy2 :: Ord (Proxy2 a) where - compare _ _ = EQ - -instance ordProxy3 :: Ord (Proxy3 a) where - compare _ _ = EQ - instance ordArray :: Ord a => Ord (Array a) where compare = \xs ys -> compare 0 (ordArrayImpl toDelta xs ys) where @@ -228,7 +222,7 @@ instance ord1Array :: Ord1 Array where class OrdRecord :: RL.RowList Type -> Row Type -> Constraint class EqRecord rowlist row <= OrdRecord rowlist row where - compareRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Ordering + compareRecord :: Proxy rowlist -> Record row -> Record row -> Ordering instance ordRecordNil :: OrdRecord RL.Nil row where compareRecord _ _ _ = EQ diff --git a/src/Data/Ring.purs b/src/Data/Ring.purs index e70d9157..855c6436 100644 --- a/src/Data/Ring.purs +++ b/src/Data/Ring.purs @@ -10,7 +10,7 @@ import Data.Unit (Unit, unit) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeGet, unsafeSet) -import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) +import Type.Proxy (Proxy(..)) -- | The `Ring` class is for types that support addition, multiplication, -- | and subtraction operations. @@ -40,12 +40,6 @@ instance ringFn :: Ring b => Ring (a -> b) where instance ringProxy :: Ring (Proxy a) where sub _ _ = Proxy -instance ringProxy2 :: Ring (Proxy2 a) where - sub _ _ = Proxy2 - -instance ringProxy3 :: Ring (Proxy3 a) where - sub _ _ = Proxy3 - instance ringRecord :: (RL.RowToList row list, RingRecord list row row) => Ring (Record row) where sub = subRecord (Proxy :: Proxy list) @@ -60,7 +54,7 @@ foreign import numSub :: Number -> Number -> Number -- | implement the `Ring` instance for records. class RingRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint class SemiringRecord rowlist row subrow <= RingRecord rowlist row subrow | rowlist -> subrow where - subRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow + subRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow instance ringRecordNil :: RingRecord RL.Nil row () where subRecord _ _ _ = {} diff --git a/src/Data/Semigroup.purs b/src/Data/Semigroup.purs index c7ee426b..141f9c14 100644 --- a/src/Data/Semigroup.purs +++ b/src/Data/Semigroup.purs @@ -9,7 +9,7 @@ import Data.Void (Void, absurd) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeGet, unsafeSet) -import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) +import Type.Proxy (Proxy(..)) -- | The `Semigroup` type class identifies an associative operation on a type. -- | @@ -51,12 +51,6 @@ instance semigroupArray :: Semigroup (Array a) where instance semigroupProxy :: Semigroup (Proxy a) where append _ _ = Proxy -instance semigroupProxy2 :: Semigroup (Proxy2 a) where - append _ _ = Proxy2 - -instance semigroupProxy3 :: Semigroup (Proxy3 a) where - append _ _ = Proxy3 - instance semigroupRecord :: (RL.RowToList row list, SemigroupRecord list row row) => Semigroup (Record row) where append = appendRecord (Proxy :: Proxy list) @@ -67,7 +61,7 @@ foreign import concatArray :: forall a. Array a -> Array a -> Array a -- | implement the `Semigroup` instance for records. class SemigroupRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint class SemigroupRecord rowlist row subrow | rowlist -> subrow where - appendRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow + appendRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow instance semigroupRecordNil :: SemigroupRecord RL.Nil row () where appendRecord _ _ _ = {} diff --git a/src/Data/Semiring.purs b/src/Data/Semiring.purs index 09250d8c..f97838e4 100644 --- a/src/Data/Semiring.purs +++ b/src/Data/Semiring.purs @@ -8,7 +8,7 @@ import Data.Unit (Unit, unit) import Prim.Row as Row import Prim.RowList as RL import Record.Unsafe (unsafeGet, unsafeSet) -import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..)) +import Type.Proxy (Proxy(..)) -- | The `Semiring` class is for types that support an addition and -- | multiplication operation. @@ -70,18 +70,6 @@ instance semiringProxy :: Semiring (Proxy a) where one = Proxy zero = Proxy -instance semiringProxy2 :: Semiring (Proxy2 a) where - add _ _ = Proxy2 - mul _ _ = Proxy2 - one = Proxy2 - zero = Proxy2 - -instance semiringProxy3 :: Semiring (Proxy3 a) where - add _ _ = Proxy3 - mul _ _ = Proxy3 - one = Proxy3 - zero = Proxy3 - instance semiringRecord :: (RL.RowToList row list, SemiringRecord list row row) => Semiring (Record row) where add = addRecord (Proxy :: Proxy list) mul = mulRecord (Proxy :: Proxy list) @@ -97,10 +85,10 @@ foreign import numMul :: Number -> Number -> Number -- | implement the `Semiring` instance for records. class SemiringRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint class SemiringRecord rowlist row subrow | rowlist -> subrow where - addRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow - mulRecord :: forall rlproxy. rlproxy rowlist -> Record row -> Record row -> Record subrow - oneRecord :: forall rlproxy rproxy. rlproxy rowlist -> rproxy row -> Record subrow - zeroRecord :: forall rlproxy rproxy. rlproxy rowlist -> rproxy row -> Record subrow + addRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow + mulRecord :: Proxy rowlist -> Record row -> Record row -> Record subrow + oneRecord :: Proxy rowlist -> Proxy row -> Record subrow + zeroRecord :: Proxy rowlist -> Proxy row -> Record subrow instance semiringRecordNil :: SemiringRecord RL.Nil row () where addRecord _ _ _ = {} From 59424561cccc1bae6dc360ebb348efc6f5da058c Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 11:27:31 -0700 Subject: [PATCH 9/9] Update rendering for proxy change --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4143f29..50ee9a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: - Migrated FFI to ES Modules (#287 by @kl0tl and @JordanMartinez) - Change Generic Rep's `NoConstructors` to newtype `Void` (#282 by @JordanMartinez) -- Replace `forall proxy. proxy k` workaound with `Proxy k` (#281, #288 by @JordanMartinez) -- Drop all kind-specific Proxy types (e.g. `Proxy2`, `Proxy3`) (#281, #288 by @JordanMartinez) +- Replaced polymorphic proxies with monomorphic `Proxy` (#281, #288 by @JordanMartinez) New features: