Skip to content

Commit 0d06e1e

Browse files
author
Serhii Khoma
committed
feat: update to purs 0.14 -> fix warning "shadowing Type/Row/Constraint type from Prim module"
1 parent 9fa3be7 commit 0d06e1e

File tree

25 files changed

+185
-185
lines changed

25 files changed

+185
-185
lines changed

src/Language/PS/CST.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Language.PS.CST
22
( module Export
33
) where
44

5-
import Language.PS.CST.Types.Declaration (AdoBlock, Binder(..), CaseOf, ClassHead, Constraint(..), DataCtor(..), DataHead(..), Declaration(..), DoStatement(..), Expr(..), FixityFields, FixityOp(..), Foreign(..), Guarded(..), GuardedExpr, IfThenElse, Instance, InstanceBinding(..), InstanceHead, Kind(..), Lambda, LetBinding(..), LetIn, PatternGuard, RecordAccessor, RecordUpdate(..), Row, Type(..), TypeVarBinding(..), ValueBindingFields, Where, (====>), (====>>), (====>>>)) as Export
5+
import Language.PS.CST.Types.Declaration (AdoBlock, Binder(..), CaseOf, ClassHead, PSConstraint(..), DataCtor(..), DataHead(..), Declaration(..), DoStatement(..), Expr(..), FixityFields, FixityOp(..), Foreign(..), Guarded(..), GuardedExpr, IfThenElse, Instance, InstanceBinding(..), InstanceHead, Kind(..), Lambda, LetBinding(..), LetIn, PatternGuard, RecordAccessor, RecordUpdate(..), PSRow, PSType(..), TypeVarBinding(..), ValueBindingFields, Where, (====>), (====>>), (====>>>)) as Export
66
import Language.PS.CST.Types.Module (DataMembers(..), Export(..), Import(..), ImportDecl(..), Module(..)) as Export
77
import Language.PS.CST.Types.QualifiedName (QualifiedName(..)) as Export
88
import Language.PS.CST.Types.Leafs (ClassFundep(..), Comments(..), DeclDeriveType(..), Fixity(..), Ident(..), Label(..), ModuleName(..), OpName(..), OpNameType_TypeOpName, OpNameType_ValueOpName, ProperName(..), ProperNameType_ClassName, ProperNameType_ConstructorName, ProperNameType_KindName, ProperNameType_Namespace, ProperNameType_TypeName, RecordLabeled(..), OpNameType, ProperNameType) as Export

src/Language/PS/CST/Printers.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Language.PS.CST.Printers.TypeLevel (printConstraint, printConstraintList,
1818
import Language.PS.CST.Printers.Utils (dot, dquotesIf, exprShouldBeOnNextLine, labelNeedsQuotes, maybeWrapInParentheses, parens, printAndConditionallyAddNewlinesBetween, printLabelledGroup, shouldBeNoNewlineBetweenDeclarations, shouldBeNoNewlineBetweenInstanceBindings, shouldBeNoNewlineBetweenLetBindings, unwrapText, (<%%>))
1919
import Language.PS.CST.ReservedNames (appendUnderscoreIfReserved, quoteIfReserved)
2020
import Language.PS.CST.Sugar.QualifiedName (nonQualifiedName)
21-
import Language.PS.CST.Types.Declaration (Binder(..), Constraint(..), DataCtor(..), DataHead(..), Declaration(..), Expr(..), FixityOp(..), Foreign(..), Guarded(..), Instance, InstanceBinding(..), InstanceHead, LetBinding(..), RecordUpdate(..), Type(..), ValueBindingFields)
21+
import Language.PS.CST.Types.Declaration (Binder(..), PSConstraint(..), DataCtor(..), DataHead(..), Declaration(..), Expr(..), FixityOp(..), Foreign(..), Guarded(..), Instance, InstanceBinding(..), InstanceHead, LetBinding(..), RecordUpdate(..), PSType(..), ValueBindingFields)
2222
import Language.PS.CST.Types.Leafs (Comments(..), DeclDeriveType(..), ProperName(..), RecordLabeled(..))
2323
import Language.PS.CST.Types.Module (Module(..))
2424

@@ -97,7 +97,7 @@ printDeclaration (DeclDerive { comments, deriveType, head: { instName, instConst
9797
, unwrapText instName
9898
]
9999

100-
instConstraint = Constraint { className: instClass
100+
instConstraint = PSConstraint { className: instClass
101101
, args: NonEmptyArray.toArray instTypes
102102
}
103103

@@ -330,7 +330,7 @@ printRecordUpdate (RecordUpdateBranch label recordUpdates) = (text <<< appendUnd
330330
printAssignmentDecl
331331
:: String
332332
-> DataHead
333-
-> Array Type
333+
-> Array PSType
334334
-> Doc Void
335335
printAssignmentDecl reservedWord (DataHead { dataHdName, dataHdVars }) types =
336336
(flexGroup $
@@ -345,14 +345,14 @@ printAssignmentDecl reservedWord (DataHead { dataHdName, dataHdVars }) types =
345345

346346
sep = spaceBreak <> text "| "
347347

348-
dataCtorToType :: DataCtor -> Type
348+
dataCtorToType :: DataCtor -> PSType
349349
dataCtorToType (DataCtor ctor) = foldl TypeApp initType ctor.dataCtorFields
350350
where
351351
initType =
352352
TypeConstructor (nonQualifiedName (coerceProperName ctor.dataCtorName))
353353

354354
-- TODO add printing of constraints
355-
instanceHeadToType :: InstanceHead -> Type
355+
instanceHeadToType :: InstanceHead -> PSType
356356
instanceHeadToType inst = foldl TypeApp initType inst.instTypes
357357
where
358358
initType = TypeConstructor (coerceProperName <$> inst.instClass)

src/Language/PS/CST/Printers/TypeLevel.purs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Dodo (Doc, alignCurrentColumn, bothNotEmpty, break, encloseEmptyAlt, flex
1313
import Dodo.Common (leadingComma)
1414
import Language.PS.CST.Printers.Utils (dquotesIf, labelNeedsQuotes, parens, printLabelledGroup, printModuleName, softSpace, unwrapText, (<%%>))
1515
import Language.PS.CST.ReservedNames (appendUnderscoreIfReserved)
16-
import Language.PS.CST.Types.Declaration (Constraint(..), Kind(..), Row, Type(..), TypeVarBinding(..))
16+
import Language.PS.CST.Types.Declaration (PSConstraint(..), Kind(..), PSRow, PSType(..), TypeVarBinding(..))
1717
import Language.PS.CST.Types.Leafs (ClassFundep(..), Fixity(..), Ident, Label(..), OpName, ProperName)
1818
import Language.PS.CST.Types.QualifiedName (QualifiedName(..))
1919

@@ -59,10 +59,10 @@ printQualifiedName_AnyOpNameType (QualifiedName qualifiedName) = case qualifiedN
5959
Nothing -> (text <<< appendUnderscoreIfReserved <<< unwrap) qualifiedName.qualName
6060
(Just moduleName) -> printModuleName moduleName <> text "." <> parens ((text <<< appendUnderscoreIfReserved <<< unwrap) qualifiedName.qualName)
6161

62-
printType :: Type -> Doc Void
62+
printType :: PSType -> Doc Void
6363
printType = printType' false
6464

65-
printType' :: Boolean -> Type -> Doc Void
65+
printType' :: Boolean -> PSType -> Doc Void
6666
printType' _ (TypeVar a) = unwrapText a
6767
printType' _ TypeWildcard = text "_"
6868
printType' _ (TypeConstructor c) = printQualifiedName_AnyProperNameType c
@@ -164,7 +164,7 @@ printType' _ (TypeOp a op b) =
164164
printType' _ (TypeConstrained c t) =
165165
printConstraint c <> spaceBreak <> text "=> " <> printType' false t
166166

167-
printRow :: String -> String -> Row -> Doc Void
167+
printRow :: String -> String -> PSRow -> Doc Void
168168
printRow open close { rowLabels, rowTail } =
169169
alignCurrentColumn $
170170
encloseEmptyAlt (text open <> space) (spaceBreak <> text close) (text (open <> close)) $
@@ -179,8 +179,8 @@ printRow open close { rowLabels, rowTail } =
179179

180180
printTl t = text "| " <> printType' false t
181181

182-
printConstraint :: Constraint -> Doc Void
183-
printConstraint (Constraint { className, args }) =
182+
printConstraint :: PSConstraint -> Doc Void
183+
printConstraint (PSConstraint { className, args }) =
184184
foldWithSeparator sep apps
185185

186186
where
@@ -199,7 +199,7 @@ printConstraint (Constraint { className, args }) =
199199

200200
sep = spaceBreak
201201

202-
printConstraintList :: NonEmptyArray Constraint -> Doc Void
202+
printConstraintList :: NonEmptyArray PSConstraint -> Doc Void
203203
printConstraintList cs =
204204
parenIf (NonEmptyArray.length cs > 1)
205205
$ foldWithSeparator leadingComma (flexGroup <<< printConstraint <$> cs)
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Language.PS.CST.Sugar.Declaration where
22

3-
import Language.PS.CST.Types.Declaration (Type(..))
3+
import Language.PS.CST.Types.Declaration (PSType(..))
44
import Language.PS.CST.Types.Leafs (ProperName(..))
55
import Language.PS.CST.Sugar.QualifiedName (nonQualifiedName)
66
import Language.PS.CST.Sugar.Leafs (mkRowLabels)
@@ -9,23 +9,23 @@ import Prelude
99
import Data.Maybe (Maybe(..))
1010
import Data.Tuple.Nested (type (/\))
1111

12-
typeRecord :: Array (String /\ Type) -> Type
12+
typeRecord :: Array (String /\ PSType) -> PSType
1313
typeRecord labels = TypeRecord { rowLabels: mkRowLabels labels, rowTail: Nothing }
1414

15-
typeRow :: Array (String /\ Type) -> Type
15+
typeRow :: Array (String /\ PSType) -> PSType
1616
typeRow labels = TypeRow { rowLabels: mkRowLabels labels, rowTail: Nothing }
1717

18-
booleanType :: Type
18+
booleanType :: PSType
1919
booleanType = TypeConstructor $ nonQualifiedName $ ProperName "Boolean"
2020

21-
numberType :: Type
21+
numberType :: PSType
2222
numberType = TypeConstructor $ nonQualifiedName $ ProperName "Number"
2323

24-
stringType :: Type
24+
stringType :: PSType
2525
stringType = TypeConstructor $ nonQualifiedName $ ProperName "String"
2626

27-
arrayType :: Type -> Type
27+
arrayType :: PSType -> PSType
2828
arrayType = TypeApp (TypeConstructor $ nonQualifiedName $ ProperName "Array")
2929

30-
maybeType :: Type -> Type
30+
maybeType :: PSType -> PSType
3131
maybeType = TypeApp (TypeConstructor $ nonQualifiedName $ ProperName "Maybe")

src/Language/PS/CST/Types/Declaration.purs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ data Declaration
2121
| DeclType
2222
{ comments :: Maybe Comments
2323
, head :: DataHead
24-
, type_ :: Type
24+
, type_ :: PSType
2525
}
2626
| DeclNewtype
2727
{ comments :: Maybe Comments
2828
, head :: DataHead
2929
, name :: ProperName ProperNameType_ConstructorName
30-
, type_ :: Type
30+
, type_ :: PSType
3131
}
3232
| DeclClass
3333
{ comments :: Maybe Comments
3434
, head :: ClassHead
35-
, methods :: Array { ident :: Ident, type_ :: Type }
35+
, methods :: Array { ident :: Ident, type_ :: PSType }
3636
}
3737
| DeclInstanceChain
3838
{ comments :: Maybe Comments
@@ -46,7 +46,7 @@ data Declaration
4646
| DeclSignature
4747
{ comments :: Maybe Comments
4848
, ident :: Ident
49-
, type_ :: Type
49+
, type_ :: PSType
5050
}
5151
| DeclValue
5252
{ comments :: Maybe Comments
@@ -68,13 +68,13 @@ instance showDeclaration :: Show Declaration where show = genericShow
6868

6969
type InstanceHead =
7070
{ instName :: Ident
71-
, instConstraints :: Array Constraint
71+
, instConstraints :: Array PSConstraint
7272
, instClass :: QualifiedName (ProperName ProperNameType_ClassName)
73-
, instTypes :: NonEmptyArray Type
73+
, instTypes :: NonEmptyArray PSType
7474
}
7575

7676
data Foreign
77-
= ForeignValue { ident :: Ident, type_ :: Type }
77+
= ForeignValue { ident :: Ident, type_ :: PSType }
7878
| ForeignData { name :: ProperName ProperNameType_TypeName, kind_ :: Kind }
7979
| ForeignKind { name :: ProperName ProperNameType_KindName }
8080

@@ -98,31 +98,31 @@ derive instance eqFixityOp :: Eq FixityOp
9898
derive instance ordFixityOp :: Ord FixityOp
9999
instance showFixityOp :: Show FixityOp where show = genericShow
100100

101-
data Type
101+
data PSType
102102
= TypeVar Ident
103103
| TypeConstructor (QualifiedName (ProperName ProperNameType_TypeName))
104104
| TypeWildcard
105105
| TypeHole Ident
106106
| TypeString String
107-
| TypeRow Row
108-
| TypeRecord Row
109-
| TypeApp Type Type
110-
| TypeForall (NonEmptyArray TypeVarBinding) Type
111-
| TypeArr Type Type
112-
| TypeKinded Type Kind
113-
| TypeOp Type (QualifiedName (OpName OpNameType_TypeOpName)) Type -- like TypeArr, but with custom type alias
114-
| TypeConstrained Constraint Type
107+
| TypeRow PSRow
108+
| TypeRecord PSRow
109+
| TypeApp PSType PSType
110+
| TypeForall (NonEmptyArray TypeVarBinding) PSType
111+
| TypeArr PSType PSType
112+
| TypeKinded PSType Kind
113+
| TypeOp PSType (QualifiedName (OpName OpNameType_TypeOpName)) PSType -- like TypeArr, but with custom type alias
114+
| TypeConstrained PSConstraint PSType
115115
--
116116
-- no need to implement
117117
--
118118
-- | TypeOpName (QualifiedName (OpName OpNameType_TypeOpName))
119119
-- | TypeArrName
120-
-- | TypeParens Type
120+
-- | TypeParens PSType
121121

122-
derive instance genericType :: Generic Type _
123-
derive instance eqType :: Eq Type
124-
derive instance ordType :: Ord Type
125-
instance showType :: Show Type where show x = genericShow x
122+
derive instance genericType :: Generic PSType _
123+
derive instance eqType :: Eq PSType
124+
derive instance ordType :: Ord PSType
125+
instance showType :: Show PSType where show x = genericShow x
126126

127127
data Kind
128128
= KindName (QualifiedName (ProperName ProperNameType_KindName))
@@ -157,7 +157,7 @@ instance showDataHead :: Show DataHead where show = genericShow
157157

158158
newtype DataCtor = DataCtor
159159
{ dataCtorName :: ProperName ProperNameType_ConstructorName
160-
, dataCtorFields :: Array Type
160+
, dataCtorFields :: Array PSType
161161
}
162162

163163
derive instance newtypeDataCtor :: Newtype DataCtor _
@@ -166,28 +166,28 @@ derive instance eqDataCtor :: Eq DataCtor
166166
derive instance ordDataCtor :: Ord DataCtor
167167
instance showDataCtor :: Show DataCtor where show = genericShow
168168

169-
type Row =
170-
{ rowLabels :: Array { label :: Label, type_ :: Type }
171-
, rowTail :: Maybe Type
169+
type PSRow =
170+
{ rowLabels :: Array { label :: Label, type_ :: PSType }
171+
, rowTail :: Maybe PSType
172172
}
173173

174-
newtype Constraint
175-
= Constraint
174+
newtype PSConstraint
175+
= PSConstraint
176176
{ className :: QualifiedName (ProperName ProperNameType_ClassName)
177-
, args :: Array Type
177+
, args :: Array PSType
178178
}
179-
-- | ConstraintParens Constraint
179+
-- | ConstraintParens PSConstraint
180180

181-
derive instance genericConstraint :: Generic Constraint _
182-
derive instance eqConstraint :: Eq Constraint
183-
derive instance ordConstraint :: Ord Constraint
184-
instance showConstraint :: Show Constraint where show = genericShow
181+
derive instance genericConstraint :: Generic PSConstraint _
182+
derive instance eqConstraint :: Eq PSConstraint
183+
derive instance ordConstraint :: Ord PSConstraint
184+
instance showConstraint :: Show PSConstraint where show = genericShow
185185

186186
-- Delimeted or separated
187187
type ClassHead =
188188
{ name :: ProperName ProperNameType_ClassName
189189
, vars :: Array TypeVarBinding
190-
, super :: Array Constraint
190+
, super :: Array PSConstraint
191191
, fundeps :: Array ClassFundep
192192
}
193193

@@ -208,7 +208,7 @@ data Binder
208208
| BinderNumber (Either Int Number)
209209
| BinderArray (Array Binder)
210210
| BinderRecord (Array (RecordLabeled Binder))
211-
| BinderTyped Binder Type
211+
| BinderTyped Binder PSType
212212
| BinderOp Binder (QualifiedName (OpName OpNameType_ValueOpName)) Binder
213213
-- | BinderParens Binder -- no need
214214

@@ -232,7 +232,7 @@ type Where =
232232
}
233233

234234
data LetBinding
235-
= LetBindingSignature { ident :: Ident, type_ :: Type }
235+
= LetBindingSignature { ident :: Ident, type_ :: PSType }
236236
| LetBindingName ValueBindingFields
237237
| LetBindingPattern { binder :: Binder, where_ :: Where }
238238

@@ -262,7 +262,7 @@ data Expr
262262
| ExprNumber (Either Int Number)
263263
| ExprArray (Array Expr)
264264
| ExprRecord (Array (RecordLabeled Expr))
265-
| ExprTyped Expr Type
265+
| ExprTyped Expr PSType
266266
| ExprInfix Expr Expr Expr -- e.g. `1 : 2 : Nil`
267267
| ExprOp Expr (QualifiedName (OpName OpNameType_ValueOpName)) Expr
268268
| ExprOpName (QualifiedName (OpName OpNameType_ValueOpName))
@@ -334,7 +334,7 @@ type AdoBlock =
334334
}
335335

336336
data InstanceBinding
337-
= InstanceBindingSignature { ident :: Ident, type_ :: Type }
337+
= InstanceBindingSignature { ident :: Ident, type_ :: PSType }
338338
| InstanceBindingName ValueBindingFields
339339

340340
derive instance genericInstanceBinding :: Generic InstanceBinding _

src/Language/PS/SmartCST.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Language.PS.SmartCST
44

55
import Language.PS.SmartCST.Types.SmartQualifiedName (SmartQualifiedName(..)) as Export
66
import Language.PS.SmartCST.Types.SmartQualifiedNameConstructor (SmartQualifiedNameConstructor(..)) as Export
7-
import Language.PS.SmartCST.Types.Declaration (AdoBlock, Binder(..), CaseOf, ClassHead, Constraint(..), DataCtor(..), DataHead(..), Declaration(..), DoStatement(..), Expr(..), FixityFields, FixityOp(..), Foreign(..), Guarded(..), GuardedExpr, IfThenElse, Instance, InstanceBinding(..), InstanceHead, Kind(..), Lambda, LetBinding(..), LetIn, PatternGuard, RecordAccessor, RecordUpdate(..), Row, Type(..), TypeVarBinding(..), ValueBindingFields, Where, (====>), (====>>), (====>>>)) as Export
7+
import Language.PS.SmartCST.Types.Declaration (AdoBlock, Binder(..), CaseOf, ClassHead, PSConstraint(..), DataCtor(..), DataHead(..), Declaration(..), DoStatement(..), Expr(..), FixityFields, FixityOp(..), Foreign(..), Guarded(..), GuardedExpr, IfThenElse, Instance, InstanceBinding(..), InstanceHead, Kind(..), Lambda, LetBinding(..), LetIn, PatternGuard, RecordAccessor, RecordUpdate(..), PSRow, PSType(..), TypeVarBinding(..), ValueBindingFields, Where, (====>), (====>>), (====>>>)) as Export
88
import Language.PS.SmartCST.ProcessModule (Module(..), moduleToCstModule, printModule) as Export
99
import Language.PS.SmartCST.Sugar.Declaration (arrayType, booleanType, maybeType, numberType, stringType, typeRecord, typeRow) as Export
1010
import Language.PS.CST.Sugar.Leafs (emptyRow, mkModuleName, mkRowLabel, mkRowLabels) as Export

0 commit comments

Comments
 (0)