Skip to content

Update to v0.14.0-rc2 #63

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 20 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dd61999
Make library compile on polykinds PR
JordanMartinez Jan 30, 2020
aa22055
Make `RowApply` polymorphic in its kinds
JordanMartinez Jan 30, 2020
53e0bff
Add polymorphic type application in original and reversed forms
JordanMartinez Jan 30, 2020
768c4e1
Fix compiler warnings
JordanMartinez Feb 12, 2020
827c858
Revert 'Row Type' back to '# Type'; clarify situation
JordanMartinez Feb 12, 2020
aca1e8c
Merge remote-tracking branch 'origin/fixCompilerWarnings' into update…
JordanMartinez Oct 8, 2020
0e5f71a
Remove dependency on proxy
JordanMartinez Oct 8, 2020
d123826
Update dependencies to master
JordanMartinez Oct 8, 2020
c1645f3
Update TAG to v0.14.0-rc2
JordanMartinez Oct 8, 2020
0deb116
Update purescript-psa to v0.8.0
JordanMartinez Oct 11, 2020
ddf3ad5
Use explicit kind signatures rather than kind annotations
JordanMartinez Oct 15, 2020
3c7058b
Use Proxy where it doesn't cause breaking changes
JordanMartinez Oct 15, 2020
12ee9b9
Use forall proxy solution
JordanMartinez Oct 15, 2020
69473a4
Add kind signatures rather than annotations for BProxy; use Proxy
JordanMartinez Oct 15, 2020
96e5223
Use Constraint, not Type
JordanMartinez Oct 15, 2020
147df8e
Fix typo
JordanMartinez Oct 15, 2020
1d33254
Only refer to Prim.Ordering entities via PO prefix
JordanMartinez Oct 15, 2020
52297b2
Add deprecation notice to kind-specific proxies
JordanMartinez Oct 15, 2020
87f7f22
Remove unicode syntax
JordanMartinez Oct 17, 2020
48c3154
Port APPLY and FLIP to Type.Function
JordanMartinez Oct 17, 2020
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ node_js: stable
env:
- PATH=$HOME/purescript:$PATH
install:
- TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
# - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
- TAG=v0.14.0-rc2
- curl --location --output $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
- chmod a+x $HOME/purescript
Expand Down
5 changes: 2 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"package.json"
],
"dependencies": {
"purescript-proxy": "^3.0.0",
"purescript-prelude": "^4.1.0",
"purescript-type-equality": "^3.0.0"
"purescript-prelude": "master",
"purescript-type-equality": "master"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"devDependencies": {
"pulp": "^15.0.0",
"purescript-psa": "^0.6.0",
"purescript-psa": "^0.8.0",
"rimraf": "^2.6.2"
}
}
41 changes: 18 additions & 23 deletions src/Type/Data/Boolean.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,57 @@ module Type.Data.Boolean
, if_
) where

import Prim.Boolean (kind Boolean, True, False)
import Prim.Boolean (True, False)
import Type.Proxy (Proxy(..))

-- | Value proxy for `Boolean` types
data BProxy (bool :: Boolean) = BProxy
-- | **Deprecated:** Use `Type.Proxy` instead
data BProxy :: Boolean -> Type
data BProxy bool = BProxy

-- | Class for reflecting a type level `Boolean` at the value level
class IsBoolean (bool :: Boolean) where
reflectBoolean :: BProxy bool -> Boolean
class IsBoolean :: Boolean -> Constraint
class IsBoolean bool where
reflectBoolean :: forall proxy. proxy bool -> Boolean

instance isBooleanTrue :: IsBoolean True where reflectBoolean _ = true
instance isBooleanFalse :: IsBoolean False where reflectBoolean _ = false

-- | Use a value level `Boolean` as a type-level `Boolean`
reifyBoolean :: forall r. Boolean -> (forall o. IsBoolean o => BProxy o -> r) -> r
reifyBoolean true f = f (BProxy :: BProxy True)
reifyBoolean false f = f (BProxy :: BProxy False)
reifyBoolean :: forall r. Boolean -> (forall proxy o. IsBoolean o => proxy o -> r) -> r
reifyBoolean true f = f (Proxy :: Proxy True)
reifyBoolean false f = f (Proxy :: Proxy False)

-- | And two `Boolean` types together
class And (lhs :: Boolean)
(rhs :: Boolean)
(output :: Boolean) |
lhs rhs -> output
class And :: Boolean -> Boolean -> Boolean -> Constraint
class And lhs rhs out | lhs rhs -> out
instance andTrue :: And True rhs rhs
instance andFalse :: And False rhs False

and :: forall l r o. And l r o => BProxy l -> BProxy r -> BProxy o
and _ _ = BProxy

-- | Or two `Boolean` types together
class Or (lhs :: Boolean)
(rhs :: Boolean)
(output :: Boolean) |
lhs rhs -> output
class Or :: Boolean -> Boolean -> Boolean -> Constraint
class Or lhs rhs output | lhs rhs -> output
instance orTrue :: Or True rhs True
instance orFalse :: Or False rhs rhs

or :: forall l r o. Or l r o => BProxy l -> BProxy r -> BProxy o
or _ _ = BProxy

-- | Not a `Boolean`
class Not (bool :: Boolean)
(output :: Boolean) |
bool -> output
class Not :: Boolean -> Boolean -> Constraint
class Not bool output | bool -> output
instance notTrue :: Not True False
instance notFalse :: Not False True

not :: forall i o. Not i o => BProxy i -> BProxy o
not _ = BProxy

-- | If - dispatch based on a boolean
class If (bool :: Boolean)
(onTrue :: Type)
(onFalse :: Type)
(output :: Type) |
bool onTrue onFalse -> output
class If :: forall k. Boolean -> k -> k -> k -> Constraint
class If bool onTrue onFalse output | bool onTrue onFalse -> output
instance ifTrue :: If True onTrue onFalse onTrue
instance ifFalse :: If False onTrue onFalse onFalse

Expand Down
78 changes: 38 additions & 40 deletions src/Type/Data/Ordering.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Type.Data.Ordering
( module Prim.Ordering
( module PO
, OProxy(..)
, class IsOrdering
, reflectOrdering
Expand All @@ -12,66 +12,64 @@ module Type.Data.Ordering
, equals
) where

import Prim.Ordering (kind Ordering, LT, EQ, GT)
import Prim.Ordering (LT, EQ, GT, Ordering) as PO
import Data.Ordering (Ordering(..))
import Type.Data.Boolean (kind Boolean, True, False, BProxy(..))
import Type.Data.Boolean (True, False, BProxy(..))
import Type.Proxy (Proxy(..))

-- | Value proxy for `Ordering` types
data OProxy (ordering :: Ordering) = OProxy
-- | **Deprecated:** Use `Type.Proxy` instead
data OProxy :: PO.Ordering -> Type
data OProxy ordering = OProxy

-- | Class for reflecting a type level `Ordering` at the value level
class IsOrdering (ordering :: Ordering) where
reflectOrdering :: OProxy ordering -> Ordering
class IsOrdering :: PO.Ordering -> Constraint
class IsOrdering ordering where
reflectOrdering :: forall proxy. proxy ordering -> Ordering

instance isOrderingLT :: IsOrdering LT where reflectOrdering _ = LT
instance isOrderingEQ :: IsOrdering EQ where reflectOrdering _ = EQ
instance isOrderingGT :: IsOrdering GT where reflectOrdering _ = GT
instance isOrderingLT :: IsOrdering PO.LT where reflectOrdering _ = LT
instance isOrderingEQ :: IsOrdering PO.EQ where reflectOrdering _ = EQ
instance isOrderingGT :: IsOrdering PO.GT where reflectOrdering _ = GT

-- | Use a value level `Ordering` as a type-level `Ordering`
reifyOrdering :: forall r. Ordering -> (forall o. IsOrdering o => OProxy o -> r) -> r
reifyOrdering LT f = f (OProxy :: OProxy LT)
reifyOrdering EQ f = f (OProxy :: OProxy EQ)
reifyOrdering GT f = f (OProxy :: OProxy GT)
reifyOrdering :: forall r. Ordering -> (forall proxy o. IsOrdering o => proxy o -> r) -> r
reifyOrdering LT f = f (Proxy :: Proxy PO.LT)
reifyOrdering EQ f = f (Proxy :: Proxy PO.EQ)
reifyOrdering GT f = f (Proxy :: Proxy PO.GT)

-- | Append two `Ordering` types together
-- | Reflective of the semigroup for value level `Ordering`
class Append (lhs :: Ordering)
(rhs :: Ordering)
(output :: Ordering) |
lhs -> rhs output
instance appendOrderingLT :: Append LT rhs LT
instance appendOrderingEQ :: Append EQ rhs rhs
instance appendOrderingGT :: Append GT rhs GT
class Append :: PO.Ordering -> PO.Ordering -> PO.Ordering -> Constraint
class Append lhs rhs output | lhs -> rhs output
instance appendOrderingLT :: Append PO.LT rhs PO.LT
instance appendOrderingEQ :: Append PO.EQ rhs rhs
instance appendOrderingGT :: Append PO.GT rhs PO.GT

append :: forall l r o. Append l r o => OProxy l -> OProxy r -> OProxy o
append _ _ = OProxy

-- | Invert an `Ordering`
class Invert (ordering :: Ordering)
(result :: Ordering) |
ordering -> result
instance invertOrderingLT :: Invert LT GT
instance invertOrderingEQ :: Invert EQ EQ
instance invertOrderingGT :: Invert GT LT
class Invert :: PO.Ordering -> PO.Ordering -> Constraint
class Invert ordering result | ordering -> result
instance invertOrderingLT :: Invert PO.LT PO.GT
instance invertOrderingEQ :: Invert PO.EQ PO.EQ
instance invertOrderingGT :: Invert PO.GT PO.LT

invert :: forall i o. Invert i o => OProxy i -> OProxy o
invert _ = OProxy

class Equals (lhs :: Ordering)
(rhs :: Ordering)
(out :: Boolean) |
lhs rhs -> out
class Equals :: PO.Ordering -> PO.Ordering -> Boolean -> Constraint
class Equals lhs rhs out | lhs rhs -> out

instance equalsEQEQ :: Equals EQ EQ True
instance equalsLTLT :: Equals LT LT True
instance equalsGTGT :: Equals GT GT True
instance equalsEQLT :: Equals EQ LT False
instance equalsEQGT :: Equals EQ GT False
instance equalsLTEQ :: Equals LT EQ False
instance equalsLTGT :: Equals LT GT False
instance equalsGTLT :: Equals GT LT False
instance equalsGTEQ :: Equals GT EQ False
instance equalsEQEQ :: Equals PO.EQ PO.EQ True
instance equalsLTLT :: Equals PO.LT PO.LT True
instance equalsGTGT :: Equals PO.GT PO.GT True
instance equalsEQLT :: Equals PO.EQ PO.LT False
instance equalsEQGT :: Equals PO.EQ PO.GT False
instance equalsLTEQ :: Equals PO.LT PO.EQ False
instance equalsLTGT :: Equals PO.LT PO.GT False
instance equalsGTLT :: Equals PO.GT PO.LT False
instance equalsGTEQ :: Equals PO.GT PO.EQ False

equals :: forall l r o. Equals l r o => OProxy l -> OProxy r -> BProxy o
equals _ _ = BProxy

9 changes: 3 additions & 6 deletions src/Type/Data/Symbol.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Prim.Symbol (class Append, class Compare, class Cons)
import Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol)
import Type.Data.Ordering (OProxy(..), EQ)
import Type.Data.Ordering (class Equals) as Ordering
import Type.Data.Boolean (kind Boolean, BProxy(..))
import Type.Data.Boolean (BProxy(..))

compare :: forall l r o. Compare l r o => SProxy l -> SProxy r -> OProxy o
compare _ _ = OProxy
Expand All @@ -23,10 +23,8 @@ append _ _ = SProxy
uncons :: forall h t s. Cons h t s => SProxy s -> {head :: SProxy h, tail :: SProxy t}
uncons _ = {head : SProxy, tail : SProxy}

class Equals (lhs :: Symbol)
(rhs :: Symbol)
(out :: Boolean) |
lhs rhs -> out
class Equals :: Symbol -> Symbol -> Boolean -> Constraint
class Equals lhs rhs out | lhs rhs -> out

instance equalsSymbol
:: (Compare lhs rhs ord,
Expand All @@ -35,4 +33,3 @@ instance equalsSymbol

equals :: forall l r o. Equals l r o => SProxy l -> SProxy r -> BProxy o
equals _ _ = BProxy

28 changes: 28 additions & 0 deletions src/Type/Function.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Type.Function where

-- | Polymorphic Type application
-- |
-- | For example...
-- | ```
-- | APPLY Maybe Int == Maybe $ Int == Maybe Int
-- | ```
type APPLY :: forall a b. (a -> b) -> a -> b
type APPLY f a = f a

infixr 0 type APPLY as $

-- | Reversed polymorphic Type application
-- |
-- | For example...
-- | ```
-- | FLIP Int Maybe == Maybe Int
-- | ```
-- | Note: an infix for FLIP (e.g. `Int # Maybe`) is not allowed.
-- | Before the `0.14.0` release, we used `# Type` to refer to a row of types.
-- | In the `0.14.0` release, the `# Type` syntax was deprecated,
-- | and `Row Type` is the correct way to do this now. To help mitigate
-- | breakage, `# Type` was made an alias to `Row Type`. When the `# Type`
-- | syntax is fully dropped in a later language release, we can then
-- | support the infix version: `Int # Maybe`.
type FLIP :: forall a b. a -> (a -> b) -> b
type FLIP a f = f a
4 changes: 2 additions & 2 deletions src/Type/Prelude.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module Type.Prelude
, module Type.RowList
) where

import Type.Data.Boolean (kind Boolean, True, False, BProxy(..), class IsBoolean, reflectBoolean, reifyBoolean)
import Type.Data.Ordering (kind Ordering, LT, EQ, GT, OProxy(..), class IsOrdering, reflectOrdering, reifyOrdering)
import Type.Data.Boolean (True, False, BProxy(..), class IsBoolean, reflectBoolean, reifyBoolean)
import Type.Data.Ordering (Ordering, LT, EQ, GT, OProxy(..), class IsOrdering, reflectOrdering, reifyOrdering)
import Type.Proxy (Proxy(..))
import Type.Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol, class Compare, compare, class Append, append)
import Type.Equality (class TypeEquals, from, to)
Expand Down
3 changes: 2 additions & 1 deletion src/Type/Row.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Prim.Row (class Lacks, class Nub, class Cons, class Union)
import Type.Data.Row (RProxy(..)) as RProxy

-- | Type application for rows.
type RowApply (f :: # Type -> # Type) (a :: # Type) = f a
type RowApply :: forall k. (Row k -> Row k) -> Row k -> Row k
type RowApply f a = f a

-- | Applies a type alias of open rows to a set of rows. The primary use case
-- | this operator is as convenient sugar for combining open rows without
Expand Down
8 changes: 5 additions & 3 deletions src/Type/Row/Homogeneous.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ module Type.Row.Homogeneous
) where

import Type.Equality (class TypeEquals)
import Type.RowList (class RowToList, Cons, Nil, kind RowList)
import Type.RowList (class RowToList, Cons, Nil, RowList)

-- | Ensure that every field in a row has the same type.
class Homogeneous (row :: # Type) fieldType | row -> fieldType
class Homogeneous :: forall k. Row k -> k -> Constraint
class Homogeneous row fieldType | row -> fieldType
instance homogeneous
:: ( RowToList row fields
, HomogeneousRowList fields fieldType )
=> Homogeneous row fieldType

class HomogeneousRowList (rowList :: RowList) fieldType | rowList -> fieldType
class HomogeneousRowList :: forall k. RowList k -> k -> Constraint
class HomogeneousRowList rowList fieldType | rowList -> fieldType
instance homogeneousRowListCons
:: ( HomogeneousRowList tail fieldType
, TypeEquals fieldType fieldType2 )
Expand Down
31 changes: 11 additions & 20 deletions src/Type/RowList.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Type.RowList
) where

import Prim.Row as Row
import Prim.RowList (kind RowList, Cons, Nil, class RowToList)
import Prim.RowList (RowList, Cons, Nil, class RowToList)
import Type.Equality (class TypeEquals)
import Type.Data.Symbol as Symbol
import Type.Data.Boolean as Boolean
Expand All @@ -18,9 +18,8 @@ import Type.Data.RowList (RLProxy(..)) as RLProxy

-- | Convert a RowList to a row of types.
-- | The inverse of this operation is `RowToList`.
class ListToRow (list :: RowList)
(row :: # Type) |
list -> row
class ListToRow :: forall k. RowList k -> Row k -> Constraint
class ListToRow list row | list -> row

instance listToRowNil
:: ListToRow Nil ()
Expand All @@ -31,10 +30,8 @@ instance listToRowCons
=> ListToRow (Cons label ty tail) row

-- | Remove all occurences of a given label from a RowList
class RowListRemove (label :: Symbol)
(input :: RowList)
(output :: RowList)
| label input -> output
class RowListRemove :: forall k. Symbol -> RowList k -> RowList k -> Constraint
class RowListRemove label input output | label input -> output

instance rowListRemoveNil
:: RowListRemove label Nil Nil
Expand All @@ -50,11 +47,8 @@ instance rowListRemoveCons
=> RowListRemove label (Cons key head tail) output

-- | Add a label to a RowList after removing other occurences.
class RowListSet (label :: Symbol)
(typ :: Type)
(input :: RowList)
(output :: RowList)
| label typ input -> output
class RowListSet :: forall k. Symbol -> k -> RowList k -> RowList k -> Constraint
class RowListSet label typ input output | label typ input -> output

instance rowListSetImpl
:: ( TypeEquals (Symbol.SProxy label) (Symbol.SProxy label')
Expand All @@ -63,9 +57,8 @@ instance rowListSetImpl
=> RowListSet label typ input (Cons label' typ' lacking)

-- | Remove label duplicates, keeps earlier occurrences.
class RowListNub (input :: RowList)
(output :: RowList)
| input -> output
class RowListNub :: forall k. RowList k -> RowList k -> Constraint
class RowListNub input output | input -> output

instance rowListNubNil
:: RowListNub Nil Nil
Expand All @@ -79,10 +72,8 @@ instance rowListNubCons
=> RowListNub (Cons label head tail) (Cons label' head' nubbed')

-- Append two row lists together
class RowListAppend (lhs :: RowList)
(rhs :: RowList)
(out :: RowList)
| lhs rhs -> out
class RowListAppend :: forall k. RowList k -> RowList k -> RowList k -> Constraint
class RowListAppend lhs rhs out | lhs rhs -> out

instance rowListAppendNil
:: TypeEquals (RLProxy rhs) (RLProxy out)
Expand Down