Skip to content

Commit 7aeb599

Browse files
authored
Merge pull request #38 from purescript/compiler/0.12
Update for PureScript 0.12
2 parents 5502856 + cb426c5 commit 7aeb599

File tree

9 files changed

+81
-135
lines changed

9 files changed

+81
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ package-lock.json
55
/bower_components/
66
/node_modules/
77
/output/
8+
package-lock.json

LICENSE

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
The MIT License (MIT)
1+
Copyright 2018 PureScript
22

3-
Copyright (c) 2016 PureScript
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
45

5-
Permission is hereby granted, free of charge, to any person obtaining a copy of
6-
this software and associated documentation files (the "Software"), to deal in
7-
the Software without restriction, including without limitation the rights to
8-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9-
the Software, and to permit persons to whom the Software is furnished to do so,
10-
subject to the following conditions:
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
118

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation and/or
11+
other materials provided with the distribution.
1412

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
3. Neither the name of the copyright holder nor the names of its contributors
14+
may be used to endorse or promote products derived from this software without
15+
specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "purescript-typelevel-prelude",
33
"homepage": "https://github.com/purescript/purescript-typelevel-prelude",
44
"description": "Types and kinds for basic type-level programming",
5-
"license": "MIT",
5+
"license": "BSD-3-Clause",
66
"repository": {
77
"type": "git",
88
"url": "git://github.com/purescript/purescript-typelevel-prelude.git"
@@ -16,8 +16,8 @@
1616
"package.json"
1717
],
1818
"dependencies": {
19-
"purescript-proxy": "^2.0.0",
20-
"purescript-symbols": "^3.0.0",
21-
"purescript-type-equality": "^2.0.0"
19+
"purescript-proxy": "^3.0.0",
20+
"purescript-prelude": "^4.0.0",
21+
"purescript-type-equality": "^3.0.0"
2222
}
2323
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"build": "pulp build -- --censor-lib --strict"
66
},
77
"devDependencies": {
8-
"pulp": "^10.0.4",
9-
"purescript-psa": "^0.5.0-rc.1",
10-
"rimraf": "^2.6.1"
8+
"pulp": "^12.2.0",
9+
"purescript-psa": "^0.6.0",
10+
"rimraf": "^2.6.2"
1111
}
1212
}

src/Type/Data/Ordering.purs

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
module Type.Data.Ordering
2-
( kind Ordering
3-
, LT
4-
, EQ
5-
, GT
2+
( module Prim.Ordering
63
, OProxy(..)
74
, class IsOrdering
85
, reflectOrdering
96
, reifyOrdering
10-
, class AppendOrdering
11-
, appendOrdering
12-
, class InvertOrdering
13-
, invertOrdering
7+
, class Append
8+
, append
9+
, class Invert
10+
, invert
1411
, class Equals
1512
, equals
1613
) where
1714

15+
import Prim.Ordering (kind Ordering, LT, EQ, GT)
1816
import Data.Ordering (Ordering(..))
1917
import Type.Data.Boolean (kind Boolean, True, False, BProxy(..))
2018

21-
foreign import kind Ordering
22-
foreign import data LT :: Ordering
23-
foreign import data EQ :: Ordering
24-
foreign import data GT :: Ordering
25-
2619
-- | Value proxy for `Ordering` types
2720
data OProxy (ordering :: Ordering) = OProxy
2821

@@ -42,27 +35,27 @@ reifyOrdering GT f = f (OProxy :: OProxy GT)
4235

4336
-- | Append two `Ordering` types together
4437
-- | Reflective of the semigroup for value level `Ordering`
45-
class AppendOrdering (lhs :: Ordering)
46-
(rhs :: Ordering)
47-
(output :: Ordering) |
48-
lhs -> rhs output
49-
instance appendOrderingLT :: AppendOrdering LT rhs LT
50-
instance appendOrderingEQ :: AppendOrdering EQ rhs rhs
51-
instance appendOrderingGT :: AppendOrdering GT rhs GT
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
5245

53-
appendOrdering :: forall l r o. AppendOrdering l r o => OProxy l -> OProxy r -> OProxy o
54-
appendOrdering _ _ = OProxy
46+
append :: forall l r o. Append l r o => OProxy l -> OProxy r -> OProxy o
47+
append _ _ = OProxy
5548

5649
-- | Invert an `Ordering`
57-
class InvertOrdering (ordering :: Ordering)
58-
(result :: Ordering) |
59-
ordering -> result
60-
instance invertOrderingLT :: InvertOrdering LT GT
61-
instance invertOrderingEQ :: InvertOrdering EQ EQ
62-
instance invertOrderingGT :: InvertOrdering GT LT
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
6356

64-
invertOrdering :: forall i o. InvertOrdering i o => OProxy i -> OProxy o
65-
invertOrdering _ = OProxy
57+
invert :: forall i o. Invert i o => OProxy i -> OProxy o
58+
invert _ = OProxy
6659

6760
class Equals (lhs :: Ordering)
6861
(rhs :: Ordering)

src/Type/Data/Symbol.purs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
11
module Type.Data.Symbol
2-
( module Data.Symbol
3-
, class CompareSymbol
4-
, compareSymbol
5-
, class AppendSymbol
6-
, appendSymbol
2+
( module Prim.Symbol
3+
, module Data.Symbol
4+
, append
5+
, compare
6+
, uncons
77
, class Equals
88
, equals
99
) where
1010

11+
import Prim.Symbol (class Append, class Compare, class Cons)
1112
import Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol)
1213
import Type.Data.Ordering (OProxy(..), kind Ordering, EQ)
1314
import Type.Data.Ordering (class Equals) as Ordering
1415
import Type.Data.Boolean (kind Boolean, BProxy(..))
1516

16-
-- | Compare two `Symbol` types
17-
class CompareSymbol (lhs :: Symbol)
18-
(rhs :: Symbol)
19-
(out :: Ordering) |
20-
lhs rhs -> out
17+
compare :: forall l r o. Compare l r o => SProxy l -> SProxy r -> OProxy o
18+
compare _ _ = OProxy
2119

22-
compareSymbol :: forall l r o. CompareSymbol l r o => SProxy l -> SProxy r -> OProxy o
23-
compareSymbol _ _ = OProxy
20+
append :: forall l r o. Append l r o => SProxy l -> SProxy r -> SProxy o
21+
append _ _ = SProxy
2422

25-
26-
-- | Append two `Symbol` types together
27-
class AppendSymbol (lhs :: Symbol)
28-
(rhs :: Symbol)
29-
(out :: Symbol) |
30-
lhs rhs -> out
31-
32-
appendSymbol :: forall l r o. AppendSymbol l r o => SProxy l -> SProxy r -> SProxy o
33-
appendSymbol _ _ = SProxy
23+
uncons :: forall h t s. Cons h t s => SProxy s -> {head :: SProxy h, tail :: SProxy t}
24+
uncons _ = {head : SProxy, tail : SProxy}
3425

3526
class Equals (lhs :: Symbol)
3627
(rhs :: Symbol)
3728
(out :: Boolean) |
3829
lhs rhs -> out
3930

4031
instance equalsSymbol
41-
:: (CompareSymbol lhs rhs ord,
32+
:: (Compare lhs rhs ord,
4233
Ordering.Equals EQ ord out)
4334
=> Equals lhs rhs out
4435

src/Type/Prelude.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Type.Prelude
1010
import Type.Data.Boolean (kind Boolean, True, False, BProxy(..), class IsBoolean, reflectBoolean, reifyBoolean)
1111
import Type.Data.Ordering (kind Ordering, LT, EQ, GT, OProxy(..), class IsOrdering, reflectOrdering, reifyOrdering)
1212
import Type.Proxy (Proxy(..))
13-
import Type.Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol, class CompareSymbol, compareSymbol, class AppendSymbol, appendSymbol)
13+
import Type.Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol, reifySymbol, class Compare, compare, class Append, append)
1414
import Type.Equality (class TypeEquals, from, to)
15-
import Type.Row (class RowLacks, class RowToList, class ListToRow, RProxy(..), RLProxy(..))
15+
import Type.Row (class Union, class Lacks, class RowToList, class ListToRow, RProxy(..), RLProxy(..))
1616

src/Type/Row.purs

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
module Type.Row
22
( RProxy(..)
3-
, class RowLacks
4-
, class RowLacking
5-
, kind RowList
6-
, Nil
7-
, Cons
3+
, module Prim.Row
4+
, module Prim.RowList
85
, RLProxy(..)
9-
, class RowToList
106
, class ListToRow
117
, class RowListRemove
128
, class RowListSet
@@ -16,57 +12,16 @@ module Type.Row
1612
, type (+)
1713
) where
1814

15+
import Prim.Row (class Lacks, class Nub, class Cons, class Union)
16+
import Prim.RowList (kind RowList, Cons, Nil, class RowToList)
1917
import Type.Equality (class TypeEquals)
2018
import Type.Data.Symbol as Symbol
2119
import Type.Data.Boolean as Boolean
2220

2321
data RProxy (row :: # Type) = RProxy
2422

25-
-- Must not be exported
26-
foreign import data Entry :: Type
27-
28-
-- | If you get "No type class instance was found" for this class, then your
29-
-- | `row` shouldn't contain the label `key`.
30-
class RowLacking (entry :: Type)
31-
(key :: Symbol)
32-
(typ :: Type)
33-
(row :: # Type) |
34-
entry typ -> key row
35-
36-
instance rowLacking :: RowLacking entry key entry row
37-
38-
-- | Encodes the constraint that a given row does not contain a specific key.
39-
class RowLacks (key :: Symbol)
40-
(row :: # Type)
41-
42-
-- Append `Entry` at label `key` to the right of `row` then lookup `key` on the
43-
-- left - if we check via instance solving that the `typ` we get back is
44-
-- `Entry`, then `row` lacks `key`. In the case that `row` doesn't lack
45-
-- `key`, we get a "No type class instance found" error for:
46-
-- `RowLacking Entry key typ row`.
47-
instance rowLacks
48-
:: ( RowCons key Entry () keyEntry
49-
, Union row keyEntry rowKeyEntry
50-
, RowCons key typ ignored rowKeyEntry
51-
, RowLacking Entry key typ row )
52-
=> RowLacks key row
53-
54-
55-
-- | A type-level list representation of a row
56-
foreign import kind RowList
57-
foreign import data Nil :: RowList
58-
foreign import data Cons :: Symbol -> Type -> RowList -> RowList
59-
6023
data RLProxy (rowList :: RowList) = RLProxy
6124

62-
-- | Extract the collection of entries in a closed row of types.
63-
-- | The list of entries is sorted by label and preserves duplicates.
64-
-- | The inverse of this operation is `ListToRow`.
65-
-- | Solved by the compiler.
66-
class RowToList (row :: # Type)
67-
(list :: RowList) |
68-
row -> list
69-
7025
-- | Convert a RowList to a row of types.
7126
-- | The inverse of this operation is `RowToList`.
7227
class ListToRow (list :: RowList)
@@ -76,9 +31,9 @@ class ListToRow (list :: RowList)
7631
instance listToRowNil
7732
:: ListToRow Nil ()
7833

79-
instance listToRowCons
34+
instance listToCons
8035
:: ( ListToRow tail tailRow
81-
, RowCons label ty tailRow row )
36+
, Cons label ty tailRow row )
8237
=> ListToRow (Cons label ty tail) row
8338

8439
-- | Remove all occurences of a given label from a RowList

src/Type/Row/Homogeneous.purs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Type.Row.Homogeneous
22
( class Homogeneous
3-
, class HomogenousRowList
3+
, class HomogeneousRowList
44
) where
55

66
import Type.Equality (class TypeEquals)
@@ -10,12 +10,12 @@ import Type.Row (class RowToList, Cons, Nil, kind RowList)
1010
class Homogeneous (row :: # Type) fieldType | row -> fieldType
1111
instance homogeneous
1212
:: ( RowToList row fields
13-
, HomogenousRowList fields fieldType )
13+
, HomogeneousRowList fields fieldType )
1414
=> Homogeneous row fieldType
1515

16-
class HomogenousRowList (rowList :: RowList) fieldType | rowList -> fieldType
17-
instance homogenousRowListCons
18-
:: ( HomogenousRowList tail fieldType
16+
class HomogeneousRowList (rowList :: RowList) fieldType | rowList -> fieldType
17+
instance homogeneousRowListCons
18+
:: ( HomogeneousRowList tail fieldType
1919
, TypeEquals fieldType fieldType2 )
20-
=> HomogenousRowList (Cons symbol fieldType tail) fieldType2
21-
instance homogenousRowListNil :: HomogenousRowList Nil fieldType
20+
=> HomogeneousRowList (Cons symbol fieldType tail) fieldType2
21+
instance homogeneousRowListNil :: HomogeneousRowList Nil fieldType

0 commit comments

Comments
 (0)