Skip to content

Ports purescript-proxy into this repo #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add kind signatures to record type classes to remove warnings
  • Loading branch information
JordanMartinez committed Oct 6, 2020
commit fa7d8d2b49b9f1cb277dbedee9cd6e24f61c4fcf
1 change: 1 addition & 0 deletions src/Data/BooleanAlgebra.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ instance booleanAlgebraProxy3 :: BooleanAlgebra (Proxy3 a)

-- | A class for records where all fields have `BooleanAlgebra` instances, used
-- | to implement the `BooleanAlgebra` instance for records.
class BooleanAlgebraRecord :: RL.RowList Type -> Row Type -> Row Type -> Constraint
class HeytingAlgebraRecord rowlist row subrow <= BooleanAlgebraRecord rowlist row subrow | rowlist -> subrow

instance booleanAlgebraRecordNil :: BooleanAlgebraRecord RL.Nil row ()
Expand Down
5 changes: 2 additions & 3 deletions src/Data/Bounded.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ module Data.Bounded
) where

import Data.Ord (class Ord, class OrdRecord, Ordering(..), compare, (<), (<=), (>), (>=))
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Unit (Unit, unit)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeSet)
import Type.Data.Row (RProxy(..))
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..))

-- | The `Bounded` type class represents totally ordered types that have an
Expand Down Expand Up @@ -75,6 +73,7 @@ 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
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Eq.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ module Data.Eq
) where

import Data.HeytingAlgebra ((&&))
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Unit (Unit)
import Data.Void (Void)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeGet)
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2, Proxy3)

-- | The `Eq` type class represents types which support decidable equality.
Expand Down Expand Up @@ -94,6 +93,7 @@ notEq1 x y = (x `eq1` y) == false

-- | A class for records where all fields have `Eq` instances, used to implement
-- | 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

Expand Down
5 changes: 2 additions & 3 deletions src/Data/HeytingAlgebra.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ module Data.HeytingAlgebra
, class HeytingAlgebraRecord, ffRecord, ttRecord, impliesRecord, conjRecord, disjRecord, notRecord
) where

import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Unit (Unit, unit)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeGet, unsafeSet)
import Type.Data.Row (RProxy(..))
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..))

-- | The `HeytingAlgebra` type class represents types that are bounded lattices with
Expand Down Expand Up @@ -110,6 +108,7 @@ foreign import boolNot :: Boolean -> Boolean

-- | A class for records where all fields have `HeytingAlgebra` instances, used
-- | 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
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Ord.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ module Data.Ord
) where

import Data.Eq (class Eq, class Eq1, class EqRecord, (/=))
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Ordering (Ordering(..))
import Data.Ring (class Ring, zero, one, negate)
import Data.Unit (Unit)
import Data.Void (Void)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeGet)
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2, Proxy3)

-- | The `Ord` type class represents types which support comparisons with a
Expand Down Expand Up @@ -224,6 +223,7 @@ class Eq1 f <= Ord1 f where
instance ord1Array :: Ord1 Array where
compare1 = compare

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

Expand Down
4 changes: 2 additions & 2 deletions src/Data/Ring.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ module Data.Ring
) where

import Data.Semiring (class Semiring, class SemiringRecord, add, mul, one, zero, (*), (+))
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Unit (Unit, unit)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeGet, unsafeSet)
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..))

-- | The `Ring` class is for types that support addition, multiplication,
Expand Down Expand Up @@ -58,6 +57,7 @@ foreign import numSub :: Number -> Number -> Number

-- | A class for records where all fields have `Ring` instances, used to
-- | 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

Expand Down
4 changes: 2 additions & 2 deletions src/Data/Semigroup.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ module Data.Semigroup
, class SemigroupRecord, appendRecord
) where

import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Unit (Unit, unit)
import Data.Void (Void, absurd)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeGet, unsafeSet)
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..))

-- | The `Semigroup` type class identifies an associative operation on a type.
Expand Down Expand Up @@ -66,6 +65,7 @@ foreign import concatArray :: forall a. Array a -> Array a -> Array a

-- | A class for records where all fields have `Semigroup` instances, used to
-- | 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

Expand Down
5 changes: 2 additions & 3 deletions src/Data/Semiring.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ module Data.Semiring
, class SemiringRecord, addRecord, mulRecord, oneRecord, zeroRecord
) where

import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Unit (Unit, unit)
import Prim.Row as Row
import Prim.RowList as RL
import Record.Unsafe (unsafeGet, unsafeSet)
import Type.Data.Row (RProxy(..))
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2(..), Proxy3(..))

-- | The `Semiring` class is for types that support an addition and
Expand Down Expand Up @@ -97,6 +95,7 @@ foreign import numMul :: Number -> Number -> Number

-- | A class for records where all fields have `Semiring` instances, used to
-- | 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
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Show.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module Data.Show
, class ShowRecordFields, showRecordFields
) where

import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Prim.RowList as RL
import Record.Unsafe (unsafeGet)
import Type.Data.RowList (RLProxy(..))
import Type.Proxy (Proxy(..), Proxy2, Proxy3)

-- | The `Show` type class represents those types which can be converted into
Expand Down