Skip to content

Commit 4c9182d

Browse files
authored
Merge pull request #63 from JordanMartinez/updateTo14
Update to v0.14.0-rc2
2 parents f202d4e + 48c3154 commit 4c9182d

File tree

11 files changed

+112
-100
lines changed

11 files changed

+112
-100
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ node_js: stable
55
env:
66
- PATH=$HOME/purescript:$PATH
77
install:
8-
- TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
8+
# - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
9+
- TAG=v0.14.0-rc2
910
- curl --location --output $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
1011
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
1112
- chmod a+x $HOME/purescript

bower.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"package.json"
1717
],
1818
"dependencies": {
19-
"purescript-proxy": "^3.0.0",
20-
"purescript-prelude": "^4.1.0",
21-
"purescript-type-equality": "^3.0.0"
19+
"purescript-prelude": "master",
20+
"purescript-type-equality": "master"
2221
}
2322
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"devDependencies": {
88
"pulp": "^15.0.0",
9-
"purescript-psa": "^0.6.0",
9+
"purescript-psa": "^0.8.0",
1010
"rimraf": "^2.6.2"
1111
}
1212
}

src/Type/Data/Boolean.purs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,57 @@ module Type.Data.Boolean
1414
, if_
1515
) where
1616

17-
import Prim.Boolean (kind Boolean, True, False)
17+
import Prim.Boolean (True, False)
1818
import Type.Proxy (Proxy(..))
1919

2020
-- | Value proxy for `Boolean` types
21-
data BProxy (bool :: Boolean) = BProxy
21+
-- | **Deprecated:** Use `Type.Proxy` instead
22+
data BProxy :: Boolean -> Type
23+
data BProxy bool = BProxy
2224

2325
-- | Class for reflecting a type level `Boolean` at the value level
24-
class IsBoolean (bool :: Boolean) where
25-
reflectBoolean :: BProxy bool -> Boolean
26+
class IsBoolean :: Boolean -> Constraint
27+
class IsBoolean bool where
28+
reflectBoolean :: forall proxy. proxy bool -> Boolean
2629

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

3033
-- | Use a value level `Boolean` as a type-level `Boolean`
31-
reifyBoolean :: forall r. Boolean -> (forall o. IsBoolean o => BProxy o -> r) -> r
32-
reifyBoolean true f = f (BProxy :: BProxy True)
33-
reifyBoolean false f = f (BProxy :: BProxy False)
34+
reifyBoolean :: forall r. Boolean -> (forall proxy o. IsBoolean o => proxy o -> r) -> r
35+
reifyBoolean true f = f (Proxy :: Proxy True)
36+
reifyBoolean false f = f (Proxy :: Proxy False)
3437

3538
-- | And two `Boolean` types together
36-
class And (lhs :: Boolean)
37-
(rhs :: Boolean)
38-
(output :: Boolean) |
39-
lhs rhs -> output
39+
class And :: Boolean -> Boolean -> Boolean -> Constraint
40+
class And lhs rhs out | lhs rhs -> out
4041
instance andTrue :: And True rhs rhs
4142
instance andFalse :: And False rhs False
4243

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

4647
-- | Or two `Boolean` types together
47-
class Or (lhs :: Boolean)
48-
(rhs :: Boolean)
49-
(output :: Boolean) |
50-
lhs rhs -> output
48+
class Or :: Boolean -> Boolean -> Boolean -> Constraint
49+
class Or lhs rhs output | lhs rhs -> output
5150
instance orTrue :: Or True rhs True
5251
instance orFalse :: Or False rhs rhs
5352

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

5756
-- | Not a `Boolean`
58-
class Not (bool :: Boolean)
59-
(output :: Boolean) |
60-
bool -> output
57+
class Not :: Boolean -> Boolean -> Constraint
58+
class Not bool output | bool -> output
6159
instance notTrue :: Not True False
6260
instance notFalse :: Not False True
6361

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

6765
-- | If - dispatch based on a boolean
68-
class If (bool :: Boolean)
69-
(onTrue :: Type)
70-
(onFalse :: Type)
71-
(output :: Type) |
72-
bool onTrue onFalse -> output
66+
class If :: forall k. Boolean -> k -> k -> k -> Constraint
67+
class If bool onTrue onFalse output | bool onTrue onFalse -> output
7368
instance ifTrue :: If True onTrue onFalse onTrue
7469
instance ifFalse :: If False onTrue onFalse onFalse
7570

src/Type/Data/Ordering.purs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Type.Data.Ordering
2-
( module Prim.Ordering
2+
( module PO
33
, OProxy(..)
44
, class IsOrdering
55
, reflectOrdering
@@ -12,66 +12,64 @@ module Type.Data.Ordering
1212
, equals
1313
) where
1414

15-
import Prim.Ordering (kind Ordering, LT, EQ, GT)
15+
import Prim.Ordering (LT, EQ, GT, Ordering) as PO
1616
import Data.Ordering (Ordering(..))
17-
import Type.Data.Boolean (kind Boolean, True, False, BProxy(..))
17+
import Type.Data.Boolean (True, False, BProxy(..))
18+
import Type.Proxy (Proxy(..))
1819

1920
-- | Value proxy for `Ordering` types
20-
data OProxy (ordering :: Ordering) = OProxy
21+
-- | **Deprecated:** Use `Type.Proxy` instead
22+
data OProxy :: PO.Ordering -> Type
23+
data OProxy ordering = OProxy
2124

2225
-- | Class for reflecting a type level `Ordering` at the value level
23-
class IsOrdering (ordering :: Ordering) where
24-
reflectOrdering :: OProxy ordering -> Ordering
26+
class IsOrdering :: PO.Ordering -> Constraint
27+
class IsOrdering ordering where
28+
reflectOrdering :: forall proxy. proxy ordering -> Ordering
2529

26-
instance isOrderingLT :: IsOrdering LT where reflectOrdering _ = LT
27-
instance isOrderingEQ :: IsOrdering EQ where reflectOrdering _ = EQ
28-
instance isOrderingGT :: IsOrdering GT where reflectOrdering _ = GT
30+
instance isOrderingLT :: IsOrdering PO.LT where reflectOrdering _ = LT
31+
instance isOrderingEQ :: IsOrdering PO.EQ where reflectOrdering _ = EQ
32+
instance isOrderingGT :: IsOrdering PO.GT where reflectOrdering _ = GT
2933

3034
-- | Use a value level `Ordering` as a type-level `Ordering`
31-
reifyOrdering :: forall r. Ordering -> (forall o. IsOrdering o => OProxy o -> r) -> r
32-
reifyOrdering LT f = f (OProxy :: OProxy LT)
33-
reifyOrdering EQ f = f (OProxy :: OProxy EQ)
34-
reifyOrdering GT f = f (OProxy :: OProxy GT)
35+
reifyOrdering :: forall r. Ordering -> (forall proxy o. IsOrdering o => proxy o -> r) -> r
36+
reifyOrdering LT f = f (Proxy :: Proxy PO.LT)
37+
reifyOrdering EQ f = f (Proxy :: Proxy PO.EQ)
38+
reifyOrdering GT f = f (Proxy :: Proxy PO.GT)
3539

3640
-- | Append two `Ordering` types together
3741
-- | Reflective of the semigroup for value level `Ordering`
38-
class Append (lhs :: Ordering)
39-
(rhs :: Ordering)
40-
(output :: Ordering) |
41-
lhs -> rhs output
42-
instance appendOrderingLT :: Append LT rhs LT
43-
instance appendOrderingEQ :: Append EQ rhs rhs
44-
instance appendOrderingGT :: Append GT rhs GT
42+
class Append :: PO.Ordering -> PO.Ordering -> PO.Ordering -> Constraint
43+
class Append lhs rhs output | lhs -> rhs output
44+
instance appendOrderingLT :: Append PO.LT rhs PO.LT
45+
instance appendOrderingEQ :: Append PO.EQ rhs rhs
46+
instance appendOrderingGT :: Append PO.GT rhs PO.GT
4547

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

4951
-- | Invert an `Ordering`
50-
class Invert (ordering :: Ordering)
51-
(result :: Ordering) |
52-
ordering -> result
53-
instance invertOrderingLT :: Invert LT GT
54-
instance invertOrderingEQ :: Invert EQ EQ
55-
instance invertOrderingGT :: Invert GT LT
52+
class Invert :: PO.Ordering -> PO.Ordering -> Constraint
53+
class Invert ordering result | ordering -> result
54+
instance invertOrderingLT :: Invert PO.LT PO.GT
55+
instance invertOrderingEQ :: Invert PO.EQ PO.EQ
56+
instance invertOrderingGT :: Invert PO.GT PO.LT
5657

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

60-
class Equals (lhs :: Ordering)
61-
(rhs :: Ordering)
62-
(out :: Boolean) |
63-
lhs rhs -> out
61+
class Equals :: PO.Ordering -> PO.Ordering -> Boolean -> Constraint
62+
class Equals lhs rhs out | lhs rhs -> out
6463

65-
instance equalsEQEQ :: Equals EQ EQ True
66-
instance equalsLTLT :: Equals LT LT True
67-
instance equalsGTGT :: Equals GT GT True
68-
instance equalsEQLT :: Equals EQ LT False
69-
instance equalsEQGT :: Equals EQ GT False
70-
instance equalsLTEQ :: Equals LT EQ False
71-
instance equalsLTGT :: Equals LT GT False
72-
instance equalsGTLT :: Equals GT LT False
73-
instance equalsGTEQ :: Equals GT EQ False
64+
instance equalsEQEQ :: Equals PO.EQ PO.EQ True
65+
instance equalsLTLT :: Equals PO.LT PO.LT True
66+
instance equalsGTGT :: Equals PO.GT PO.GT True
67+
instance equalsEQLT :: Equals PO.EQ PO.LT False
68+
instance equalsEQGT :: Equals PO.EQ PO.GT False
69+
instance equalsLTEQ :: Equals PO.LT PO.EQ False
70+
instance equalsLTGT :: Equals PO.LT PO.GT False
71+
instance equalsGTLT :: Equals PO.GT PO.LT False
72+
instance equalsGTEQ :: Equals PO.GT PO.EQ False
7473

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

src/Type/Data/Symbol.purs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Prim.Symbol (class Append, class Compare, class Cons)
1212
import Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol)
1313
import Type.Data.Ordering (OProxy(..), EQ)
1414
import Type.Data.Ordering (class Equals) as Ordering
15-
import Type.Data.Boolean (kind Boolean, BProxy(..))
15+
import Type.Data.Boolean (BProxy(..))
1616

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

26-
class Equals (lhs :: Symbol)
27-
(rhs :: Symbol)
28-
(out :: Boolean) |
29-
lhs rhs -> out
26+
class Equals :: Symbol -> Symbol -> Boolean -> Constraint
27+
class Equals lhs rhs out | lhs rhs -> out
3028

3129
instance equalsSymbol
3230
:: (Compare lhs rhs ord,
@@ -35,4 +33,3 @@ instance equalsSymbol
3533

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

src/Type/Function.purs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Type.Function where
2+
3+
-- | Polymorphic Type application
4+
-- |
5+
-- | For example...
6+
-- | ```
7+
-- | APPLY Maybe Int == Maybe $ Int == Maybe Int
8+
-- | ```
9+
type APPLY :: forall a b. (a -> b) -> a -> b
10+
type APPLY f a = f a
11+
12+
infixr 0 type APPLY as $
13+
14+
-- | Reversed polymorphic Type application
15+
-- |
16+
-- | For example...
17+
-- | ```
18+
-- | FLIP Int Maybe == Maybe Int
19+
-- | ```
20+
-- | Note: an infix for FLIP (e.g. `Int # Maybe`) is not allowed.
21+
-- | Before the `0.14.0` release, we used `# Type` to refer to a row of types.
22+
-- | In the `0.14.0` release, the `# Type` syntax was deprecated,
23+
-- | and `Row Type` is the correct way to do this now. To help mitigate
24+
-- | breakage, `# Type` was made an alias to `Row Type`. When the `# Type`
25+
-- | syntax is fully dropped in a later language release, we can then
26+
-- | support the infix version: `Int # Maybe`.
27+
type FLIP :: forall a b. a -> (a -> b) -> b
28+
type FLIP a f = f a

src/Type/Prelude.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module Type.Prelude
88
, module Type.RowList
99
) where
1010

11-
import Type.Data.Boolean (kind Boolean, True, False, BProxy(..), class IsBoolean, reflectBoolean, reifyBoolean)
12-
import Type.Data.Ordering (kind Ordering, LT, EQ, GT, OProxy(..), class IsOrdering, reflectOrdering, reifyOrdering)
11+
import Type.Data.Boolean (True, False, BProxy(..), class IsBoolean, reflectBoolean, reifyBoolean)
12+
import Type.Data.Ordering (Ordering, LT, EQ, GT, OProxy(..), class IsOrdering, reflectOrdering, reifyOrdering)
1313
import Type.Proxy (Proxy(..))
1414
import Type.Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol, class Compare, compare, class Append, append)
1515
import Type.Equality (class TypeEquals, from, to)

src/Type/Row.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import Prim.Row (class Lacks, class Nub, class Cons, class Union)
99
import Type.Data.Row (RProxy(..)) as RProxy
1010

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

1415
-- | Applies a type alias of open rows to a set of rows. The primary use case
1516
-- | this operator is as convenient sugar for combining open rows without

src/Type/Row/Homogeneous.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ module Type.Row.Homogeneous
44
) where
55

66
import Type.Equality (class TypeEquals)
7-
import Type.RowList (class RowToList, Cons, Nil, kind RowList)
7+
import Type.RowList (class RowToList, Cons, Nil, RowList)
88

99
-- | Ensure that every field in a row has the same type.
10-
class Homogeneous (row :: # Type) fieldType | row -> fieldType
10+
class Homogeneous :: forall k. Row k -> k -> Constraint
11+
class Homogeneous row fieldType | row -> fieldType
1112
instance homogeneous
1213
:: ( RowToList row fields
1314
, HomogeneousRowList fields fieldType )
1415
=> Homogeneous row fieldType
1516

16-
class HomogeneousRowList (rowList :: RowList) fieldType | rowList -> fieldType
17+
class HomogeneousRowList :: forall k. RowList k -> k -> Constraint
18+
class HomogeneousRowList rowList fieldType | rowList -> fieldType
1719
instance homogeneousRowListCons
1820
:: ( HomogeneousRowList tail fieldType
1921
, TypeEquals fieldType fieldType2 )

src/Type/RowList.purs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Type.RowList
99
) where
1010

1111
import Prim.Row as Row
12-
import Prim.RowList (kind RowList, Cons, Nil, class RowToList)
12+
import Prim.RowList (RowList, Cons, Nil, class RowToList)
1313
import Type.Equality (class TypeEquals)
1414
import Type.Data.Symbol as Symbol
1515
import Type.Data.Boolean as Boolean
@@ -18,9 +18,8 @@ import Type.Data.RowList (RLProxy(..)) as RLProxy
1818

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

2524
instance listToRowNil
2625
:: ListToRow Nil ()
@@ -31,10 +30,8 @@ instance listToRowCons
3130
=> ListToRow (Cons label ty tail) row
3231

3332
-- | Remove all occurences of a given label from a RowList
34-
class RowListRemove (label :: Symbol)
35-
(input :: RowList)
36-
(output :: RowList)
37-
| label input -> output
33+
class RowListRemove :: forall k. Symbol -> RowList k -> RowList k -> Constraint
34+
class RowListRemove label input output | label input -> output
3835

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

5249
-- | Add a label to a RowList after removing other occurences.
53-
class RowListSet (label :: Symbol)
54-
(typ :: Type)
55-
(input :: RowList)
56-
(output :: RowList)
57-
| label typ input -> output
50+
class RowListSet :: forall k. Symbol -> k -> RowList k -> RowList k -> Constraint
51+
class RowListSet label typ input output | label typ input -> output
5852

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

6559
-- | Remove label duplicates, keeps earlier occurrences.
66-
class RowListNub (input :: RowList)
67-
(output :: RowList)
68-
| input -> output
60+
class RowListNub :: forall k. RowList k -> RowList k -> Constraint
61+
class RowListNub input output | input -> output
6962

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

8174
-- Append two row lists together
82-
class RowListAppend (lhs :: RowList)
83-
(rhs :: RowList)
84-
(out :: RowList)
85-
| lhs rhs -> out
75+
class RowListAppend :: forall k. RowList k -> RowList k -> RowList k -> Constraint
76+
class RowListAppend lhs rhs out | lhs rhs -> out
8677

8778
instance rowListAppendNil
8879
:: TypeEquals (RLProxy rhs) (RLProxy out)

0 commit comments

Comments
 (0)