purescript 0.8.5.0 → 0.9.1
raw patch · 560 files changed
+7765/−9823 lines, 560 filesdep +ansi-terminaldep +silentlydep ~parsecPVP ok
version bump matches the API change (PVP)
Dependencies added: ansi-terminal, silently
Dependency ranges changed: parsec
API changes (from Hackage documentation)
This diff is very large; some files are shown as “too large to diff”. Download the raw patch for the complete diff.
Files
- CONTRIBUTORS.md +2/−0
- examples/docs/src/Clash.purs +0/−28
- examples/docs/src/Clash1.purs +3/−0
- examples/docs/src/Clash1a.purs +9/−0
- examples/docs/src/Clash2.purs +3/−0
- examples/docs/src/Clash2a.purs +9/−0
- examples/docs/src/ImportedTwice.purs +4/−18
- examples/docs/src/ImportedTwiceA.purs +8/−0
- examples/docs/src/ImportedTwiceB.purs +4/−0
- examples/docs/src/MultiVirtual.purs +0/−21
- examples/docs/src/MultiVirtual1.purs +4/−0
- examples/docs/src/MultiVirtual2.purs +9/−0
- examples/docs/src/MultiVirtual3.purs +4/−0
- examples/docs/src/NewOperators.purs +0/−7
- examples/docs/src/NewOperators2.purs +6/−0
- examples/docs/src/OldOperators.purs +0/−10
- examples/docs/src/TypeClassWithoutMembers.purs +2/−8
- examples/docs/src/TypeClassWithoutMembersIntermediate.purs +5/−0
- examples/failing/1733.purs +1/−8
- examples/failing/1733/Thingy.purs +4/−0
- examples/failing/1825.purs +4/−4
- examples/failing/1881.purs +6/−0
- examples/failing/2128-class.purs +5/−0
- examples/failing/2128-instance.purs +8/−0
- examples/failing/ArgLengthMismatch.purs +7/−0
- examples/failing/Arrays.purs +2/−4
- examples/failing/ConflictingExports.purs +0/−10
- examples/failing/ConflictingExports/A.purs +4/−0
- examples/failing/ConflictingExports/B.purs +4/−0
- examples/failing/ConflictingImports.purs +5/−15
- examples/failing/ConflictingImports/A.purs +4/−0
- examples/failing/ConflictingImports/B.purs +4/−0
- examples/failing/ConflictingImports2.purs +6/−16
- examples/failing/ConflictingImports2/A.purs +4/−0
- examples/failing/ConflictingImports2/B.purs +4/−0
- examples/failing/ConflictingQualifiedImports.purs +3/−13
- examples/failing/ConflictingQualifiedImports/A.purs +4/−0
- examples/failing/ConflictingQualifiedImports/B.purs +4/−0
- examples/failing/ConflictingQualifiedImports2.purs +2/−12
- examples/failing/ConflictingQualifiedImports2/A.purs +4/−0
- examples/failing/ConflictingQualifiedImports2/B.purs +4/−0
- examples/failing/DeclConflictClassCtor.purs +6/−0
- examples/failing/DeclConflictClassSynonym.purs +8/−0
- examples/failing/DeclConflictClassType.purs +6/−0
- examples/failing/DeclConflictCtorClass.purs +6/−0
- examples/failing/DeclConflictCtorCtor.purs +6/−0
- examples/failing/DeclConflictSynonymClass.purs +8/−0
- examples/failing/DeclConflictSynonymType.purs +8/−0
- examples/failing/DeclConflictTypeClass.purs +6/−0
- examples/failing/DeclConflictTypeSynonym.purs +8/−0
- examples/failing/DeclConflictTypeType.purs +6/−0
- examples/failing/Do.purs +2/−2
- examples/failing/ExportConflictClass.purs +5/−0
- examples/failing/ExportConflictClass/A.purs +3/−0
- examples/failing/ExportConflictClass/B.purs +3/−0
- examples/failing/ExportConflictCtor.purs +5/−0
- examples/failing/ExportConflictCtor/A.purs +3/−0
- examples/failing/ExportConflictCtor/B.purs +3/−0
- examples/failing/ExportConflictType.purs +5/−0
- examples/failing/ExportConflictType/A.purs +3/−0
- examples/failing/ExportConflictType/B.purs +3/−0
- examples/failing/ExportConflictTypeOp.purs +5/−0
- examples/failing/ExportConflictTypeOp/A.purs +5/−0
- examples/failing/ExportConflictTypeOp/B.purs +5/−0
- examples/failing/ExportConflictValue.purs +5/−0
- examples/failing/ExportConflictValue/A.purs +4/−0
- examples/failing/ExportConflictValue/B.purs +4/−0
- examples/failing/ExportConflictValueOp.purs +5/−0
- examples/failing/ExportConflictValueOp/A.purs +6/−0
- examples/failing/ExportConflictValueOp/B.purs +6/−0
- examples/failing/ExportExplicit.purs +8/−0
- examples/failing/ExportExplicit1.purs +12/−0
- examples/failing/ExportExplicit1/M1.purs +3/−0
- examples/failing/ExportExplicit2.purs +8/−0
- examples/failing/ExportExplicit3.purs +10/−0
- examples/failing/ExportExplicit3/M1.purs +4/−0
- examples/failing/ImportExplicit.purs +4/−0
- examples/failing/ImportExplicit/M1.purs +3/−0
- examples/failing/ImportExplicit2.purs +4/−0
- examples/failing/ImportExplicit2/M1.purs +3/−0
- examples/failing/ImportHidingModule.purs +4/−10
- examples/failing/ImportHidingModule/A.purs +2/−0
- examples/failing/ImportHidingModule/B.purs +3/−0
- examples/failing/ImportModule.purs +4/−0
- examples/failing/ImportModule/M2.purs +3/−0
- examples/failing/InstanceExport.purs +7/−19
- examples/failing/InstanceExport/InstanceExport.purs +11/−0
- examples/failing/MissingClassMemberExport.purs +1/−1
- examples/failing/MultipleErrors2.purs +2/−2
- examples/failing/MultipleTypeOpFixities.purs +9/−0
- examples/failing/MultipleValueOpFixities.purs +9/−0
- examples/failing/OrphanInstance.purs +7/−12
- examples/failing/OrphanInstance/Class.purs +4/−0
- examples/failing/OrphanTypeDecl.purs +4/−0
- examples/failing/OverlappingReExport.purs +0/−10
- examples/failing/ProgrammableTypeErrors.purs +16/−0
- examples/failing/RequiredHiddenType.purs +9/−0
- examples/failing/RowConstructors1.purs +2/−2
- examples/failing/RowConstructors2.purs +2/−2
- examples/failing/RowConstructors3.purs +2/−2
- examples/failing/SkolemEscape2.purs +1/−1
- examples/failing/SuggestComposition.purs +1/−1
- examples/failing/Superclasses5.purs +2/−1
- examples/failing/TypeError.purs +1/−1
- examples/failing/TypedBinders.purs +3/−3
- examples/failing/TypedBinders2.purs +3/−3
- examples/failing/TypedBinders3.purs +2/−1
- examples/failing/UnderscoreModuleName.purs +2/−2
- examples/failing/UnknownType.purs +1/−1
- examples/passing/1185.purs +3/−1
- examples/passing/1335.purs +14/−12
- examples/passing/1570.purs +3/−1
- examples/passing/1664.purs +1/−1
- examples/passing/1697.purs +2/−1
- examples/passing/1881.purs +19/−0
- examples/passing/1991.purs +4/−2
- examples/passing/2018.purs +0/−13
- examples/passing/2018/A.purs +7/−0
- examples/passing/2018/B.purs +3/−0
- examples/passing/2049.purs +14/−0
- examples/passing/2138.purs +7/−0
- examples/passing/2138/Lib.purs +3/−0
- examples/passing/2172.js +5/−0
- examples/passing/2172.purs +10/−0
- examples/passing/652.purs +2/−1
- examples/passing/810.purs +2/−1
- examples/passing/Applicative.purs +2/−2
- examples/passing/ArrayType.purs +2/−1
- examples/passing/Auto.purs +2/−1
- examples/passing/AutoPrelude.purs +11/−9
- examples/passing/AutoPrelude2.purs +1/−1
- examples/passing/BindersInFunctions.purs +8/−3
- examples/passing/BindingGroups.purs +2/−1
- examples/passing/BlockString.purs +2/−1
- examples/passing/CaseInDo.purs +4/−2
- examples/passing/CaseMultipleExpressions.purs +4/−2
- examples/passing/CaseStatement.purs +2/−1
- examples/passing/CheckFunction.purs +2/−1
- examples/passing/CheckSynonymBug.purs +2/−1
- examples/passing/CheckTypeClass.purs +2/−2
- examples/passing/Church.purs +2/−2
- examples/passing/ClassRefSyntax.purs +5/−9
- examples/passing/ClassRefSyntax/Lib.purs +4/−0
- examples/passing/Collatz.purs +5/−2
- examples/passing/Comparisons.purs +15/−15
- examples/passing/Conditional.purs +2/−2
- examples/passing/Console.purs +4/−2
- examples/passing/ConstraintInference.purs +5/−2
- examples/passing/ContextSimplification.purs +5/−3
- examples/passing/DataAndType.purs +2/−1
- examples/passing/DctorOperatorAlias.purs +2/−8
- examples/passing/DctorOperatorAlias/List.purs +5/−0
- examples/passing/DeepArrayBinder.purs +2/−1
- examples/passing/DeepCase.purs +4/−4
- examples/passing/Deriving.purs +5/−2
- examples/passing/Do.purs +3/−2
- examples/passing/Dollar.purs +5/−5
- examples/passing/Eff.purs +4/−3
- examples/passing/EmptyDataDecls.purs +2/−1
- examples/passing/EmptyRow.purs +2/−1
- examples/passing/EmptyTypeClass.purs +5/−6
- examples/passing/EqOrd.purs +4/−1
- examples/passing/ExplicitImportReExport.purs +11/−16
- examples/passing/ExplicitImportReExport/Bar.purs +3/−0
- examples/passing/ExplicitImportReExport/Foo.purs +4/−0
- examples/passing/ExplicitOperatorSections.purs +2/−1
- examples/passing/ExportExplicit.purs +10/−0
- examples/passing/ExportExplicit/M1.purs +10/−0
- examples/passing/ExportExplicit2.purs +8/−0
- examples/passing/ExportExplicit2/M1.purs +7/−0
- examples/passing/ExportedInstanceDeclarations.purs +45/−0
- examples/passing/ExtendedInfixOperators.purs +5/−2
- examples/passing/Fib.purs +14/−11
- examples/passing/FieldConsPuns.purs +13/−10
- examples/passing/FieldPuns.purs +10/−8
- examples/passing/FinalTagless.purs +4/−1
- examples/passing/FunctionScope.purs +2/−1
- examples/passing/Functions.purs +2/−5
- examples/passing/Functions2.purs +2/−1
- examples/passing/Generalization1.purs +4/−3
- examples/passing/Guards.purs +2/−1
- examples/passing/IfThenElseMaybe.purs +2/−1
- examples/passing/ImplicitEmptyImport.purs +4/−3
- examples/passing/Import.purs +6/−0
- examples/passing/Import/M1.purs +8/−0
- examples/passing/Import/M2.purs +6/−0
- examples/passing/ImportExplicit.purs +10/−0
- examples/passing/ImportExplicit/M1.purs +4/−0
- examples/passing/ImportHiding.purs +3/−2
- examples/passing/ImportQualified.purs +8/−0
- examples/passing/ImportQualified/M1.purs +3/−0
- examples/passing/InferRecFunWithConstrainedArgument.purs +6/−3
- examples/passing/InstanceBeforeClass.purs +2/−1
- examples/passing/IntAndChar.purs +2/−1
- examples/passing/JSReserved.purs +2/−1
- examples/passing/KindedType.purs +2/−1
- examples/passing/LargeSumType.purs +4/−2
- examples/passing/Let.purs +14/−9
- examples/passing/Let2.purs +4/−1
- examples/passing/LetInInstance.purs +2/−1
- examples/passing/LiberalTypeSynonyms.purs +4/−3
- examples/passing/MPTCs.purs +3/−2
- examples/passing/Match.purs +2/−1
- examples/passing/Module.purs +7/−0
- examples/passing/Module/M1.purs +14/−0
- examples/passing/Module/M2.purs +10/−0
- examples/passing/ModuleDeps.purs +6/−0
- examples/passing/ModuleDeps/M1.purs +5/−0
- examples/passing/ModuleDeps/M2.purs +5/−0
- examples/passing/ModuleDeps/M3.purs +3/−0
- examples/passing/ModuleExport.purs +6/−7
- examples/passing/ModuleExport/A.purs +3/−0
- examples/passing/ModuleExportDupes.purs +3/−11
- examples/passing/ModuleExportDupes/A.purs +3/−0
- examples/passing/ModuleExportDupes/B.purs +3/−0
- examples/passing/ModuleExportDupes/C.purs +4/−0
- examples/passing/ModuleExportExcluded.purs +8/−11
- examples/passing/ModuleExportExcluded/A.purs +6/−0
- examples/passing/ModuleExportQualified.purs +7/−7
- examples/passing/ModuleExportQualified/A.purs +3/−0
- examples/passing/ModuleExportSelf.purs +8/−11
- examples/passing/ModuleExportSelf/A.purs +5/−0
- examples/passing/Monad.purs +2/−2
- examples/passing/MonadState.purs +3/−1
- examples/passing/MultiArgFunctions.purs +3/−3
- examples/passing/MutRec.purs +2/−1
- examples/passing/MutRec2.purs +2/−1
- examples/passing/MutRec3.purs +2/−1
- examples/passing/NamedPatterns.purs +3/−2
- examples/passing/NegativeBinder.purs +2/−1
- examples/passing/NegativeIntInRange.purs +2/−1
- examples/passing/Nested.purs +2/−1
- examples/passing/NestedTypeSynonyms.purs +2/−1
- examples/passing/NestedWhere.purs +2/−1
- examples/passing/Newtype.purs +5/−5
- examples/passing/NewtypeWithRecordUpdate.purs +2/−2
- examples/passing/NonConflictingExports.purs +5/−9
- examples/passing/NonConflictingExports/A.purs +4/−0
- examples/passing/NumberLiterals.purs +39/−0
- examples/passing/ObjectGetter.purs +5/−4
- examples/passing/ObjectSynonym.purs +2/−1
- examples/passing/ObjectUpdate.purs +23/−20
- examples/passing/ObjectUpdate2.purs +2/−1
- examples/passing/ObjectUpdater.purs +3/−1
- examples/passing/ObjectWildcards.purs +4/−4
- examples/passing/Objects.purs +3/−2
- examples/passing/OneConstructor.purs +2/−1
- examples/passing/OperatorAliasElsewhere.purs +0/−5
- examples/passing/OperatorAliasElsewhere/Def.purs +4/−0
- examples/passing/OperatorAssociativity.purs +25/−25
- examples/passing/OperatorInlining.purs +23/−22
- examples/passing/OperatorSections.purs +11/−10
- examples/passing/Operators.purs +22/−30
- examples/passing/Operators/Other.purs +7/−0
- examples/passing/OptimizerBug.purs +2/−1
- examples/passing/OptionalQualified.purs +2/−3
- examples/passing/OverlappingInstances.purs +17/−13
- examples/passing/OverlappingInstances2.purs +27/−23
- examples/passing/OverlappingInstances3.purs +20/−16
- examples/passing/ParensInTypedBinder.purs +20/−0
- examples/passing/PartialFunction.purs +4/−2
- examples/passing/Patterns.purs +5/−4
- examples/passing/PendingConflictingImports.purs +5/−14
- examples/passing/PendingConflictingImports/A.purs +4/−0
- examples/passing/PendingConflictingImports/B.purs +4/−0
- examples/passing/PendingConflictingImports2.purs +6/−10
- examples/passing/PendingConflictingImports2/A.purs +4/−0
- examples/passing/Person.purs +3/−2
- examples/passing/PrimedTypeName.purs +20/−0
- examples/passing/QualifiedNames.purs +11/−0
- examples/passing/QualifiedNames/Either.purs +5/−0
- examples/passing/QualifiedQualifiedImports.purs +2/−2
- examples/passing/Rank2Data.purs +30/−29
- examples/passing/Rank2Object.purs +1/−1
- examples/passing/Rank2TypeSynonym.purs +3/−2
- examples/passing/Rank2Types.purs +2/−1
- examples/passing/ReExportQualified.purs +4/−13
- examples/passing/ReExportQualified/A.purs +3/−0
- examples/passing/ReExportQualified/B.purs +3/−0
- examples/passing/ReExportQualified/C.purs +4/−0
- examples/passing/RebindableSyntax.purs +43/−39
- examples/passing/Recursion.purs +2/−1
- examples/passing/RedefinedFixity.purs +6/−0
- examples/passing/RedefinedFixity/M1.purs +6/−0
- examples/passing/RedefinedFixity/M2.purs +5/−0
- examples/passing/RedefinedFixity/M3.purs +6/−0
- examples/passing/ReservedWords.purs +6/−2
- examples/passing/ResolvableScopeConflict.purs +9/−21
- examples/passing/ResolvableScopeConflict/A.purs +4/−0
- examples/passing/ResolvableScopeConflict/B.purs +7/−0
- examples/passing/ResolvableScopeConflict2.purs +10/−17
- examples/passing/ResolvableScopeConflict2/A.purs +7/−0
- examples/passing/ResolvableScopeConflict3.purs +5/−11
- examples/passing/ResolvableScopeConflict3/A.purs +4/−0
- examples/passing/RowConstructors.purs +3/−2
- examples/passing/RowPolyInstanceContext.purs +4/−3
- examples/passing/RuntimeScopeIssue.purs +4/−1
- examples/passing/ScopedTypeVariables.purs +2/−1
- examples/passing/Sequence.purs +2/−1
- examples/passing/SequenceDesugared.purs +5/−4
- examples/passing/ShadowedModuleName.purs +4/−11
- examples/passing/ShadowedModuleName/Test.purs +6/−0
- examples/passing/ShadowedName.purs +11/−0
- examples/passing/ShadowedTCO.purs +21/−18
- examples/passing/ShadowedTCOLet.purs +15/−9
- examples/passing/SignedNumericLiterals.purs +2/−1
- examples/passing/StringEscapes.purs +17/−15
- examples/passing/Superclasses1.purs +4/−1
- examples/passing/Superclasses3.purs +1/−1
- examples/passing/TCO.purs +7/−7
- examples/passing/TCOCase.purs +2/−1
- examples/passing/TailCall.purs +4/−1
- examples/passing/Tick.purs +2/−1
- examples/passing/TopLevelCase.purs +2/−1
- examples/passing/TransitiveImport.purs +9/−0
- examples/passing/TransitiveImport/Middle.purs +5/−0
- examples/passing/TransitiveImport/Test.purs +9/−0
- examples/passing/TypeClassMemberOrderChange.purs +16/−13
- examples/passing/TypeClasses.purs +11/−9
- examples/passing/TypeClassesInOrder.purs +2/−1
- examples/passing/TypeClassesWithOverlappingTypeVariables.purs +3/−2
- examples/passing/TypeDecl.purs +2/−1
- examples/passing/TypeOperators.purs +13/−27
- examples/passing/TypeOperators/A.purs +22/−0
- examples/passing/TypeSynonymInData.purs +2/−1
- examples/passing/TypeSynonyms.purs +2/−1
- examples/passing/TypeWildcards.purs +2/−1
- examples/passing/TypeWildcardsRecordExtension.purs +2/−1
- examples/passing/TypeWithoutParens.purs +7/−11
- examples/passing/TypeWithoutParens/Lib.purs +4/−0
- examples/passing/TypedBinders.purs +8/−7
- examples/passing/TypedWhere.purs +2/−1
- examples/passing/UTF8Sourcefile.purs +8/−10
- examples/passing/UnderscoreIdent.purs +3/−1
- examples/passing/UnicodeIdentifier.purs +3/−1
- examples/passing/UnicodeOperators.purs +3/−1
- examples/passing/UnicodeType.purs +8/−9
- examples/passing/Unit.purs +4/−2
- examples/passing/UnknownInTypeClassLookup.purs +2/−1
- examples/passing/UntupledConstraints.purs +1/−1
- examples/passing/Where.purs +11/−11
- examples/passing/WildcardType.purs +12/−0
- examples/passing/iota.purs +3/−1
- examples/passing/s.purs +2/−1
- examples/warning/DuplicateExportRef.purs +30/−0
- examples/warning/DuplicateImport.purs +10/−0
- examples/warning/DuplicateImportRef.purs +18/−0
- examples/warning/DuplicateSelectiveImport.purs +10/−0
- examples/warning/HidingImport.purs +9/−0
- examples/warning/ImplicitImport.purs +9/−0
- examples/warning/ImplicitQualifiedImport.purs +11/−0
- examples/warning/MissingTypeDeclaration.purs +4/−0
- examples/warning/OverlappingInstances.purs +17/−0
- examples/warning/OverlappingPattern.purs +15/−0
- examples/warning/ScopeShadowing.purs +13/−0
- examples/warning/ShadowedTypeVar.purs +5/−0
- examples/warning/UnnecessaryFFIModule.js +1/−0
- examples/warning/UnnecessaryFFIModule.purs +5/−0
- examples/warning/UnusedDctorExplicitImport.purs +8/−0
- examples/warning/UnusedDctorImportAll.purs +7/−0
- examples/warning/UnusedDctorImportExplicit.purs +7/−0
- examples/warning/UnusedExplicitImport.purs +8/−0
- examples/warning/UnusedFFIImplementations.js +2/−0
- examples/warning/UnusedFFIImplementations.purs +4/−0
- examples/warning/UnusedImport.purs +14/−0
- examples/warning/UnusedTypeVar.purs +5/−0
- examples/warning/WildcardInferredType.purs +23/−0
- hierarchy/Main.hs +2/−3
- psc-bundle/Main.hs +1/−11
- psc-docs/Main.hs +1/−1
- psc-ide-client/Main.hs +1/−1
- psc-ide-server/Main.hs +20/−26
- psc/Main.hs +27/−53
- psci/Main.hs +132/−0
- psci/PSCi.hs +0/−372
- psci/PSCi/Completion.hs +0/−226
- psci/PSCi/Directive.hs +0/−119
- psci/PSCi/IO.hs +0/−68
- psci/PSCi/Message.hs +0/−53
- psci/PSCi/Module.hs +0/−107
- psci/PSCi/Option.hs +0/−57
- psci/PSCi/Parser.hs +0/−140
- psci/PSCi/Printer.hs +0/−131
- psci/PSCi/Types.hs +0/−218
- psci/main/Main.hs +0/−6
- purescript.cabal +227/−109
- src/Control/Monad/Logger.hs +7/−20
- src/Control/Monad/Supply.hs +5/−18
- src/Control/Monad/Supply/Class.hs +6/−6
- src/Language/PureScript.hs +5/−17
- src/Language/PureScript/AST/Binders.hs +3/−1
- src/Language/PureScript/AST/Declarations.hs +56/−71
- src/Language/PureScript/AST/Exported.hs +12/−15
- src/Language/PureScript/AST/Literals.hs +2/−2
- src/Language/PureScript/AST/Operators.hs +2/−0
- src/Language/PureScript/AST/SourcePos.hs +0/−3
- src/Language/PureScript/AST/Traversals.hs +8/−25
- src/Language/PureScript/Bundle.hs +57/−52
- src/Language/PureScript/CodeGen.hs +8/−20
- src/Language/PureScript/CodeGen/JS.hs +10/−18
- src/Language/PureScript/CodeGen/JS/AST.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Common.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer/Blocks.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer/Common.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer/MagicDo.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer/TCO.hs too large to diff
- src/Language/PureScript/CodeGen/JS/Optimizer/Unused.hs too large to diff
- src/Language/PureScript/Comments.hs too large to diff
- src/Language/PureScript/Constants.hs too large to diff
- src/Language/PureScript/CoreFn.hs too large to diff
- src/Language/PureScript/CoreFn/Ann.hs too large to diff
- src/Language/PureScript/CoreFn/Binders.hs too large to diff
- src/Language/PureScript/CoreFn/Desugar.hs too large to diff
- src/Language/PureScript/CoreFn/Expr.hs too large to diff
- src/Language/PureScript/CoreFn/Meta.hs too large to diff
- src/Language/PureScript/CoreFn/Module.hs too large to diff
- src/Language/PureScript/CoreFn/Traversals.hs too large to diff
- src/Language/PureScript/Crash.hs too large to diff
- src/Language/PureScript/Docs.hs too large to diff
- src/Language/PureScript/Docs/AsMarkdown.hs too large to diff
- src/Language/PureScript/Docs/Convert.hs too large to diff
- src/Language/PureScript/Docs/Convert/ReExports.hs too large to diff
- src/Language/PureScript/Docs/Convert/Single.hs too large to diff
- src/Language/PureScript/Docs/ParseAndBookmark.hs too large to diff
- src/Language/PureScript/Docs/Render.hs too large to diff
- src/Language/PureScript/Docs/RenderedCode.hs too large to diff
- src/Language/PureScript/Docs/RenderedCode/Render.hs too large to diff
- src/Language/PureScript/Docs/RenderedCode/Types.hs too large to diff
- src/Language/PureScript/Docs/Types.hs too large to diff
- src/Language/PureScript/Environment.hs too large to diff
- src/Language/PureScript/Errors.hs too large to diff
- src/Language/PureScript/Errors/JSON.hs too large to diff
- src/Language/PureScript/Externs.hs too large to diff
- src/Language/PureScript/Ide.hs too large to diff
- src/Language/PureScript/Ide/CaseSplit.hs too large to diff
- src/Language/PureScript/Ide/Command.hs too large to diff
- src/Language/PureScript/Ide/Error.hs too large to diff
- src/Language/PureScript/Ide/Externs.hs too large to diff
- src/Language/PureScript/Ide/Filter.hs too large to diff
- src/Language/PureScript/Ide/Imports.hs too large to diff
- src/Language/PureScript/Ide/Matcher.hs too large to diff
- src/Language/PureScript/Ide/Pursuit.hs too large to diff
- src/Language/PureScript/Ide/Rebuild.hs too large to diff
- src/Language/PureScript/Ide/Reexports.hs too large to diff
- src/Language/PureScript/Ide/SourceFile.hs too large to diff
- src/Language/PureScript/Ide/State.hs too large to diff
- src/Language/PureScript/Ide/Types.hs too large to diff
- src/Language/PureScript/Ide/Util.hs too large to diff
- src/Language/PureScript/Ide/Watcher.hs too large to diff
- src/Language/PureScript/Interactive.hs too large to diff
- src/Language/PureScript/Interactive/Completion.hs too large to diff
- src/Language/PureScript/Interactive/Directive.hs too large to diff
- src/Language/PureScript/Interactive/IO.hs too large to diff
- src/Language/PureScript/Interactive/Message.hs too large to diff
- src/Language/PureScript/Interactive/Module.hs too large to diff
- src/Language/PureScript/Interactive/Parser.hs too large to diff
- src/Language/PureScript/Interactive/Printer.hs too large to diff
- src/Language/PureScript/Interactive/Types.hs too large to diff
- src/Language/PureScript/Kinds.hs too large to diff
- src/Language/PureScript/Linter.hs too large to diff
- src/Language/PureScript/Linter/Exhaustive.hs too large to diff
- src/Language/PureScript/Linter/Imports.hs too large to diff
- src/Language/PureScript/Make.hs too large to diff
- src/Language/PureScript/ModuleDependencies.hs too large to diff
- src/Language/PureScript/Names.hs too large to diff
- src/Language/PureScript/Options.hs too large to diff
- src/Language/PureScript/Parser.hs too large to diff
- src/Language/PureScript/Parser/Common.hs too large to diff
- src/Language/PureScript/Parser/Declarations.hs too large to diff
- src/Language/PureScript/Parser/JS.hs too large to diff
- src/Language/PureScript/Parser/Kinds.hs too large to diff
- src/Language/PureScript/Parser/Lexer.hs too large to diff
- src/Language/PureScript/Parser/State.hs too large to diff
- src/Language/PureScript/Parser/Types.hs too large to diff
- src/Language/PureScript/Pretty.hs too large to diff
- src/Language/PureScript/Pretty/Common.hs too large to diff
- src/Language/PureScript/Pretty/JS.hs too large to diff
- src/Language/PureScript/Pretty/Kinds.hs too large to diff
- src/Language/PureScript/Pretty/Types.hs too large to diff
- src/Language/PureScript/Pretty/Values.hs too large to diff
- src/Language/PureScript/Publish.hs too large to diff
- src/Language/PureScript/Publish/BoxesHelpers.hs too large to diff
- src/Language/PureScript/Publish/ErrorsWarnings.hs too large to diff
- src/Language/PureScript/Publish/Utils.hs too large to diff
- src/Language/PureScript/Renamer.hs too large to diff
- src/Language/PureScript/Sugar.hs too large to diff
- src/Language/PureScript/Sugar/BindingGroups.hs too large to diff
- src/Language/PureScript/Sugar/CaseDeclarations.hs too large to diff
- src/Language/PureScript/Sugar/DoNotation.hs too large to diff
- src/Language/PureScript/Sugar/Names.hs too large to diff
- src/Language/PureScript/Sugar/Names/Common.hs too large to diff
- src/Language/PureScript/Sugar/Names/Env.hs too large to diff
- src/Language/PureScript/Sugar/Names/Exports.hs too large to diff
- src/Language/PureScript/Sugar/Names/Imports.hs too large to diff
- src/Language/PureScript/Sugar/ObjectWildcards.hs too large to diff
- src/Language/PureScript/Sugar/Operators.hs too large to diff
- src/Language/PureScript/Sugar/Operators/Binders.hs too large to diff
- src/Language/PureScript/Sugar/Operators/Common.hs too large to diff
- src/Language/PureScript/Sugar/Operators/Expr.hs too large to diff
- src/Language/PureScript/Sugar/Operators/Types.hs too large to diff
- src/Language/PureScript/Sugar/TypeClasses.hs too large to diff
- src/Language/PureScript/Sugar/TypeClasses/Deriving.hs too large to diff
- src/Language/PureScript/Sugar/TypeDeclarations.hs too large to diff
- src/Language/PureScript/Traversals.hs too large to diff
- src/Language/PureScript/TypeChecker.hs too large to diff
- src/Language/PureScript/TypeChecker/Entailment.hs too large to diff
- src/Language/PureScript/TypeChecker/Kinds.hs too large to diff
- src/Language/PureScript/TypeChecker/Monad.hs too large to diff
- src/Language/PureScript/TypeChecker/Rows.hs too large to diff
- src/Language/PureScript/TypeChecker/Skolems.hs too large to diff
- src/Language/PureScript/TypeChecker/Subsumption.hs too large to diff
- src/Language/PureScript/TypeChecker/Synonyms.hs too large to diff
- src/Language/PureScript/TypeChecker/Types.hs too large to diff
- src/Language/PureScript/TypeChecker/Unify.hs too large to diff
- src/Language/PureScript/TypeClassDictionaries.hs too large to diff
- src/Language/PureScript/Types.hs too large to diff
- src/System/IO/UTF8.hs too large to diff
- stack-lts-5.yaml too large to diff
- stack-nightly.yaml too large to diff
- stack.yaml too large to diff
- tests/Language/PureScript/Ide/FilterSpec.hs too large to diff
- tests/Language/PureScript/Ide/Imports/IntegrationSpec.hs too large to diff
- tests/Language/PureScript/Ide/ImportsSpec.hs too large to diff
- tests/Language/PureScript/Ide/Integration.hs too large to diff
- tests/Language/PureScript/Ide/MatcherSpec.hs too large to diff
- tests/Language/PureScript/Ide/RebuildSpec.hs too large to diff
- tests/Language/PureScript/Ide/ReexportsSpec.hs too large to diff
- tests/Language/PureScript/IdeSpec.hs too large to diff
- tests/Main.hs too large to diff
- tests/TestCompiler.hs too large to diff
- tests/TestDocs.hs too large to diff
- tests/TestPscIde.hs too large to diff
- tests/TestPscPublish.hs too large to diff
- tests/TestPsci.hs too large to diff
- tests/TestUtils.hs too large to diff
- tests/support/bower.json too large to diff
- tests/support/flattened/Control-Monad-Eff-Class.purs too large to diff
- tests/support/flattened/Control-Monad-Eff-Console.js too large to diff
- tests/support/flattened/Control-Monad-Eff-Console.purs too large to diff
- tests/support/flattened/Control-Monad-Eff-Unsafe.js too large to diff
- tests/support/flattened/Control-Monad-Eff-Unsafe.purs too large to diff
- tests/support/flattened/Control-Monad-Eff.js too large to diff
- tests/support/flattened/Control-Monad-Eff.purs too large to diff
- tests/support/flattened/Control-Monad-ST.js too large to diff
- tests/support/flattened/Control-Monad-ST.purs too large to diff
- tests/support/flattened/Data-Function.js too large to diff
- tests/support/flattened/Data-Function.purs too large to diff
- tests/support/flattened/Prelude.js too large to diff
- tests/support/flattened/Prelude.purs too large to diff
- tests/support/flattened/Test-Assert.js too large to diff
- tests/support/flattened/Test-Assert.purs too large to diff
- tests/support/package.json too large to diff
- tests/support/prelude/LICENSE too large to diff
- tests/support/prelude/bower.json too large to diff
- tests/support/prelude/src/Prelude.js too large to diff
- tests/support/prelude/src/Prelude.purs too large to diff
- tests/support/pscide/src/RebuildSpecWithHiddenIdent.purs too large to diff
- tests/support/setup.js too large to diff
@@ -31,6 +31,7 @@ - [@jacereda](https://github.com/jacereda) (Jorge Acereda) My existing contributions and all future contributions until further notice are Copyright Jorge Acereda, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - [@japesinator](https://github.com/japesinator) (JP Smith) My existing contributions and all future contributions until further notice are Copyright JP Smith, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - [@joneshf](https://github.com/joneshf) (Hardy Jones) - My existing contributions and all future contributions until further notice are Copyright Hardy Jones, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license.+- [@kika](https://github.com/kika) (Kirill Pertsev) - My existing contributions and all future contributions until further notice are Copyright Kirill Pertsev, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license. - [@kRITZCREEK](https://github.com/kRITZCREEK) (Christoph Hegemann) - My existing contributions and all future contributions until further notice are Copyright Christoph Hegemann, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license. - [@L8D](https://github.com/L8D) (Tenor Biel) My existing contributions and all future contributions until further notice are Copyright Tenor Biel, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - [@leighman](http://github.com/leighman) (Jack Leigh) My existing contributions and all future contributions until further notice are Copyright Jack Leigh, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).@@ -70,6 +71,7 @@ - [@zudov](https://github.com/zudov) (Konstantin Zudov) My existing contributions and all future contributions until further notice are Copyright Konstantin Zudov, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - [@LiamGoodacre](https://github.com/LiamGoodacre) (Liam Goodacre) My existing contributions and all future contributions until further notice are Copyright Liam Goodacre, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). - [@bsermons](https://github.com/bsermons) (Brian Sermons) My existing contributions and all future contributions until further notice are Copyright Brian Sermons, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).+- [@bmjames](https://github.com/bmjames) (Ben James) My existing contributions and all future contributions until further notice are Copyright Ben James, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT). ### Companies
@@ -2,31 +2,3 @@ import Clash1 as Clash1 import Clash2 as Clash2--module Clash1 (module Clash1a) where--import Clash1a--module Clash1a where--value :: Int-value = 0--type Type = Int--class TypeClass a where- typeClassMember :: a--module Clash2 (module Clash2a) where--import Clash2a--module Clash2a where--value :: String-value = "hello"--type Type = String--class TypeClass a b where- typeClassMember :: a -> b
@@ -0,0 +1,3 @@+module Clash1 (module Clash1a) where++import Clash1a
@@ -0,0 +1,9 @@+module Clash1a where++value :: Int+value = 0++type Type = Int++class TypeClass a where+ typeClassMember :: a
@@ -0,0 +1,3 @@+module Clash2 (module Clash2a) where++import Clash2a
@@ -0,0 +1,9 @@+module Clash2a where++value :: String+value = "hello"++type Type = String++class TypeClass a b where+ typeClassMember :: a -> b
@@ -4,24 +4,10 @@ -- re-exports it from Control.Monad.Trans). module ImportedTwice- ( module A- , module B+ ( module ImportedTwiceA+ , module ImportedTwiceB ) where -import A-import B--module A- ( module B )- where--import B--bar :: Int-bar = 1--module B where--foo :: Int-foo = 0+import ImportedTwiceA+import ImportedTwiceB
@@ -0,0 +1,8 @@+module ImportedTwiceA+ ( module ImportedTwiceB )+ where++import ImportedTwiceB++bar :: Int+bar = 1
@@ -0,0 +1,4 @@+module ImportedTwiceB where++foo :: Int+foo = 0
@@ -4,24 +4,3 @@ import MultiVirtual1 as X import MultiVirtual2 as X---module MultiVirtual1 where--foo :: Int-foo = 1--module MultiVirtual2 - ( module MultiVirtual2- , module MultiVirtual3- ) where--import MultiVirtual3--bar :: Int-bar = 2--module MultiVirtual3 where--baz :: Int-baz = 3
@@ -0,0 +1,4 @@+module MultiVirtual1 where++foo :: Int+foo = 1
@@ -0,0 +1,9 @@+module MultiVirtual2+ ( module MultiVirtual2+ , module MultiVirtual3+ ) where++import MultiVirtual3++bar :: Int+bar = 2
@@ -0,0 +1,4 @@+module MultiVirtual3 where++baz :: Int+baz = 3
@@ -3,10 +3,3 @@ where import NewOperators2--module NewOperators2 where--infixl 8 _compose as >>>--_compose :: forall a b c. (b -> c) -> (a -> b) -> (a -> c)-_compose f g x = f (g x)
@@ -0,0 +1,6 @@+module NewOperators2 where++infixl 8 _compose as >>>++_compose :: forall a b c. (b -> c) -> (a -> b) -> (a -> c)+_compose f g x = f (g x)
@@ -1,10 +0,0 @@---- Remove this after 0.9.-module OldOperators (module OldOperators2) where--import OldOperators2--module OldOperators2 where--(>>) :: forall a. a -> a -> a-(>>) a b = b
@@ -1,11 +1,5 @@ module TypeClassWithoutMembers- ( module Intermediate )- where--import Intermediate--module Intermediate- ( module SomeTypeClass )+ ( module TypeClassWithoutMembersIntermediate ) where -import SomeTypeClass (SomeClass)+import TypeClassWithoutMembersIntermediate
@@ -0,0 +1,5 @@+module TypeClassWithoutMembersIntermediate+ ( module SomeTypeClass )+ where++import SomeTypeClass (class SomeClass)
@@ -1,13 +1,6 @@--- @shouldFailWith UnknownValue-+-- @shouldFailWith UnknownName module Main where import Thingy as Thing main = Thing.doesntExist "hi"--module Thingy where--foo :: Int-foo = 1-
@@ -0,0 +1,4 @@+module Thingy where++foo :: Int+foo = 1
@@ -1,9 +1,9 @@--- @shouldFailWith UnknownValue+-- @shouldFailWith UnknownName module Main where data W = X | Y | Z -bad X a = a -bad Y _ = a -bad Z a = a +bad X a = a+bad Y _ = a+bad Z a = a
@@ -0,0 +1,6 @@+-- @shouldFailWith ErrorParsingModule+module Main where++foo =+bar :: Int+bar = 3
@@ -0,0 +1,5 @@+-- @shouldFailWith ErrorParsingModule+module Main where++class Foo a where+ foo :: a -> !!!
@@ -0,0 +1,8 @@+-- @shouldFailWith ErrorParsingModule+module Main where++class Foo a where+ foo :: a++instance fooInt :: Foo Int where+ foo = !!!
@@ -0,0 +1,7 @@+-- @shouldFailWith ArgListLengthsDiffer +module ArgLengthMismatch where + +import Prelude + +f x y = true +f = false
@@ -1,8 +1,6 @@ -- @shouldFailWith TypesDoNotUnify module Main where -import Prelude--foreign import (!!) :: forall a. Array a -> Int -> a+foreign import ix :: forall a. Array a -> Int -> a -test = \arr -> arr !! (0 !! 0)+test = \arr -> arr `ix` (0 `ix` 0)
@@ -1,14 +1,4 @@ -- @shouldFailWith ScopeConflict-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2- -- Fails here because re-exporting forces any scope conflicts to be resolved module Main (module A, module B) where
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,4 @@+module B where++thing :: Int+thing = 2
@@ -1,19 +1,9 @@ -- @shouldFailWith ScopeConflict-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2- module Main where - import A- import B+import A+import B - -- Error due to referencing `thing` which is in scope as A.thing and B.thing- what :: Int- what = thing+-- Error due to referencing `thing` which is in scope as A.thing and B.thing+what :: Int+what = thing
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,4 @@+module B where++thing :: Int+thing = 2
@@ -1,20 +1,10 @@ -- @shouldFailWith ScopeConflict-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2- module Main where - import A (thing)- import B (thing)+import A (thing)+import B (thing) - -- Error due to referencing `thing` which is explicitly in scope as A.thing- -- and B.thing- what :: Int- what = thing+-- Error due to referencing `thing` which is explicitly in scope as A.thing+-- and B.thing+what :: Int+what = thing
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,4 @@+module B where++thing :: Int+thing = 2
@@ -1,17 +1,7 @@ -- @shouldFailWith ScopeConflict-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2- module Main where - import A as X- import B as X+import A as X+import B as X - foo = X.thing+foo = X.thing
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,4 @@+module B where++thing :: Int+thing = 2
@@ -1,15 +1,5 @@ -- @shouldFailWith ScopeConflict-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2- module Main (module X) where - import A as X- import B as X+import A as X+import B as X
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,4 @@+module B where++thing :: Int+thing = 2
@@ -0,0 +1,6 @@+-- @shouldFailWith DeclConflict+module Main where++data T = Fail++class Fail
@@ -0,0 +1,8 @@+-- @shouldFailWith DeclConflict+module Main where++import Prelude++type Fail = Unit++class Fail
@@ -0,0 +1,6 @@+-- @shouldFailWith DeclConflict+module Main where++class Fail++data Fail
@@ -0,0 +1,6 @@+-- @shouldFailWith DeclConflict+module Main where++class Fail++data T = Fail
@@ -0,0 +1,6 @@+-- @shouldFailWith DeclConflict+module Main where++data T1 = Fail++data T2 = Fail
@@ -0,0 +1,8 @@+-- @shouldFailWith DeclConflict+module Main where++import Prelude++class Fail++type Fail = Unit
@@ -0,0 +1,8 @@+-- @shouldFailWith DeclConflict+module Main where++import Prelude++data Fail++type Fail = Unit
@@ -0,0 +1,6 @@+-- @shouldFailWith DeclConflict+module Main where++class Fail++data Fail
@@ -0,0 +1,8 @@+-- @shouldFailWith DeclConflict+module Main where++import Prelude++type Fail = Unit++data Fail
@@ -0,0 +1,6 @@+-- @shouldFailWith DeclConflict+module Main where++data Fail++data Fail
@@ -8,5 +8,5 @@ test2 y = do x <- y -test3 = do return 1- return 2+test3 = do pure 1+ pure 2
@@ -0,0 +1,5 @@+-- @shouldFailWith ExportConflict+module C (module A, module B) where++import A as A+import B as B
@@ -0,0 +1,3 @@+module A where++class X
@@ -0,0 +1,3 @@+module B where++class X
@@ -0,0 +1,5 @@+-- @shouldFailWith ExportConflict+module C (module A, module B) where++import A as A+import B as B
@@ -0,0 +1,3 @@+module A where++data T1 = X
@@ -0,0 +1,3 @@+module B where++data T2 = X
@@ -0,0 +1,5 @@+-- @shouldFailWith ExportConflict+module C (module A, module B) where++import A as A+import B as B
@@ -0,0 +1,3 @@+module A where++data T
@@ -0,0 +1,3 @@+module B where++data T
@@ -0,0 +1,5 @@+-- @shouldFailWith ExportConflict+module C (module A, module B) where++import A as A+import B as B
@@ -0,0 +1,5 @@+module A where++type T1 a b = a -> b++infixr 4 type T1 as ??
@@ -0,0 +1,5 @@+module B where++type T2 a b = a -> b++infixr 4 type T2 as ??
@@ -0,0 +1,5 @@+-- @shouldFailWith ExportConflict+module C (module A, module B) where++import A as A+import B as B
@@ -0,0 +1,4 @@+module A where++x :: Boolean+x = true
@@ -0,0 +1,4 @@+module B where++x :: Boolean+x = false
@@ -0,0 +1,5 @@+-- @shouldFailWith ExportConflict+module C (module A, module B) where++import A as A+import B as B
@@ -0,0 +1,6 @@+module A where++f1 :: forall a b. a -> b -> a+f1 x _ = x++infix 0 f1 as !!
@@ -0,0 +1,6 @@+module B where++f2 :: forall a b. a -> b -> a+f2 x _ = x++infix 0 f2 as !!
@@ -0,0 +1,8 @@+-- @shouldFailWith UnknownExport +-- should fail as z does not exist in the module +module M1 (x, y, z) where + +import Prelude + +x = 1 +y = 2
@@ -0,0 +1,12 @@+-- @shouldFailWith UnknownName +module Main where + +import M1 +import Control.Monad.Eff.Console (log) + +testX = X + +-- should fail as Y constructor is not exported from M1 +testY = Y + +main = log "Done"
@@ -0,0 +1,3 @@+module M1 (X(X)) where + +data X = X | Y
@@ -0,0 +1,8 @@+-- @shouldFailWith UnknownExportDataConstructor +-- should fail as Y is not a data constructor for X +module M1 (X(Y)) where + +import Prelude + +data X = X +data Y = Y
@@ -0,0 +1,10 @@+-- @shouldFailWith UnknownName +module Main where + +import M1 as M +import Control.Monad.Eff.Console (log) + +-- should fail as Z is not exported from M1 +testZ = M.Z + +main = log "Done"
@@ -0,0 +1,4 @@+module M1 (X(..)) where + +data X = X | Y +data Z = Z
@@ -0,0 +1,4 @@+-- @shouldFailWith UnknownImport +module Main where + +import M1 (X(..))
@@ -0,0 +1,3 @@+module M1 where + +foo = "foo"
@@ -0,0 +1,4 @@+-- @shouldFailWith UnknownImportDataConstructor +module Main where + +import M1 (X(Z, Q))
@@ -0,0 +1,3 @@+module M1 where + +data X = Y
@@ -1,10 +1,4 @@--- @shouldFailWith ImportHidingModule-module A where- x = 1--module B (module B, module A) where- import A- y = 1--module C where- import B hiding (module A)+-- @shouldFailWith ImportHidingModule +module Main where + +import B hiding (module A)
@@ -0,0 +1,2 @@+module A where +x = 1
@@ -0,0 +1,3 @@+module B (module B, module A) where +import A +y = 1
@@ -0,0 +1,4 @@+-- @shouldFailWith UnknownName +module Main where + +import M1
@@ -0,0 +1,3 @@+module M2 where + +data X = X
@@ -1,19 +1,7 @@--- @shouldFailWith TransitiveExportError-module InstanceExport (S(..), f) where--import Prelude--newtype S = S String--class F a where- f :: a -> String--instance fs :: F S where- f (S s) = s--module Test where--import InstanceExport-import Prelude--test = f $ S "Test"+-- @shouldFailWith TransitiveExportError +module Test where + +import InstanceExport +import Prelude + +test = f $ S "Test"
@@ -0,0 +1,11 @@+module InstanceExport (S(..), f) where + +import Prelude + +newtype S = S String + +class F a where + f :: a -> String + +instance fs :: F S where + f (S s) = s
@@ -1,5 +1,5 @@ -- @shouldFailWith TransitiveExportError-module Test (Foo) where+module Test (class Foo) where import Prelude
@@ -1,5 +1,5 @@--- @shouldFailWith UnknownValue--- @shouldFailWith UnknownValue+-- @shouldFailWith UnknownName+-- @shouldFailWith UnknownName module MultipleErrors2 where import Prelude
@@ -0,0 +1,9 @@+-- @shouldFailWith MultipleTypeOpFixities +module MultipleTypeOpFixities where + +import Prelude + +type Op x y = Op x y + +infix 2 type Op as !? +infix 2 type Op as !?
@@ -0,0 +1,9 @@+-- @shouldFailWith MultipleValueOpFixities +module MultipleValueOpFixities where + +import Prelude + +add x y = x + y + +infix 2 add as !? +infix 2 add as !?
@@ -1,12 +1,7 @@--- @shouldFailWith OrphanInstance-module Class where-- class C a where- op :: a -> a--module Test where-- import Class-- instance cBoolean :: C Boolean where- op a = a+-- @shouldFailWith OrphanInstance +module Test where + +import Class + +instance cBoolean :: C Boolean where + op a = a
@@ -0,0 +1,4 @@+module Class where + +class C a where + op :: a -> a
@@ -0,0 +1,4 @@+-- @shouldFailWith OrphanTypeDeclaration +module OrphanTypeDecl where + +fn :: Number -> Boolean
@@ -1,10 +0,0 @@--- @shouldFailWith DuplicateValueExport-module A where- x = true--module B where- x = false--module C (module A, module M2) where- import A- import qualified B as M2
@@ -0,0 +1,16 @@+-- @shouldFailWith NoInstanceFound++module Main where++import Prelude+import Control.Monad.Eff (Eff)+import Control.Monad.Eff.Console (log)++class MyShow a where+ myShow :: a -> String++instance cannotShowFunctions :: Fail "Cannot show functions" => MyShow (a -> b) where+ myShow _ = "unreachable"++main :: Eff _ _+main = log (myShow (_ + 1))
@@ -0,0 +1,9 @@+-- @shouldFailWith TransitiveExportError +-- exporting `a` should fail as `A` is hidden +module Foo (B(..), a, b) where + +data A = A +data B = B + +a = A +b = B
@@ -1,9 +1,9 @@ -- @shouldFailWith KindsDoNotUnify module Main where -import Prelude+import Control.Monad.Eff.Console (log) data Foo = Bar type Baz = { | Foo } -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,9 @@ -- @shouldFailWith KindsDoNotUnify module Main where -import Prelude+import Control.Monad.Eff.Console (log) type Foo r = (x :: Number | r) type Bar = { | Foo } -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,9 @@ -- @shouldFailWith KindsDoNotUnify module Main where -import Prelude+import Control.Monad.Eff.Console (log) type Foo = { x :: Number } type Bar = { | Foo } -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -7,4 +7,4 @@ test _ = do r <- runST (newSTRef 0)- return 0+ pure 0
@@ -4,4 +4,4 @@ import Prelude -f = g . g where g = (+1)+f = g . g where g = (_ + 1)
@@ -3,6 +3,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (logShow) class Su a where su :: a -> a@@ -22,4 +23,4 @@ test :: forall a. (Cl a) => a -> Array a test x = su [cl x x] -main = Control.Monad.Eff.Console.print $ test 10.0+main = logShow $ test 10.0
@@ -3,4 +3,4 @@ import Prelude -test = 1 ++ "A"+test = 1 <> "A"
@@ -1,10 +1,10 @@--- @shouldFailWith ErrorParsingModule +-- @shouldFailWith ErrorParsingModule module Main where -import Prelude+import Control.Monad.Eff.Console (log) test = (\f :: Int -> Int -> f 10) id main = do let t1 = test- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -2,8 +2,8 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) main = do- s :: String <- Control.Monad.Eff.Console.log "Foo"- Control.Monad.Eff.Console.log "Done"-+ s :: String <- log "Foo"+ log "Done"
@@ -2,6 +2,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test = case 1 of (0 :: String) -> true@@ -9,4 +10,4 @@ main = do let t = test- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,6 +1,6 @@ -- @shouldFailWith ErrorParsingModule module Bad_Module where -import Prelude+import Control.Monad.Eff.Console (log) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,4 +1,4 @@--- @shouldFailWith UnknownType+-- @shouldFailWith UnknownName module Main where import Prelude
@@ -1,5 +1,7 @@ module Main where +import Control.Monad.Eff.Console (log)+ data Person = Person String Boolean getName :: Person -> String@@ -10,4 +12,4 @@ name :: String name = getName (Person "John Smith" true) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,12 +1,14 @@-module Main where--import Prelude-import Control.Monad.Eff.Console (log)--x :: forall a. a -> String-x a = y "Done"- where- y :: forall a. (Show a) => a -> String- y a = show (a :: a)--main = log (x 0)+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +x :: forall a. a -> String +x a = y "Test" + where + y :: forall a. (Show a) => a -> String + y a = show (a :: a) + +main = do + log (x 0) + log "Done"
@@ -1,6 +1,8 @@ module Main where +import Control.Monad.Eff.Console (log)+ test :: forall a. a -> a test = \(x :: a) -> x -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -11,6 +11,6 @@ test :: forall e a. IdentityEff e a -> IdentityEff e Unit test (IdentityEff action) = IdentityEff $ do (Identity x :: Identity _) <- action- return $ Identity unit+ pure $ Identity unit main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) _2 :: forall a. a -> a _2 a = a@@ -21,4 +22,4 @@ let tmp = _2 1 pure unit -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,19 @@+module Main where++import Control.Monad.Eff.Console (log)++foo =+ 1++bar+ = 2++baz+ =+ 3++qux+ =+ 3++main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) singleton :: forall a. a -> Array a singleton x = [x]@@ -10,11 +11,12 @@ foldMap :: forall a m. (Semigroup m) => (a -> m) -> Array a -> m foldMap f [a, b, c, d, e] = f a <> f b <> f c <> f d <> f e+foldMap f xs = foldMap f xs -- spin, not used regression :: Array Int regression = let as = [1,2,3,4,5] as' = foldMap (\x -> if 1 < x && x < 4 then singleton x else empty) as in as'- -main = Control.Monad.Eff.Console.log "Done"++main = log "Done"
@@ -1,15 +1,3 @@-module B where-- data Foo = X | Y--module A where-- import B as Main-- -- Prior to the 2018 fix this would be detected as a cycle between A and Main.- foo ∷ Main.Foo → Main.Foo- foo x = x- module Main where import Prelude@@ -22,4 +10,3 @@ main = do let tmp = foo X log "Done"-
@@ -0,0 +1,7 @@+module A where++import B as Main++-- Prior to the 2018 fix this would be detected as a cycle between A and Main.+foo ∷ Main.Foo → Main.Foo+foo x = x
@@ -0,0 +1,3 @@+module B where++data Foo = X | Y
@@ -0,0 +1,14 @@+module Main where++import Prelude+import Control.Monad.Eff.Console (log)++data List a = Cons a (List a) | Nil++infixr 6 Cons as :++f :: List { x :: Int, y :: Int } -> Int+f ( r@{ x } : _) = x + r.y+f _ = 0++main = log "Done"
@@ -0,0 +1,7 @@+module Main where++import Control.Monad.Eff.Console (log)++import Lib (A(B,C))++main = log "Done"
@@ -0,0 +1,3 @@+module Lib (A(..), A) where++data A = B | C
@@ -0,0 +1,5 @@+exports['a\''] = 0;+exports["\x62\x27"] = 1;+// NOTE: I wanted to use "\c'" here, but langauge-javascript doesn't support it...+exports["c'"] = 2;+exports["\u0064\u0027"] = 3;
@@ -0,0 +1,10 @@+module Main where++import Control.Monad.Eff.Console (log)++foreign import a' :: Number+foreign import b' :: Number+foreign import c' :: Number+foreign import d' :: Number++main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class Foo a b @@ -14,4 +15,4 @@ instance baz :: (Eq a) => Baz (a -> b) a b -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Maybe a = Nothing | Just a @@ -10,4 +11,4 @@ o = case m of Nothing -> { x : Nothing } Just a -> { x : Just a } -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,6 @@ module Main where -import Prelude ()+import Control.Monad.Eff.Console (log) class Applicative f where pure :: forall a. a -> f a@@ -13,4 +13,4 @@ apply (Just f) (Just a) = Just (f a) apply _ _ = Nothing -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class Pointed p where point :: forall a. a -> p a@@ -8,4 +9,4 @@ instance pointedArray :: Pointed Array where point a = [a] -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Auto s i o = Auto { state :: s, step :: s -> i -> o } @@ -12,4 +13,4 @@ run :: forall i o. SomeAuto i o -> i -> o run = \s i -> s (\a -> case a of Auto a -> a.step a.state i) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,11 @@-module Main where--import Prelude-import Control.Monad.Eff.Console--f x = x * 10.0-g y = y - 10.0--main = log $ show $ (f <<< g) 100.0+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +f x = x * 10.0 +g y = y - 10.0 + +main = do + log $ show $ (f <<< g) 100.0 + log "Done"
@@ -1,7 +1,7 @@ module Main where import Prelude-import qualified Prelude as P+import Prelude as P import Control.Monad.Eff.Console f :: forall a. a -> a
@@ -1,11 +1,16 @@ module Main where import Prelude-import Test.Assert+import Partial.Unsafe (unsafePartial)+import Test.Assert (assert')+import Control.Monad.Eff (Eff)+import Control.Monad.Eff.Console (log) +snd :: forall a. Partial => Array a -> a snd = \[_, y] -> y +main :: Eff _ _ main = do- let ts = snd [1.0, 2.0]+ let ts = unsafePartial (snd [1.0, 2.0]) assert' "Incorrect result from 'snd'." (ts == 2.0)- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,10 +1,11 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) foo = bar where bar r = r + 1.0 r = foo 2.0 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,8 +1,9 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) foo :: String foo = """foo""" -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,19 +1,21 @@ module Main where import Prelude+import Partial.Unsafe (unsafeCrashWith) import Control.Monad.Eff.Console import Control.Monad.Eff doIt :: forall eff. Eff eff Boolean-doIt = return true+doIt = pure true set = do log "Testing..." case 0 of 0 -> doIt- _ -> return false+ _ -> pure false main = do b <- set case b of true -> log "Done"+ false -> unsafeCrashWith "Failed"
@@ -1,19 +1,21 @@ module Main where import Prelude+import Partial.Unsafe (unsafeCrashWith) import Control.Monad.Eff.Console import Control.Monad.Eff doIt :: forall eff. Eff eff Boolean-doIt = return true+doIt = pure true set = do log "Testing..." case 42, 10 of 42, 10 -> doIt- _ , _ -> return false+ _ , _ -> pure false main = do b <- set case b of true -> log "Done"+ false -> unsafeCrashWith "Failed"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data A = A | B | C @@ -18,4 +19,4 @@ h f a N = a h f (J a) (J b) = J (f a b) -main = Control.Monad.Eff.Console.log $ f "Done" "Failed" A+main = log $ f "Done" "Failed" A
@@ -1,7 +1,8 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test = ((\x -> x+1.0) >>> (\x -> x*2.0)) 4.0 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) length :: forall a. Array a -> Int length _ = 0@@ -9,4 +10,4 @@ foo _ = length ([] :: Foo Number) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Bar a = Bar data Baz@@ -14,5 +15,4 @@ mkBar :: forall a. a -> Bar a mkBar _ = Bar -main = Control.Monad.Eff.Console.log "Done"-+main = log "Done"
@@ -1,6 +1,6 @@ module Main where -import Prelude ()+import Control.Monad.Eff.Console (log) type List a = forall r. r -> (a -> r -> r) -> r @@ -15,4 +15,4 @@ test = append (cons 1 empty) (cons 2 empty) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,13 +1,9 @@-module Lib (class X, go) where-- class X a where- go :: a -> a- module Main where - import Lib (class X, go)+import Lib (class X, go)+import Control.Monad.Eff.Console (log) - go' :: forall a. (X a) => a -> a- go' = go+go' :: forall a. (X a) => a -> a+go' = go - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,4 @@+module Lib (class X, go) where++class X a where+ go :: a -> a
@@ -3,6 +3,7 @@ import Prelude import Control.Monad.Eff import Control.Monad.ST+import Control.Monad.Eff.Console (log, logShow) collatz :: Int -> Int collatz n = runPure (runST (do@@ -12,7 +13,9 @@ modifySTRef count $ (+) 1 m <- readSTRef r writeSTRef r $ if m `mod` 2 == 0 then m / 2 else 3 * m + 1- return $ m == 1+ pure $ m == 1 readSTRef count)) -main = Control.Monad.Eff.Console.print $ collatz 1000+main = do+ logShow $ collatz 1000+ log "Done"
@@ -1,15 +1,15 @@-module Main where--import Prelude-import Control.Monad.Eff-import Control.Monad.Eff.Console-import Test.Assert--main = do- assert (1.0 < 2.0)- assert (2.0 == 2.0)- assert (3.0 > 1.0)- assert ("a" < "b")- assert ("a" == "a")- assert ("z" > "a")- log "Done!"+module Main where + +import Prelude +import Control.Monad.Eff +import Control.Monad.Eff.Console +import Test.Assert + +main = do + assert (1.0 < 2.0) + assert (2.0 == 2.0) + assert (3.0 > 1.0) + assert ("a" < "b") + assert ("a" == "a") + assert ("z" > "a") + log "Done"
@@ -1,9 +1,9 @@ module Main where -import Prelude ()+import Control.Monad.Eff.Console (log) fns = \f -> if f true then f else \x -> x not = \x -> if x then false else true -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -5,9 +5,11 @@ import Control.Monad.Eff.Console replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {}-replicateM_ 0.0 _ = return {}+replicateM_ 0.0 _ = pure {} replicateM_ n act = do act replicateM_ (n - 1.0) act -main = replicateM_ 10.0 (log "Hello World!")+main = do+ replicateM_ 10.0 (log "Hello World!")+ log "Done"
@@ -1,7 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) -shout = Control.Monad.Eff.Console.log <<< (<> "!") <<< show+shout = log <<< (_ <> "!") <<< show -main = shout "Done"+main = do+ shout "Test"+ log "Done"
@@ -3,11 +3,13 @@ import Prelude import Control.Monad.Eff.Console -shout = log <<< (<> "!") <<< show+shout = log <<< (_ <> "!") <<< show -- Here, we should simplify the context so that only one Show -- constraint is added. usesShowTwice true = shout-usesShowTwice false = print+usesShowTwice false = logShow -main = usesShowTwice true "Done"+main = do+ usesShowTwice true "Test"+ log "Done"
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data A = A B type B = A -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,17 +1,11 @@-module Data.List where-- data List a = Cons a (List a) | Nil-- infixr 6 Cons as :- module Main where import Prelude (Unit, bind, (==)) import Control.Monad.Eff (Eff) import Control.Monad.Eff.Console (CONSOLE, log) import Test.Assert (ASSERT, assert')- import Data.List (List(..), (:))- import Data.List as L+ import List (List(..), (:))+ import List as L -- unqualified infixl 6 Cons as !
@@ -0,0 +1,5 @@+module List where++data List a = Cons a (List a) | Nil++infixr 6 Cons as :
@@ -2,6 +2,7 @@ import Prelude import Control.Monad.Eff+import Control.Monad.Eff.Console (log) import Test.Assert data List a = Cons a (List a) | Nil@@ -13,4 +14,4 @@ main = do let result = match2 (Cons 1.0 (Cons 2.0 (Cons 3.0 (Cons 4.0 (Cons 5.0 (Cons 6.0 (Cons 7.0 (Cons 8.0 (Cons 9.0 Nil))))))))) assert' "Incorrect result!" (result == 100.0)- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,9 +1,7 @@ module Main where import Prelude-import Control.Monad.Eff.Console-import Control.Monad.Eff-import Control.Monad.ST+import Control.Monad.Eff.Console (log, logShow) f x y = let@@ -12,4 +10,6 @@ x -> 1.0 + x * x in g + x + y -main = print $ f 1.0 10.0+main = do+ logShow $ f 1.0 10.0+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) import Test.Assert data V@@ -27,5 +28,7 @@ assert $ X 0 < X 1 assert $ X 0 < Y "Foo" assert $ Y "Bar" < Y "Baz"- assert $ z == z where- z = Z { left: X 0, right: Y "Foo" }+ assert $ z == z+ log "Done"+ where+ z = Z { left: X 0, right: Y "Foo" }
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Maybe a = Nothing | Just a @@ -19,7 +20,7 @@ bind Nothing _ = Nothing bind (Just a) f = f a -instance monadMaybe :: Prelude.Monad Maybe+instance monadMaybe :: Monad Maybe test1 = \_ -> do Just "abc"@@ -64,4 +65,4 @@ g x = f x / 2.0 Just (f 10.0) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,11 +1,11 @@ module Main where -import Prelude ()+import Control.Monad.Eff.Console (log) -($) :: forall a b. (a -> b) -> a -> b-($) f x = f x+applyFn :: forall a b. (a -> b) -> a -> b+applyFn f x = f x -infixr 1000 $+infixr 1000 applyFn as $ id x = x @@ -13,4 +13,4 @@ test2 x = id id $ id x -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -3,7 +3,7 @@ import Prelude import Control.Monad.Eff import Control.Monad.ST-import Control.Monad.Eff.Console+import Control.Monad.Eff.Console (log, logShow) test1 = do log "Line 1"@@ -21,5 +21,6 @@ main = do test1- Control.Monad.Eff.Console.print test2- Control.Monad.Eff.Console.print test3+ logShow test2+ logShow test3+ log "Done"
@@ -2,6 +2,7 @@ import Prelude import Test.Assert+import Control.Monad.Eff.Console (log) data Z data S n@@ -15,5 +16,5 @@ cons' x (ArrayBox xs) = ArrayBox $ append [x] xs main = case cons' 1 $ cons' 2 $ cons' 3 nil of- ArrayBox [1, 2, 3] -> Control.Monad.Eff.Console.log "Done"+ ArrayBox [1, 2, 3] -> log "Done" _ -> assert' "Failed" false
@@ -1,10 +1,11 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Foo r = Foo { | r } test :: Foo () test = Foo {} -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,12 +1,11 @@ module Main where import Prelude--class PartialP+import Control.Monad.Eff+import Control.Monad.Eff.Console -head :: forall a. (PartialP) => Array a -> a+head :: forall a. Partial => Array a -> a head [x] = x -instance allowPartials :: PartialP--main = Control.Monad.Eff.Console.log $ head ["Done"]+main :: Eff _ _+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) data Pair a b = Pair a b @@ -12,4 +13,6 @@ instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where eq (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2 -main = Control.Monad.Eff.Console.print $ Pair 1.0 2.0 == Pair 1.0 2.0+main = do+ logShow $ Pair 1.0 2.0 == Pair 1.0 2.0+ log "Done"
@@ -1,16 +1,11 @@--- from #1244-module Foo where-- foo :: Int- foo = 3--module Bar (module Foo) where-- import Foo--module Baz where-- import Bar (foo)-- baz :: Int- baz = foo+-- from #1244 +module Main where + +import Prelude +import Control.Monad.Eff.Console (log) +import Bar (foo) + +baz :: Int +baz = foo + +main = log "Done"
@@ -0,0 +1,3 @@+module Bar (module Foo) where + +import Foo
@@ -0,0 +1,4 @@+module Foo where + +foo :: Int +foo = 3
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) subtractOne :: Int -> Int subtractOne = (_ - 1)@@ -11,4 +12,4 @@ named :: Int -> Int named = (_ `sub` 1) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,10 @@+module Main where + +import M1 +import Control.Monad.Eff.Console (log) + +testX = X +testZ = Z +testFoo = foo + +main = log "Done"
@@ -0,0 +1,10 @@+module M1 (X(X), Z(..), foo) where + +data X = X | Y +data Z = Z + +foo :: Int +foo = 0 + +bar :: Int +bar = 1
@@ -0,0 +1,8 @@+module Main where + +import M1 +import Control.Monad.Eff.Console (log) + +testBar = bar + +main = log "Done"
@@ -0,0 +1,7 @@+module M1 (bar) where + +foo :: Int +foo = 0 + +bar :: Int +bar = foo
@@ -0,0 +1,45 @@+-- Tests that instances for non-exported classes / types do not appear in the+-- result of `exportedDeclarations`.+module Main+ ( Const(..)+ , class Foo+ , foo+ , main+ ) where++import Prelude+import Control.Monad.Eff.Console (log)++data Const a b = Const a++class Foo a where+ foo :: a++data NonexportedType = NonexportedType++class NonexportedClass a where+ notExported :: a++-- There are three places that a nonexported type or type class can occur,+-- leading an instance to count as non-exported:+-- * Constraints+-- * The type class itself+-- * The instance types++-- Case 1: constraints+instance nonExportedFoo :: (NonexportedClass a) => Foo a where+ foo = notExported++-- Another instance of case 1:+instance nonExportedFoo2 :: (Foo NonexportedType) => Foo (a -> a) where+ foo = id++-- Case 2: type class+instance nonExportedNonexportedType :: NonexportedClass (Const Int a) where+ notExported = Const 0++-- Case 3: instance types+instance constFoo :: Foo (Const NonexportedType b) where+ foo = Const NonexportedType++main = log "Done"
@@ -1,9 +1,11 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow)+import Data.Function (on) comparing :: forall a b. (Ord b) => (a -> b) -> a -> a -> Ordering-comparing f = compare `Data.Function.on` f+comparing f = compare `on` f null [] = true null _ = false@@ -11,4 +13,5 @@ test = [1.0, 2.0, 3.0] `comparing null` [4.0, 5.0, 6.0] main = do- Control.Monad.Eff.Console.print test+ logShow test+ log "Done"
@@ -1,15 +1,18 @@ module Main where import Prelude-import Control.Monad.Eff-import Control.Monad.ST+import Control.Monad.Eff (whileE)+import Control.Monad.Eff.Console (log, logShow)+import Control.Monad.ST (runST, newSTRef, readSTRef, writeSTRef) -main = runST (do- n1 <- newSTRef 1.0- n2 <- newSTRef 1.0- whileE ((>) 1000.0 <$> readSTRef n1) $ do- n1' <- readSTRef n1- n2' <- readSTRef n2- writeSTRef n2 $ n1' + n2'- writeSTRef n1 n2'- Control.Monad.Eff.Console.print n2')+main = do+ runST do+ n1 <- newSTRef 1.0+ n2 <- newSTRef 1.0+ whileE ((>) 1000.0 <$> readSTRef n1) $ do+ n1' <- readSTRef n1+ n2' <- readSTRef n2+ writeSTRef n2 $ n1' + n2'+ writeSTRef n1 n2'+ logShow n2'+ log "Done"
@@ -1,10 +1,13 @@-module Main where--import Prelude-import Control.Monad.Eff.Console--greet { greeting, name } = log $ greeting <> ", " <> name <> "."--main = greet { greeting, name} where- greeting = "Hello"- name = "World"+module Main where + +import Prelude +import Control.Monad.Eff.Console (log, logShow) + +greet { greeting, name } = log $ greeting <> ", " <> name <> "." + +main = do + greet { greeting, name } + log "Done" + where + greeting = "Hello" + name = "World"
@@ -1,8 +1,10 @@-module Main where--import Prelude-import Control.Monad.Eff.Console--greet { greeting, name } = log $ greeting <> ", " <> name <> "."--main = greet { greeting: "Hello", name: "World" } +module Main where + +import Prelude +import Control.Monad.Eff.Console + +greet { greeting, name } = log $ greeting <> ", " <> name <> "." + +main = do + greet { greeting: "Hello", name: "World" } + log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude hiding (add)+import Control.Monad.Eff.Console (log, logShow) class E e where num :: Number -> e Number@@ -19,4 +20,6 @@ three :: Expr Number three = add (num 1.0) (num 2.0) -main = Control.Monad.Eff.Console.print $ runId three+main = do+ logShow $ runId three+ log "Done"
@@ -2,6 +2,7 @@ import Prelude import Test.Assert+import Control.Monad.Eff.Console (log) mkValue :: Number -> Number mkValue id = id@@ -9,4 +10,4 @@ main = do let value = mkValue 1.0 assert $ value == 1.0- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test1 = \_ -> 0.0 @@ -8,8 +9,4 @@ test3 = \a -> a -test4 = \(%%) -> 1.0 %% 2.0--test5 = \(+++) (***) -> 1.0 +++ 2.0 *** 3.0--main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -2,6 +2,7 @@ import Prelude import Test.Assert+import Control.Monad.Eff.Console (log) test :: forall a b. a -> b -> a test = \const _ -> const@@ -9,4 +10,4 @@ main = do let value = test "Done" {} assert' "Not done" $ value == "Done"- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,10 +1,11 @@ module Main where import Prelude-import Control.Monad.Eff.Console (print)+import Control.Monad.Eff.Console (logShow, log) main = do- print (sum 1.0 2.0)- print (sum 1 2)+ logShow (sum 1.0 2.0)+ logShow (sum 1 2)+ log "Done" sum x y = x + y
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) collatz = \x -> case x of y | y `mod` 2.0 == 0.0 -> y / 2.0@@ -26,4 +27,4 @@ | otherwise = y - x -main = Control.Monad.Eff.Console.log $ min "Done" "ZZZZ"+main = log $ min "Done" "ZZZZ"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Maybe a = Nothing | Just a @@ -8,4 +9,4 @@ test2 = if true then Nothing else Just 10 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,8 +1,9 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) main = do- Control.Monad.Eff.Console.log "Hello"- Control.Monad.Eff.Console.log "Goodbye"- Control.Monad.Eff.Console.log "Done"+ log "Hello"+ log "Goodbye"+ log "Done"
@@ -0,0 +1,6 @@+module Main where + +import M2 +import Control.Monad.Eff.Console (log) + +main = log "Done"
@@ -0,0 +1,8 @@+module M1 where + +import Prelude () + +id :: forall a. a -> a +id = \x -> x + +foo = id
@@ -0,0 +1,6 @@+module M2 where + +import Prelude () +import M1 + +main = \_ -> foo 42
@@ -0,0 +1,10 @@+module Main where + +import M1 (X(..)) +import Control.Monad.Eff.Console (log) + +testX :: X +testX = X +testY = Y + +main = log "Done"
@@ -0,0 +1,4 @@+module M1 where + +data X = X | Y +data Z = Z
@@ -3,7 +3,7 @@ import Control.Monad.Eff.Console import Prelude hiding ( show, -- a value- Show, -- a type class+ class Show, -- a type class Unit(..) -- a constructor ) @@ -15,4 +15,5 @@ data Unit = X | Y main = do- print show+ logShow show+ log "Done"
@@ -0,0 +1,8 @@+module Main where + +import Prelude +import Control.Monad.Eff +import M1 +import Control.Monad.Eff.Console as C + +main = C.log (log "Done")
@@ -0,0 +1,3 @@+module M1 where + +log x = x
@@ -1,8 +1,11 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) -test 100.0 = 100.0-test n = test(1.0 + n)+test 100 = 100+test n = test(1 + n) -main = Control.Monad.Eff.Console.print $ test 0.0+main = do+ logShow (test 0)+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) instance fooNumber :: Foo Number where foo = 0.0@@ -8,4 +9,4 @@ class Foo a where foo :: a -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -2,6 +2,7 @@ import Prelude import Control.Monad.Eff+import Control.Monad.Eff.Console (log) import Test.Assert f 1 = 1@@ -15,4 +16,4 @@ assert $ f 0 == 0 assert $ g 'a' == 'a' assert $ g 'b' == 'b'- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) yield = 0 member = 1@@ -9,4 +10,4 @@ this catch = catch -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type Star2Star f = f :: * -> * @@ -30,4 +31,4 @@ instance clazzString :: Clazz String where def = "test" -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,5 +1,7 @@ module Main where- ++import Control.Monad.Eff.Console (log)+ data Large = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z explode A A = "A"@@ -30,4 +32,4 @@ explode Z Z = "Z" explode _ _ = "" -main = Control.Monad.Eff.Console.log "Done" +main = log "Done"
@@ -1,7 +1,9 @@ module Main where import Prelude+import Partial.Unsafe (unsafePartial) import Control.Monad.Eff+import Control.Monad.Eff.Console (log, logShow) import Control.Monad.ST test1 x = let@@ -17,8 +19,9 @@ test3 = let f x y z = x + y + z in f 1.0 2.0 3.0 -test4 = let f x [y, z] = x y z in- f (+) [1.0, 2.0]+test4 = let+ f x [y, z] = x y z+ in f (+) [1.0, 2.0] test5 = let f x | x > 0.0 = g (x / 2.0) + 1.0@@ -43,11 +46,13 @@ g x = f x / 2.0 in f 10.0 +main :: Eff _ _ main = do- Control.Monad.Eff.Console.print (test1 1.0)- Control.Monad.Eff.Console.print (test2 1.0 2.0)- Control.Monad.Eff.Console.print test3- Control.Monad.Eff.Console.print test4- Control.Monad.Eff.Console.print test5- Control.Monad.Eff.Console.print test7- Control.Monad.Eff.Console.print (test8 100.0)+ logShow (test1 1.0)+ logShow (test2 1.0 2.0)+ logShow test3+ unsafePartial (logShow test4)+ logShow test5+ logShow test7+ logShow (test8 100.0)+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) test = let f :: Number -> Boolean@@ -14,4 +15,6 @@ x = f 1.0 in not x -main = Control.Monad.Eff.Console.print test+main = do+ logShow test+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class Foo a where foo :: a -> String@@ -11,4 +12,4 @@ go :: String -> String go s = s -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type Reader = (->) String @@ -9,13 +10,13 @@ type AndFoo r = (foo :: String | r) -getFoo :: forall r. Prim.Object (AndFoo r) -> String+getFoo :: forall r. Prim.Record (AndFoo r) -> String getFoo o = o.foo type F r = { | r } -> { | r } f :: (forall r. F r) -> String f g = case g { x: "Hello" } of- { x = x } -> x+ { x: x } -> x -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class NullaryTypeClass where greeting :: String@@ -14,7 +15,7 @@ instance coerceRefl :: Coerce a a where coerce a = a -instance coerceShow :: (Prelude.Show a) => Coerce a String where+instance coerceShow :: Show a => Coerce a String where coerce = show -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Foo a = Foo foo = \f -> case f of Foo -> "foo" -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,7 @@+module Main where++import M1+import M2+import Control.Monad.Eff.Console (log)++main = log "Done"
@@ -0,0 +1,14 @@+module M1 where++import Prelude++data Foo = Foo String++foo :: Foo -> String+foo = \f -> case f of Foo s -> s <> "foo"++bar :: Foo -> String+bar = foo++incr :: Int -> Int+incr x = x + 1
@@ -0,0 +1,10 @@+module M2 where++import Prelude+import M1 as M1++baz :: M1.Foo -> String+baz = M1.foo++match :: M1.Foo -> String+match = \f -> case f of M1.Foo s -> s <> "foo"
@@ -0,0 +1,6 @@+module Main where + +import M1 +import Control.Monad.Eff.Console (log) + +main = log "Done"
@@ -0,0 +1,5 @@+module M1 where + +import M2 as M2 + +foo = M2.bar
@@ -0,0 +1,5 @@+module M2 where + +import M3 as M3 + +bar = M3.baz
@@ -0,0 +1,3 @@+module M3 where + +baz = 1
@@ -1,9 +1,8 @@-module A (module Prelude) where- import Prelude- module Main where- import Control.Monad.Eff.Console- import A - main = do- print (show 1.0)+import Control.Monad.Eff.Console (log, logShow)+import A++main = do+ logShow (show 1.0)+ log "Done"
@@ -0,0 +1,3 @@+module A (module Prelude) where++import Prelude
@@ -1,14 +1,5 @@-module A (module Prelude) where- import Prelude--module B (module Prelude) where- import Prelude--module C (module Prelude, module A) where- import Prelude- import A- module Main where+ import Control.Monad.Eff.Console import A import B@@ -16,4 +7,5 @@ import Prelude main = do- print (show 1.0)+ logShow (show 1.0)+ log "Done"
@@ -0,0 +1,3 @@+module A (module Prelude) where++import Prelude
@@ -0,0 +1,3 @@+module B (module Prelude) where++import Prelude
@@ -0,0 +1,4 @@+module C (module Prelude, module A) where++import Prelude+import A
@@ -1,14 +1,11 @@-module A (module Prelude, foo) where- import Prelude-- foo :: Number -> Number- foo _ = 0.0- module Main where- import Control.Monad.Eff.Console- import A (foo) - otherwise = false+import Prelude+import Control.Monad.Eff.Console (log, logShow)+import A (foo) - main = do- print "1.0"+otherwise = false++main = do+ logShow "1.0"+ log "Done"
@@ -0,0 +1,6 @@+module A (module Prelude, foo) where++import Prelude++foo :: Number -> Number+foo _ = 0.0
@@ -1,9 +1,9 @@-module A (module Prelude) where- import Prelude- module Main where- import Control.Monad.Eff.Console- import qualified A as B - main = do- print (B.show 1.0)+import Prelude+import Control.Monad.Eff.Console (log, logShow)+import A as B++main = do+ logShow (B.show 1.0)+ log "Done"
@@ -0,0 +1,3 @@+module A (module Prelude) where++import Prelude
@@ -1,14 +1,11 @@-module A (module A, module Prelude) where- import Prelude-- type Foo = Boolean- module Main where- import Control.Monad.Eff.Console- import A - bar :: Foo- bar = true+import Control.Monad.Eff.Console+import A - main = do- print (show bar)+bar :: Foo+bar = true++main = do+ logShow (show bar)+ log "Done"
@@ -0,0 +1,5 @@+module A (module A, module Prelude) where + +import Prelude + +type Foo = Boolean
@@ -1,6 +1,6 @@ module Main where -import Prelude ()+import Control.Monad.Eff.Console (log) type Monad m = { return :: forall a. a -> m a , bind :: forall a b. m a -> (a -> m b) -> m b }@@ -29,4 +29,4 @@ test2 = test maybe -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -58,4 +58,6 @@ same :: forall a. (a -> a) -> (a -> a) same = id -main = print $ runState 0 (modify (+ 1))+main = do+ logShow $ runState 0 (modify (_ + 1))+ log "Done"
@@ -1,7 +1,7 @@ module Main where import Prelude-import Data.Function+import Data.Function.Uncurried import Control.Monad.Eff import Control.Monad.Eff.Console @@ -23,5 +23,5 @@ runFn8 (mkFn8 $ \a b c d e f g h -> log $ show [a, b, c, d, e, f, g, h]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 runFn9 (mkFn9 $ \a b c d e f g h i -> log $ show [a, b, c, d, e, f, g, h, i]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 runFn10 (mkFn10 $ \a b c d e f g h i j-> log $ show [a, b, c, d, e, f, g, h, i, j]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0- print $ runFn2 g 0.0 0.0- log "Done!"+ logShow $ runFn2 g 0.0 0.0+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) f 0.0 = 0.0 f x = g x + 0.0@@ -16,4 +17,4 @@ oddToNumber (Odd n) = evenToNumber n + 0.0 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data A = A B @@ -16,4 +17,4 @@ showN :: A -> S showN a = f a -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data A = A B @@ -16,4 +17,4 @@ showN :: A -> S showN a = f a -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) foo = \x -> case x of- y@{ foo = "Foo" } -> y+ y@{ foo: "Foo" } -> y y -> y -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test :: Number -> Boolean test -1.0 = false test _ = true -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,8 +1,9 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) n :: Int n = -2147483648 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Extend r a = Extend { prev :: r a, next :: a } data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type X = String type Y = X -> X@@ -8,4 +9,4 @@ fn :: Y fn a = a -main = Control.Monad.Eff.Console.print (fn "Done")+main = log (fn "Done")
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) f x = g x where@@ -9,4 +10,4 @@ go x = go1 (x - 1.0) go1 x = go x -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -7,17 +7,17 @@ newtype Thing = Thing String instance showThing :: Show Thing where- show (Thing x) = "Thing " ++ show x+ show (Thing x) = "Thing " <> show x newtype Box a = Box a instance showBox :: (Show a) => Show (Box a) where- show (Box x) = "Box " ++ show x+ show (Box x) = "Box " <> show x apply f x = f x main = do- print $ Thing "hello"- print $ Box 42.0- print $ apply Box 9000.0+ logShow $ Thing "hello"+ logShow $ Box 42.0+ logShow $ apply Box 9000.0 log "Done"
@@ -5,9 +5,9 @@ import Prelude import Control.Monad.Eff.Console -newtype NewType a = NewType (Object a)+newtype NewType a = NewType (Record a) -rec1 :: Object (a :: Number, b :: Number, c:: Number)+rec1 :: Record (a :: Number, b :: Number, c:: Number) rec1 = { a: 0.0, b: 0.0, c: 0.0 } rec2 :: NewType (a :: Number, b :: Number, c :: Number)
@@ -1,14 +1,10 @@-module A where-- thing :: Int- thing = 1- -- No failure here as the export `thing` only refers to Main.thing module Main (thing, main) where - import A+import A+import Control.Monad.Eff.Console (log) - thing :: Int- thing = 2+thing :: Int+thing = 2 - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,39 @@+module Main where++-- See issue #2115.++import Prelude+import Test.Assert (assert')+import Control.Monad.Eff.Console (log)++main = do+ test "0.17" 0.17+ test "0.25996181067141905" 0.25996181067141905+ test "0.3572019862807257" 0.3572019862807257+ test "0.46817723004874223" 0.46817723004874223+ test "0.9640035681058178" 0.9640035681058178+ test "4.23808622486133" 4.23808622486133+ test "4.540362294799751" 4.540362294799751+ test "5.212384849884261" 5.212384849884261+ test "13.958257048123212" 13.958257048123212+ test "32.96176575630599" 32.96176575630599+ test "38.47735512322269" 38.47735512322269++ test "10000000000" 1e10+ test "10000000000" 1.0e10+ test "0.00001" 1e-5+ test "0.00001" 1.0e-5+ test "1.5339794352098402e-118" 1.5339794352098402e-118+ test "2.108934760892056e-59" 2.108934760892056e-59+ test "2.250634744599241e-19" 2.250634744599241e-19+ test "5.960464477539063e-8" 5.960464477539063e-8+ test "5e-324" 5e-324+ test "5e-324" 5.0e-324++ log "Done"++test str num =+ if (show num == str)+ then pure unit+ else flip assert' false $+ "Expected " <> show str <> ", got " <> show (show num) <> "."
@@ -1,13 +1,14 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) getX = _.x point = { x: 1.0, y: 0.0 } main = do- Control.Monad.Eff.Console.print $ getX point- Control.Monad.Eff.Console.log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }- Control.Monad.Eff.Console.log $ (_.x >>> _.y) { x: { y: "Nested" } }- Control.Monad.Eff.Console.log $ _.value { value: "Done!" }+ logShow $ getX point+ log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }+ log $ (_.x >>> _.y) { x: { y: "Nested" } }+ log $ _.value { value: "Done" }
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type Inner = Number @@ -12,4 +13,4 @@ outer :: Outer outer = { inner: inner } -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,20 +1,23 @@-module Main where--import Prelude--update1 = \o -> o { foo = "Foo" }--update2 :: forall r. { foo :: String | r } -> { foo :: String | r }-update2 = \o -> o { foo = "Foo" }--replace = \o -> case o of- { foo = "Foo" } -> o { foo = "Bar" }- { foo = "Bar" } -> o { bar = "Baz" }- o -> o--polyUpdate :: forall a r. { foo :: a | r } -> { foo :: String | r }-polyUpdate = \o -> o { foo = "Foo" }--inferPolyUpdate = \o -> o { foo = "Foo" }--main = Control.Monad.Eff.Console.log ((update1 {foo: ""}).foo)+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +update1 = \o -> o { foo = "Foo" } + +update2 :: forall r. { foo :: String | r } -> { foo :: String | r } +update2 = \o -> o { foo = "Foo" } + +replace = \o -> case o of + { foo: "Foo" } -> o { foo = "Bar" } + { foo: "Bar" } -> o { bar = "Baz" } + o -> o + +polyUpdate :: forall a r. { foo :: a | r } -> { foo :: String | r } +polyUpdate = \o -> o { foo = "Foo" } + +inferPolyUpdate = \o -> o { foo = "Foo" } + +main = do + log ((update1 {foo: ""}).foo) + log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type X r = { | r } @@ -14,4 +15,4 @@ { baz = "blah" } -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -6,7 +6,7 @@ import Test.Assert getValue :: forall e. Eff (| e) Boolean-getValue = return true+getValue = pure true main = do let record = { value: false }@@ -22,3 +22,5 @@ let record2 = (_ { x = _ }) { x: 0.0 } 10.0 assert $ record2.x == 10.0++ log "Done"
@@ -8,13 +8,13 @@ mkRecord = { foo: _, bar: _, baz: "baz" } getValue :: forall e. Eff (| e) Boolean-getValue = return true+getValue = pure true main = do obj <- { value: _ } <$> getValue- print obj.value+ logShow obj.value let x = 1.0- point <- { x: _, y: x } <$> return 2.0+ point <- { x: _, y: x } <$> pure 2.0 assert $ point.x == 2.0 assert $ point.y == 1.0- log (mkRecord 1.0 "Done!").bar+ log (mkRecord 1.0 "Done").bar
@@ -1,6 +1,7 @@ module Main where import Prelude hiding (append)+import Control.Monad.Eff.Console (log) test = \x -> x.foo + x.bar + 1.0 @@ -25,11 +26,11 @@ weirdObj = { "!@#": 1.0 } test5 = case { "***": 1.0 } of- { "***" = n } -> n+ { "***": n } -> n test6 = case { "***": 1.0 } of { "***": n } -> n test7 {a: snoog , b : blah } = blah -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data One a = One a one' (One a) = a -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,8 +1,3 @@-module Def where--what :: forall a b. a -> b -> a-what a _ = a- module Main where import Prelude
@@ -0,0 +1,4 @@+module Def where + +what :: forall a b. a -> b -> a +what a _ = a
@@ -1,25 +1,25 @@-module Main where--import Prelude-import Control.Monad.Eff-import Control.Monad.Eff.Console-import Test.Assert--bug :: Number -> Number -> Number-bug a b = 0.0 - (a - b)--main = do- assert (bug 0.0 2.0 == 2.0)- assert (0.0 - (0.0 - 2.0) == 2.0)- assert (0.0 - (0.0 + 2.0) == -2.0)- assert (6.0 / (3.0 * 2.0) == 1.0)- assert ((6.0 / 3.0) * 2.0 == 4.0)- assert (not (1.0 < 0.0) == true)- assert (not ((negate 1.0) < 0.0) == false)- assert (negate (1.0 + 10.0) == -11.0)- assert (2.0 * 3.0 / 4.0 == 1.5)- assert (1.0 * 2.0 * 3.0 * 4.0 * 5.0 / 6.0 == 20.0)- assert (1.0 + 10.0 - 5.0 == 6.0)- assert (1.0 + 10.0 * 5.0 == 51.0)- assert (10.0 * 5.0 - 1.0 == 49.0)- log "Success!"+module Main where + +import Prelude +import Control.Monad.Eff +import Control.Monad.Eff.Console +import Test.Assert + +bug :: Number -> Number -> Number +bug a b = 0.0 - (a - b) + +main = do + assert (bug 0.0 2.0 == 2.0) + assert (0.0 - (0.0 - 2.0) == 2.0) + assert (0.0 - (0.0 + 2.0) == -2.0) + assert (6.0 / (3.0 * 2.0) == 1.0) + assert ((6.0 / 3.0) * 2.0 == 4.0) + assert (not (1.0 < 0.0) == true) + assert (not ((negate 1.0) < 0.0) == false) + assert (negate (1.0 + 10.0) == -11.0) + assert (2.0 * 3.0 / 4.0 == 1.5) + assert (1.0 * 2.0 * 3.0 * 4.0 * 5.0 / 6.0 == 20.0) + assert (1.0 + 10.0 - 5.0 == 6.0) + assert (1.0 + 10.0 * 5.0 == 51.0) + assert (10.0 * 5.0 - 1.0 == 49.0) + log "Done"
@@ -1,47 +1,48 @@ module Main where import Prelude-import Control.Monad.Eff.Console+import Control.Monad.Eff.Console (logShow, log) main = do -- semiringNumber- print (1.0 + 2.0)- print (1.0 * 2.0)+ logShow (1.0 + 2.0)+ logShow (1.0 * 2.0) -- ringNumber- print (1.0 - 2.0)- print (negate 1.0)+ logShow (1.0 - 2.0)+ logShow (negate 1.0) -- moduleSemiringNumber- print (1.0 / 2.0)+ logShow (1.0 / 2.0) -- ordNumber- print (1.0 > 2.0)- print (1.0 < 2.0)- print (1.0 <= 2.0)- print (1.0 >= 2.0)- print (1.0 == 2.0)+ logShow (1.0 > 2.0)+ logShow (1.0 < 2.0)+ logShow (1.0 <= 2.0)+ logShow (1.0 >= 2.0)+ logShow (1.0 == 2.0) -- eqNumber- print (1.0 == 2.0)- print (1.0 /= 2.0)+ logShow (1.0 == 2.0)+ logShow (1.0 /= 2.0) -- eqString- print ("foo" == "bar")- print ("foo" /= "bar")+ logShow ("foo" == "bar")+ logShow ("foo" /= "bar") -- eqBoolean- print (true == false)- print (true /= false)+ logShow (true == false)+ logShow (true /= false) -- semigroupString- print ("foo" ++ "bar")- print ("foo" <> "bar")+ logShow ("foo" <> "bar") -- latticeBoolean- print (top && true)- print (bottom || false)+ logShow (top && true)+ logShow (bottom || false) -- complementedLatticeBoolean- print (not true)+ logShow (not true)++ log "Done"
@@ -1,17 +1,18 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) import Test.Assert main = do- assert $ (/ 2.0) 4.0 == 2.0- assert $ (2.0 /) 4.0 == 0.5- assert $ (`const` 1.0) 2.0 == 2.0- assert $ (1.0 `const`) 2.0 == 1.0+ assert $ (_ / 2.0) 4.0 == 2.0+ assert $ (2.0 / _) 4.0 == 0.5+ assert $ (_ `const` 1.0) 2.0 == 2.0+ assert $ (1.0 `const` _) 2.0 == 1.0 let foo = { x: 2.0 }- assert $ (/ foo.x) 4.0 == 2.0- assert $ (foo.x /) 4.0 == 0.5- let (//) x y = x.x / y.x- assert $ (// foo { x = 4.0 }) { x: 4.0 } == 1.0- assert $ (foo { x = 4.0 } //) { x: 4.0 } == 1.0- Control.Monad.Eff.Console.log "Done!"+ assert $ (_ / foo.x) 4.0 == 2.0+ assert $ (foo.x / _) 4.0 == 0.5+ let div x y = x.x / y.x+ assert $ (_ `div` foo { x = 4.0 }) { x: 4.0 } == 1.0+ assert $ (foo { x = 4.0 } `div` _) { x: 4.0 } == 1.0+ log "Done"
@@ -1,16 +1,17 @@ module Main where import Prelude+import Other (foo)+import Other as Other import Control.Monad.Eff import Control.Monad.Eff.Console -(?!) :: forall a. a -> a -> a-(?!) x _ = x+op1 :: forall a. a -> a -> a+op1 x _ = x -bar :: String -> String -> String-bar = \s1 s2 -> s1 ++ s2+infix 4 op1 as ?! -test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n+test1 :: forall n. (Semiring n) => n -> n -> (n -> n -> n) -> n test1 x y z = x * y + z x y test2 = (\x -> x.foo false) { foo : \_ -> 1.0 }@@ -21,40 +22,39 @@ test4 = 1 `k` 2 -infixl 5 %%+op2 :: Number -> Number -> Number+op2 x y = x * y + y -(%%) :: Number -> Number -> Number-(%%) x y = x * y + y+infixl 5 op2 as %% test5 = 1.0 %% 2.0 %% 3.0 test6 = ((\x -> x) `k` 2.0) 3.0 -(<+>) :: String -> String -> String-(<+>) = \s1 s2 -> s1 ++ s2+op3 :: String -> String -> String+op3 = \s1 s2 -> s1 <> s2 +infix 4 op3 as <+>+ test7 = "Hello" <+> "World!" -(@@) :: forall a b. (a -> b) -> a -> b-(@@) = \f x -> f x+op4 :: forall a b. (a -> b) -> a -> b+op4 = \f x -> f x -foo :: String -> String-foo = \s -> s+infix 4 op4 as @@ test8 = foo @@ "Hello World" -test9 = Main.foo @@ "Hello World"--test10 = "Hello" `Main.bar` "World"+test9 = Other.foo @@ "Hello World" -(...) :: forall a. Array a -> Array a -> Array a-(...) = \as -> \bs -> as+test10 = "Hello" `Other.baz` "World" -test11 = [1.0, 2.0, 0.0] ... [4.0, 5.0, 6.0]+op5 :: forall a. Array a -> Array a -> Array a+op5 = \as -> \bs -> as -test12 (<%>) a b = a <%> b+infix 4 op5 as ... -test13 = \(<%>) a b -> a <%> b+test11 = [1.0, 2.0, 0.0] ... [4.0, 5.0, 6.0] test14 :: Number -> Number -> Boolean test14 a b = a < b@@ -71,11 +71,6 @@ test19 :: Number test19 = negate $ negate (-1.0) -test20 :: Number-test20 = 1.0 @ 2.0- where- (@) x y = x + y * y- main = do let t1 = test1 1.0 2.0 (\x y -> x + y) let t2 = test2@@ -88,12 +83,9 @@ let t9 = test9 let t10 = test10 let t11 = test11- let t12 = test12 k 1.0 2.0- let t13 = test13 k 1.0 2.0 let t14 = test14 1.0 2.0 let t15 = test15 1.0 2.0 let t17 = test17 let t18 = test18 let t19 = test19- let t20 = test20 log "Done"
@@ -0,0 +1,7 @@+module Other where++foo :: String -> String+foo s = s++baz :: String -> String -> String+baz s _ = s
@@ -1,9 +1,10 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) x a = 1.0 + y a y a = x a -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,7 +1,6 @@ module Main where --- qualified import with the "qualified" keyword-import qualified Prelude as P+import Prelude as P -- qualified import without the "qualified" keyword import Control.Monad.Eff.Console as Console@@ -9,5 +8,5 @@ bind = P.bind main = do- message <- P.return "success!"+ message <- P.pure "Done" Console.log message
@@ -1,13 +1,17 @@-module Main where--import Prelude--data A = A--instance showA1 :: Show A where- show A = "Instance 1"--instance showA2 :: Show A where- show A = "Instance 2"--main = Test.Assert.assert $ show A == "Instance 1"+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) +import Test.Assert (assert) + +data A = A + +instance showA1 :: Show A where + show A = "Instance 1" + +instance showA2 :: Show A where + show A = "Instance 2" + +main = do + assert $ show A == "Instance 1" + log "Done"
@@ -1,23 +1,27 @@-module Main where--import Prelude--data A = A | B--instance eqA1 :: Eq A where- eq A A = true- eq B B = true- eq _ _ = false--instance eqA2 :: Eq A where- eq _ _ = true--instance ordA :: Ord A where- compare A B = LT- compare B A = GT- compare _ _ = EQ--test :: forall a. (Ord a) => a -> a -> String-test x y = show $ x == y--main = Test.Assert.assert $ test A B == "false"+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) +import Test.Assert (assert) + +data A = A | B + +instance eqA1 :: Eq A where + eq A A = true + eq B B = true + eq _ _ = false + +instance eqA2 :: Eq A where + eq _ _ = true + +instance ordA :: Ord A where + compare A B = LT + compare B A = GT + compare _ _ = EQ + +test :: forall a. (Ord a) => a -> a -> String +test x y = show $ x == y + +main = do + assert $ test A B == "false" + log "Done"
@@ -1,16 +1,20 @@-module Main where--import Prelude--class Foo a--instance foo1 :: Foo Number--instance foo2 :: Foo Number--test :: forall a. (Foo a) => a -> a-test a = a--test1 = test 0.0--main = Test.Assert.assert (test1 == 0.0)+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) +import Test.Assert (assert) + +class Foo a + +instance foo1 :: Foo Number + +instance foo2 :: Foo Number + +test :: forall a. (Foo a) => a -> a +test a = a + +test1 = test 0.0 + +main = do + assert (test1 == 0.0) + log "Done"
@@ -0,0 +1,20 @@+module Main where++import Prelude+import Control.Monad.Eff (Eff)+import Control.Monad.Eff.Console (CONSOLE, log)++foo :: Array Int+foo = do+ xss :: Array (Array Int) <- [[[1,2,3], [4, 5]], [[6]]]+ xs :: Array Int <- xss+ xs++main :: + forall eff.+ Eff+ ( console :: CONSOLE+ | eff+ )+ Unit+main = log "Done"
@@ -1,9 +1,11 @@ module Main where import Prelude-import Test.Assert+import Control.Monad.Eff+import Control.Monad.Eff.Console +fn :: Partial => Number -> Number fn 0.0 = 0.0 fn 1.0 = 2.0 -main = assertThrows $ \_ -> fn 2.0+main = log "Done"
@@ -1,14 +1,15 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test = \x -> case x of- { str = "Foo", bool = true } -> true- { str = "Bar", bool = b } -> b+ { str: "Foo", bool: true } -> true+ { str: "Bar", bool: b } -> b _ -> false f = \o -> case o of- { foo = "Foo" } -> o.bar+ { foo: "Foo" } -> o.bar _ -> 0 h = \o -> case o of@@ -19,4 +20,4 @@ isDesc [x, y] | x > y = true isDesc _ = false -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,17 +1,8 @@-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2- module Main where - -- No error as we never force `thing` to be resolved in `Main`- import A- import B+-- No error as we never force `thing` to be resolved in `Main`+import A+import B+import Control.Monad.Eff.Console (log) - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,4 @@+module B where++thing :: Int+thing = 2
@@ -1,14 +1,10 @@-module A where-- thing :: Int- thing = 1- module Main where - import A+import A+import Control.Monad.Eff.Console (log) - -- No error as we never force `thing` to be resolved in `Main`- thing :: Int- thing = 2+-- No error as we never force `thing` to be resolved in `Main`+thing :: Int+thing = 2 - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -1,11 +1,12 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Person = Person { name :: String, age :: Number } showPerson :: Person -> String showPerson = \p -> case p of- Person o -> o.name ++ ", aged " ++ show o.age+ Person o -> o.name <> ", aged " <> show o.age -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,20 @@+module Main (T, T', T'', T''', main) where + +import Prelude +import Control.Monad.Eff.Console (log) + +data T a = T +type T' = T Unit + +data T'' = TP + +foreign import data T''' ∷ * + +instance eqT ∷ Eq T'' where + eq _ _ = true + +type A' a b = b → a + +infixr 4 type A' as ↫ + +main = log "Done"
@@ -0,0 +1,11 @@+module Main where + +import Prelude +import Either as Either +import Control.Monad.Eff.Console (log) + +either :: forall a b c. (a -> c) -> (b -> c) -> Either.Either a b -> c +either f _ (Either.Left x) = f x +either _ g (Either.Right y) = g y + +main = log (either id id (Either.Left "Done"))
@@ -0,0 +1,5 @@+module Either where + +import Prelude + +data Either a b = Left a | Right b
@@ -1,6 +1,6 @@ module Main where -- qualified import with qualified imported names-import qualified Control.Monad.Eff.Console (log) as Console+import Control.Monad.Eff.Console (log) as Console -main = Console.log "Success!"+main = Console.log "Done"
@@ -1,29 +1,30 @@-module Main where--import Prelude hiding (add)--data Id = Id forall a. a -> a--runId = \id a -> case id of- Id f -> f a--data Nat = Nat forall r. r -> (r -> r) -> r--runNat = \nat -> case nat of- Nat f -> f 0.0 (\n -> n + 1.0)--zero' = Nat (\zero' _ -> zero')--succ = \n -> case n of- Nat f -> Nat (\zero' succ -> succ (f zero' succ))--add = \n m -> case n of- Nat f -> case m of- Nat g -> Nat (\zero' succ -> g (f zero' succ) succ)--one' = succ zero'-two = succ zero'-four = add two two-fourNumber = runNat four--main = Control.Monad.Eff.Console.log "Done'"+module Main where + +import Prelude hiding (add) +import Control.Monad.Eff.Console (log) + +data Id = Id forall a. a -> a + +runId = \id a -> case id of + Id f -> f a + +data Nat = Nat forall r. r -> (r -> r) -> r + +runNat = \nat -> case nat of + Nat f -> f 0.0 (\n -> n + 1.0) + +zero' = Nat (\zero' _ -> zero') + +succ = \n -> case n of + Nat f -> Nat (\zero' succ -> succ (f zero' succ)) + +add = \n m -> case n of + Nat f -> case m of + Nat g -> Nat (\zero' succ -> g (f zero' succ) succ) + +one' = succ zero' +two = succ zero' +four = add two two +fourNumber = runNat four + +main = log "Done"
@@ -6,6 +6,6 @@ data Foo = Foo { id :: forall a. a -> a } foo :: Foo -> Number-foo (Foo { id = f }) = f 0.0+foo (Foo { id: f }) = f 0.0 main = log "Done"
@@ -1,7 +1,7 @@ module Main where import Prelude-import Control.Monad.Eff+import Control.Monad.Eff.Console (log, logShow) type Foo a = forall f. (Monad f) => f a @@ -13,4 +13,5 @@ main = do x <- bar- Control.Monad.Eff.Console.print x+ logShow x+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test1 :: (forall a. (a -> a)) -> Number test1 = \f -> f 0.0@@ -8,4 +9,4 @@ forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b forever = \bind action -> bind action $ \_ -> forever bind action -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,16 +1,7 @@-module A where- x = "Do"--module B where- y = "ne"--module C (module A, module M2) where- import A- import qualified B as M2- module Main where - import Prelude- import C+import Prelude+import C+import Control.Monad.Eff.Console (log) - main = Control.Monad.Eff.Console.log (x ++ y)+main = log (x <> y)
@@ -0,0 +1,3 @@+module A where++x = "Do"
@@ -0,0 +1,3 @@+module B where++y = "ne"
@@ -0,0 +1,4 @@+module C (module A, module M2) where++import A+import B as M2
@@ -1,39 +1,43 @@-module Main where--import Prelude--example1 :: String-example1 = do- "Do"- " notation"- " for"- " Semigroup"- where- bind x f = x <> f unit--(*>) :: forall f a b. (Apply f) => f a -> f b -> f b-(*>) fa fb = const id <$> fa <*> fb--newtype Const a b = Const a--runConst :: forall a b. Const a b -> a-runConst (Const a) = a--instance functorConst :: Functor (Const a) where- map _ (Const a) = Const a--instance applyConst :: (Semigroup a) => Apply (Const a) where- apply (Const a1) (Const a2) = Const (a1 <> a2)--example2 :: Const String Unit-example2 = do- Const "Do"- Const " notation"- Const " for"- Const " Apply"- where- bind x f = x *> f unit--main = do- Control.Monad.Eff.Console.log example1- Control.Monad.Eff.Console.log $ runConst example2+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +example1 :: String +example1 = do + "Do" + " notation" + " for" + " Semigroup" + where + bind x f = x <> f unit + +applySecond :: forall f a b. (Apply f) => f a -> f b -> f b +applySecond fa fb = const id <$> fa <*> fb + +infixl 4 applySecond as *> + +newtype Const a b = Const a + +runConst :: forall a b. Const a b -> a +runConst (Const a) = a + +instance functorConst :: Functor (Const a) where + map _ (Const a) = Const a + +instance applyConst :: (Semigroup a) => Apply (Const a) where + apply (Const a1) (Const a2) = Const (a1 <> a2) + +example2 :: Const String Unit +example2 = do + Const "Do" + Const " notation" + Const " for" + Const " Apply" + where + bind x f = x *> f unit + +main = do + log example1 + log $ runConst example2 + log "Done"
@@ -1,10 +1,11 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) fib = \n -> case n of 0.0 -> 1.0 1.0 -> 1.0 n -> fib (n - 1.0) + fib (n - 2.0) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,6 @@+module Main where + +import M3 +import Control.Monad.Eff.Console (log) + +main = log "Done"
@@ -0,0 +1,6 @@+module M1 where + +applyFn :: forall a b. (forall c d. c -> d) -> a -> b +applyFn f a = f a + +infixr 1000 applyFn as $
@@ -0,0 +1,5 @@+module M2 where + +import Prelude () + +import M1
@@ -0,0 +1,6 @@+module M3 where + +import Prelude () + +import M1 +import M2
@@ -2,6 +2,8 @@ module Main where import Prelude+import Control.Monad.Eff+import Control.Monad.Eff.Console (log) o :: { type :: String } o = { type: "o" }@@ -10,6 +12,8 @@ p = o { type = "p" } f :: forall r. { type :: String | r } -> String-f { type = "p" } = "Done"+f { type: "p" } = "Done"+f _ = "Fail" -main = Control.Monad.Eff.Console.log $ f { type: p.type, foo: "bar" }+main :: Eff _ _+main = log $ f { type: p.type, foo: "bar" }
@@ -1,25 +1,13 @@-module A where-- thing :: Int- thing = 1--module B where-- thing :: Int- thing = 2-- zing :: Int- zing = 3- module Main where - import A (thing)- import B+import A (thing)+import B+import Control.Monad.Eff.Console (log) - -- Not an error as although we have `thing` in scope from both A and B, it is- -- imported explicitly from A, giving it a resolvable solution.- what :: Boolean -> Int- what true = thing- what false = zing+-- Not an error as although we have `thing` in scope from both A and B, it is+-- imported explicitly from A, giving it a resolvable solution.+what :: Boolean -> Int+what true = thing+what false = zing - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -0,0 +1,7 @@+module B where++thing :: Int+thing = 2++zing :: Int+zing = 3
@@ -1,22 +1,15 @@-module A where-- thing :: Int- thing = 2-- zing :: Int- zing = 3- module Main where - import A+import A+import Control.Monad.Eff.Console (log) - thing :: Int- thing = 1+thing :: Int+thing = 1 - -- Not an error as although we have `thing` in scope from both Main and A,- -- as the local declaration takes precedence over the implicit import- what :: Boolean -> Int- what true = thing- what false = zing+-- Not an error as although we have `thing` in scope from both Main and A,+-- as the local declaration takes precedence over the implicit import+what :: Boolean -> Int+what true = thing+what false = zing - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,7 @@+module A where++thing :: Int+thing = 2++zing :: Int+zing = 3
@@ -1,15 +1,9 @@-module A where-- thing :: Int- thing = 1- module Main (thing, main, module A) where - import A-- thing :: Int- thing = 2-- main = Control.Monad.Eff.Console.log "Done"+import A+import Control.Monad.Eff.Console (log) +thing :: Int+thing = 2 +main = log "Done"
@@ -0,0 +1,4 @@+module A where++thing :: Int+thing = 1
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type Foo = (x :: Number | (y :: Number | (z :: Number))) type Bar = (x :: Number, y :: Number, z :: Number)@@ -12,7 +13,7 @@ bar :: { | Bar } bar = { x: 0.0, y: 0.0, z: 0.0 } -id' :: Object Foo -> Object Bar+id' :: Record Foo -> Record Bar id' = id foo' :: { | Foo }@@ -39,4 +40,4 @@ wildcard' :: { | Quux _ } -> Number wildcard' { q: q } = q -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class T s m where state :: (s -> s) -> m Unit@@ -11,12 +12,12 @@ state f = S $ \s -> { new: f s, ret: unit } test1 :: forall r . S { foo :: String | r } Unit-test1 = state $ \o -> o { foo = o.foo ++ "!" }+test1 = state $ \o -> o { foo = o.foo <> "!" } test2 :: forall m r . (T { foo :: String | r } m) => m Unit-test2 = state $ \o -> o { foo = o.foo ++ "!" }+test2 = state $ \o -> o { foo = o.foo <> "!" } main = do let t1 = test1 let t2 = test2- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) class A a where a :: a -> Boolean@@ -16,4 +17,6 @@ b 0.0 = false b n = a (n - 1.0) -main = Control.Monad.Eff.Console.print $ a 10.0+main = do+ logShow $ a 10.0+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test1 :: forall a. (a -> a) -> a -> a test1 f x = g (g x)@@ -33,4 +34,4 @@ j x = x -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -2,6 +2,7 @@ import Prelude import Control.Monad.Eff+import Control.Monad.Eff.Console (log) data List a = Cons a (List a) | Nil @@ -12,4 +13,4 @@ sequence Nil = pure Nil sequence (Cons x xs) = Cons <$> x <*> sequence xs -main = sequence $ Cons (Control.Monad.Eff.Console.log "Done") Nil+main = sequence $ Cons (log "Done") Nil
@@ -2,6 +2,7 @@ import Prelude import Control.Monad.Eff+import Control.Monad.Eff.Console (log) data List a = Cons a (List a) | Nil @@ -31,7 +32,7 @@ Cons x xs -> Cons <$> x <*> sequence sequenceList''' xs) :: forall m a. (Monad m) => List (m a) -> m (List a)) main = do- sequence sequenceList $ Cons (Control.Monad.Eff.Console.log "Done") Nil- sequence sequenceList' $ Cons (Control.Monad.Eff.Console.log "Done") Nil- sequence sequenceList'' $ Cons (Control.Monad.Eff.Console.log "Done") Nil- sequence sequenceList''' $ Cons (Control.Monad.Eff.Console.log "Done") Nil+ sequence sequenceList $ Cons (log "Done") Nil+ sequence sequenceList' $ Cons (log "Done") Nil+ sequence sequenceList'' $ Cons (log "Done") Nil+ sequence sequenceList''' $ Cons (log "Done") Nil
@@ -1,15 +1,8 @@-module Test where-- data Z = Z String-- runZ :: Z -> String- runZ (Z s) = s- module Main where - import Test- import Control.Monad.Eff.Console+import Test+import Control.Monad.Eff.Console - data Test = Test+data Test = Test - main = log (runZ (Z "done"))+main = log (runZ (Z "Done"))
@@ -0,0 +1,6 @@+module Test where++data Z = Z String++runZ :: Z -> String+runZ (Z s) = s
@@ -0,0 +1,11 @@+module Main where + +import Prelude +import Control.Monad.Eff.Console +import Control.Monad.Eff.Console (log) + +done :: String +done = let str = "Not yet done" in + let str = "Done" in str + +main = log done
@@ -1,18 +1,21 @@-module Main where--import Prelude hiding (add)--runNat f = f 0.0 (\n -> n + 1.0)--zero' z _ = z--succ f zero' succ = succ (f zero' succ)--add f g zero' succ = g (f zero' succ) succ--one' = succ zero'-two = succ one'-four = add two two-fourNumber = runNat four--main = Control.Monad.Eff.Console.log $ show fourNumber+module Main where + +import Prelude hiding (add) +import Control.Monad.Eff.Console (log) + +runNat f = f 0.0 (\n -> n + 1.0) + +zero' z _ = z + +succ f zero' succ = succ (f zero' succ) + +add f g zero' succ = g (f zero' succ) succ + +one' = succ zero' +two = succ one' +four = add two two +fourNumber = runNat four + +main = do + log $ show fourNumber + log "Done"
@@ -1,9 +1,15 @@-module Main where--import Prelude--f x y z =- let f 1.0 2.0 3.0 = 1.0- in f x z y--main = Control.Monad.Eff.Console.log $ show $ f 1.0 3.0 2.0+module Main where + +import Prelude +import Partial.Unsafe (unsafePartial) +import Control.Monad.Eff +import Control.Monad.Eff.Console (log) + +f x y z = + let f 1.0 2.0 3.0 = 1.0 + in f x z y + +main :: Eff _ _ +main = do + log $ show $ unsafePartial f 1.0 3.0 2.0 + log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) p = 0.5 q = 1.0@@ -14,4 +15,4 @@ test1 = 2.0 - 1.0 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,15 +1,17 @@-module Main where--import Prelude ((==), bind)-import Test.Assert (assert)--singleCharacter = "\0\b\t\n\v\f\r\"\\" == "\x0\x8\x9\xA\xB\xC\xD\x22\x5C"-hex = "\x1D306\x2603\x3C6\xE0\x0" == "𝌆☃φà\0"-decimal = "\119558\9731\966\224\0" == "𝌆☃φà\0"-surrogatePair = "\xD834\xDF06" == "\x1D306"--main = do- assert singleCharacter- assert hex- assert decimal- assert surrogatePair+module Main where + +import Prelude ((==), bind) +import Test.Assert (assert) +import Control.Monad.Eff.Console (log) + +singleCharacter = "\0\b\t\n\v\f\r\"\\" == "\x0\x8\x9\xA\xB\xC\xD\x22\x5C" +hex = "\x1D306\x2603\x3C6\xE0\x0" == "𝌆☃φà\0" +decimal = "\119558\9731\966\224\0" == "𝌆☃φà\0" +surrogatePair = "\xD834\xDF06" == "\x1D306" + +main = do + assert singleCharacter + assert hex + assert decimal + assert surrogatePair + log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) class Su a where su :: a -> a@@ -17,4 +18,6 @@ test :: forall a. (Cl a) => a -> a test a = su (cl a a) -main = Control.Monad.Eff.Console.print $ test 10.0+main = do+ logShow $ test 10.0+ log "Done"
@@ -28,7 +28,7 @@ apply = ap instance applicativeMTrace :: Applicative MTrace where- pure = MTrace <<< return+ pure = MTrace <<< pure instance bindMTrace :: Bind MTrace where bind m f = MTrace (runMTrace m >>= (runMTrace <<< f))
@@ -1,20 +1,20 @@ module Main where import Prelude-import Control.Monad.Eff.Console (print)+import Control.Monad.Eff.Console (log, logShow) main = do let f x = x + 1 let v = 0- print (applyN 0 f v)- print (applyN 1 f v)- print (applyN 2 f v)- print (applyN 3 f v)- print (applyN 4 f v)+ logShow (applyN 0 f v)+ logShow (applyN 1 f v)+ logShow (applyN 2 f v)+ logShow (applyN 3 f v)+ logShow (applyN 4 f v)+ log "Done" applyN :: forall a. Int -> (a -> a) -> a -> a applyN = go id where go f n _ | n <= 0 = f go f n g = go (f >>> g) (n - 1) g-
@@ -1,10 +1,11 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Data = One | More Data -main = Control.Monad.Eff.Console.log (from (to 10000.0 One))+main = log (from (to 10000.0 One)) where to 0.0 a = a to n a = to (n - 1.0) (More a)
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log, logShow) data L a = C a (L a) | N @@ -14,4 +15,6 @@ notATailCall = \x -> (\notATailCall -> notATailCall x) (\x -> x) -main = Control.Monad.Eff.Console.print (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))+main = do+ logShow (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))+ log "Done"
@@ -1,7 +1,8 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test' x = x -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) gcd :: Number -> Number -> Number gcd 0.0 x = x@@ -15,4 +16,4 @@ parseTest A 0.0 = 0.0 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,9 @@+module Main where++ import Prelude+ import Middle+ import Control.Monad.Eff.Console++ main = do+ logShow (middle unit)+ log "Done"
@@ -0,0 +1,5 @@+module Middle where++import Test (test)++middle = test
@@ -0,0 +1,9 @@+module Test where++import Prelude++class TestCls a where+ test :: a -> a++instance unitTestCls :: TestCls Unit where+ test _ = unit
@@ -1,13 +1,16 @@-module Main where--import Prelude--class Test a where- fn :: a -> a -> a- val :: a--instance testBoolean :: Test Boolean where- val = true- fn x y = y--main = Control.Monad.Eff.Console.log (show (fn true val))+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +class Test a where + fn :: a -> a -> a + val :: a + +instance testBoolean :: Test Boolean where + val = true + fn x y = y + +main = do + log (show (fn true val)) + log "Done"
@@ -1,23 +1,24 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) test1 = \_ -> show "testing" -f :: forall a. (Prelude.Show a) => a -> String+f :: forall a. (Show a) => a -> String f x = show x test2 = \_ -> f "testing" -test7 :: forall a. (Prelude.Show a) => a -> String+test7 :: forall a. (Show a) => a -> String test7 = show test8 = \_ -> show $ "testing" data Data a = Data a -instance showData :: (Prelude.Show a) => Prelude.Show (Data a) where- show (Data a) = "Data (" ++ show a ++ ")"+instance showData :: (Show a) => Show (Data a) where+ show (Data a) = "Data (" <> show a <> ")" test3 = \_ -> show (Data "testing") @@ -53,9 +54,9 @@ instance monadMaybe :: Monad Maybe test4 :: forall a m. (Monad m) => a -> m Number-test4 = \_ -> return 1.0+test4 = \_ -> pure 1.0 -test5 = \_ -> Just 1.0 >>= \n -> return (n + 1.0)+test5 = \_ -> Just 1.0 >>= \n -> pure (n + 1.0) ask r = r @@ -63,7 +64,8 @@ test9 _ = runReader 0.0 $ do n <- ask- return $ n + 1.0--main = Control.Monad.Eff.Console.log (test7 "Done")+ pure $ n + 1.0 +main = do+ log (test7 "Hello")+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class Foo a where foo :: a -> String@@ -8,4 +9,4 @@ instance fooString :: Foo String where foo s = s -main = Control.Monad.Eff.Console.log $ foo "Done"+main = log $ foo "Done"
@@ -1,11 +1,12 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Either a b = Left a | Right b -instance functorEither :: Prelude.Functor (Either a) where+instance functorEither :: Functor (Either a) where map _ (Left x) = Left x map f (Right y) = Right (f y) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) k :: String -> Number -> String k x y = x@@ -9,4 +10,4 @@ iterate 0.0 f a = a iterate n f a = iterate (n - 1.0) f (f a) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,34 +1,20 @@-module A- ( Tuple(..)- , type (/\)- , (/\)- , Natural- , type (~>)- ) where-- data Tuple a b = Tuple a b-- infixl 6 Tuple as /\- infixl 6 type Tuple as /\-- type Natural f g = ∀ a. f a → g a-- infixr 0 type Natural as ~>+module Main where - tup ∷ ∀ a b. a → b → b /\ a- tup a b = b /\ a+import A (type (~>), type (/\), (/\))+import Control.Monad.Eff.Console (log) - tupX ∷ ∀ a b c. a /\ b /\ c → c- tupX (a /\ b /\ c) = c+natty ∷ ∀ f. f ~> f+natty x = x -module Main where+data Compose f g a = Compose (f (g a)) - import A (type (~>), type (/\), (/\))+testPrecedence1 ∷ ∀ f g. Compose f g ~> Compose f g+testPrecedence1 x = x - natty ∷ ∀ f. f ~> f- natty x = x+testPrecedence2 ∷ ∀ f g. f ~> g → f ~> g+testPrecedence2 nat fx = nat fx - swap ∷ ∀ a b. a /\ b → b /\ a- swap (a /\ b) = b /\ a+swap ∷ ∀ a b. a /\ b → b /\ a+swap (a /\ b) = b /\ a - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,22 @@+module A+( Tuple(..)+, type (/\)+, (/\)+, Natural+, type (~>)+) where++data Tuple a b = Tuple a b++infixl 6 Tuple as /\+infixl 6 type Tuple as /\++type Natural f g = ∀ a. f a → g a++infixr 0 type Natural as ~>++tup ∷ ∀ a b. a → b → b /\ a+tup a b = b /\ a++tupX ∷ ∀ a b c. a /\ b /\ c → c+tupX (a /\ b /\ c) = c
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type A a = Array a @@ -8,4 +9,4 @@ foo (Foo []) = Bar -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) type Lens a b = { get :: a -> b@@ -24,4 +25,4 @@ test1 :: forall a b c. Lens (Pair (Pair a b) c) a test1 = composeLenses fst fst -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) testTopLevel :: _ -> _ testTopLevel n = n + 1.0@@ -12,4 +13,4 @@ go a1 a2 | a1 == a2 = a1 go a1 _ = go (f a1) a1 -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,8 +1,9 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) foo :: forall a. {b :: Number | a} -> {b :: Number | _} foo f = f -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,16 +1,12 @@-module Lib (X, Y) where-- data X = X- type Y = X- module Main where - import Lib (X, Y)+import Lib (X, Y)+import Control.Monad.Eff.Console (log) - idX :: X -> X- idX x = x+idX :: X -> X+idX x = x - idY :: Y -> Y- idY y = y+idY :: Y -> Y+idY y = y - main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,4 @@+module Lib (X, Y) where++data X = X+type Y = X
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Tuple a b = Tuple a b @@ -31,27 +32,27 @@ get = State (\s -> Tuple s s) put s = State (\_ -> Tuple s {}) -modify :: forall m s. (Prelude.Monad m, MonadState s m) => (s -> s) -> m {}+modify :: forall m s. (Monad m, MonadState s m) => (s -> s) -> m {} modify f = do s <- get put (f s) test :: Tuple String String test = runState "" $ do- modify $ (++) "World!"- modify $ (++) "Hello, "+ modify $ (<>) "World!"+ modify $ (<>) "Hello, " str :: String <- get- return str+ pure str test2 :: (Int -> Int) -> Int test2 = (\(f :: Int -> Int) -> f 10) -test3 :: Int -> Boolean +test3 :: Int -> Boolean test3 n = case n of (0 :: Int) -> true _ -> false -test4 :: Tuple Int Int -> Tuple Int Int +test4 :: Tuple Int Int -> Tuple Int Int test4 = (\(Tuple a b :: Tuple Int Int) -> Tuple b a) type Int1 = Int@@ -64,4 +65,4 @@ t2 = test2 id t3 = test3 1 t4 = test4 (Tuple 1 0)- Control.Monad.Eff.Console.log "Done"+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data E a b = L a | R b @@ -14,4 +15,4 @@ go ls (C (L a) rest) = go (C a ls) rest go ls (C _ rest) = go ls rest -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,10 +1,8 @@-module Main where--import Control.Monad.Eff.Console- --- '→' is multibyte sequence \u2192.-utf8multibyte = "Hello λ→ world!!"--main = do- log "done"-+module Main where + +import Control.Monad.Eff.Console + +-- '→' is multibyte sequence \u2192. +utf8multibyte = "Hello λ→ world!!" + +main = log "Done"
@@ -1,11 +1,13 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) data Data_type = Con_Structor | Con_2 String type Type_name = Data_type done (Con_2 s) = s+done _ = "Failed" -main = Control.Monad.Eff.Console.log (done (Con_2 "Done"))+main = log (done (Con_2 "Done"))
@@ -1,5 +1,7 @@ module Main where +import Control.Monad.Eff.Console (log)+ f asgård = asgård -main = Control.Monad.Eff.Console.log (f "Done")+main = log (f "Done")
@@ -1,5 +1,7 @@ module Main where +import Control.Monad.Eff.Console (log)+ compose :: forall a b c. (b -> c) -> (a -> b) -> a -> c compose f g a = f (g a) @@ -17,4 +19,4 @@ test2 = 1 ∈ emptySet -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,23 +1,22 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) -class (Monad m) ⇐ Monad1 m where+class Monad m ⇐ Monad1 m where f1 :: Int -class (Monad m) <= Monad2 m where+class Monad m <= Monad2 m where f2 :: Int f ∷ ∀ m. Monad m ⇒ Int → m Int f n = do- n' ← return n- return n'+ n' ← pure n+ pure n' f' :: forall m. Monad m => Int -> m Int f' n = do- n' <- return n- return n'--(←→) a b = a ←→ b+ n' <- pure n+ pure n' -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,6 +1,8 @@ module Main where import Prelude-import Control.Monad.Eff.Console+import Control.Monad.Eff.Console (logShow, log) -main = print (const unit $ "Hello world")+main = do+ logShow (const unit $ "Hello world")+ log "Done"
@@ -1,6 +1,7 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) class EQ a b @@ -11,4 +12,4 @@ runTest a = test a a -main = Control.Monad.Eff.Console.log $ runTest 0.0+main = log $ runTest 0.0
@@ -1,7 +1,7 @@ module Main where import Prelude-import Control.Monad.Eff.Console+import Control.Monad.Eff.Console (log) class Show a <= Nonsense a where method :: a -> a
@@ -1,8 +1,9 @@ module Main where import Prelude+import Partial.Unsafe (unsafePartial) import Control.Monad.Eff-import Control.Monad.ST+import Control.Monad.Eff.Console (logShow, log) test1 x = y where@@ -14,15 +15,12 @@ x' = x + 1.0 y' = y + 1.0 - test3 = f 1.0 2.0 3.0 where f x y z = x + y + z - test4 = f (+) [1.0, 2.0] where f x [y, z] = x y z - test5 = g 10.0 where f x | x > 0.0 = g (x / 2.0) + 1.0@@ -39,11 +37,13 @@ go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y go y = go $ (y + x / y) / 2.0 +main :: Eff _ _ main = do- Control.Monad.Eff.Console.print (test1 1.0)- Control.Monad.Eff.Console.print (test2 1.0 2.0)- Control.Monad.Eff.Console.print test3- Control.Monad.Eff.Console.print test4- Control.Monad.Eff.Console.print test5- Control.Monad.Eff.Console.print test6- Control.Monad.Eff.Console.print (test7 100.0)+ logShow (test1 1.0)+ logShow (test2 1.0 2.0)+ logShow test3+ unsafePartial (logShow test4)+ logShow test5+ logShow test6+ logShow (test7 100.0)+ log "Done"
@@ -0,0 +1,12 @@+module Main where + +import Prelude +import Control.Monad.Eff.Console (log) + +f1 :: (_ -> _) -> _ +f1 g = g 1 + +f2 :: _ -> _ +f2 _ = "Done" + +main = log $ f1 f2
@@ -1,9 +1,11 @@ module Main where +import Control.Monad.Eff.Console (log)+ s = \x -> \y -> \z -> x z (y z) k = \x -> \y -> x iota = \x -> x s k -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -1,7 +1,8 @@ module Main where import Prelude+import Control.Monad.Eff.Console (log) s = \x y z -> x z (y z) -main = Control.Monad.Eff.Console.log "Done"+main = log "Done"
@@ -0,0 +1,30 @@+-- @shouldWarnWith DuplicateExportRef+-- @shouldWarnWith DuplicateExportRef+-- @shouldWarnWith DuplicateExportRef+-- @shouldWarnWith DuplicateExportRef+-- @shouldWarnWith DuplicateExportRef+-- @shouldWarnWith DuplicateExportRef+-- @shouldWarnWith DuplicateExportRef+module Main+ ( X(X, X), X+ , fn, fn+ , (!), (!)+ , class Y, class Y+ , Natural, type (~>), type (~>)+ , module Prelude, module Prelude+ ) where++import Prelude (Unit)++data X = X++fn :: X -> X -> X+fn _ _ = X++infix 2 fn as !++class Y a++type Natural f g = forall a. f a -> g a++infixl 1 type Natural as ~>
@@ -0,0 +1,10 @@+-- @shouldWarnWith DuplicateImport+module Main where++import Prelude (Unit, unit, pure)+import Prelude (Unit, unit, pure)++import Control.Monad.Eff (Eff)++main :: Eff () Unit+main = pure unit
@@ -0,0 +1,18 @@+-- @shouldWarnWith DuplicateImportRef+-- @shouldWarnWith DuplicateImportRef+-- @shouldWarnWith DuplicateImportRef+-- @shouldWarnWith DuplicateImportRef+module Main where++import Prelude+ ( Unit, Unit+ , unit, unit+ , class Functor, class Functor+ , (<>), (<>)+ )++u :: Unit+u = unit <> unit++fid :: forall f a. Functor f => f a -> f a+fid fa = fa
@@ -0,0 +1,10 @@+-- @shouldWarnWith DuplicateSelectiveImport+module Main where++import Prelude (Unit, unit)+import Prelude (pure)++import Control.Monad.Eff (Eff)++main :: Eff () Unit+main = pure unit
@@ -0,0 +1,9 @@+-- @shouldWarnWith HidingImport+-- @shouldWarnWith HidingImport+module Main where++import Prelude hiding (one)+import Control.Monad.Eff hiding (runPure)++main :: Eff () Unit+main = pure unit
@@ -0,0 +1,9 @@+-- @shouldWarnWith ImplicitImport+-- @shouldWarnWith ImplicitImport+module Main where++import Prelude+import Control.Monad.Eff++main :: Eff () Unit+main = pure unit
@@ -0,0 +1,11 @@+-- @shouldWarnWith ImplicitQualifiedImport+-- @shouldWarnWith ImplicitQualifiedImport+module Main where++import Data.Unit++import Control.Monad.Eff as E+import Control.Monad.Eff.Console as E++main :: E.Eff (console :: E.CONSOLE) Unit+main = E.log "test"
@@ -0,0 +1,4 @@+-- @shouldWarnWith MissingTypeDeclaration+module Main where++x = 0
@@ -0,0 +1,17 @@+-- @shouldWarnWith OverlappingInstances+module Main where++class Test a where+ test :: a -> a++instance testRefl :: Test a where+ test x = x++instance testInt :: Test Int where+ test _ = 0++-- The OverlappingInstances instances warning only arises when there are two+-- choices for a dictionary, not when the instances are defined. So without+-- `value` this module would not raise a warning.+value :: Int+value = test 1
@@ -0,0 +1,15 @@+-- @shouldWarnWith OverlappingPattern+-- @shouldWarnWith OverlappingPattern+module Main where++data X = A | B++pat1 :: X -> Boolean+pat1 A = true+pat1 A = true+pat1 B = false++pat2 :: X -> Boolean+pat2 A = true+pat2 _ = false+pat2 B = false
@@ -0,0 +1,13 @@+-- @shouldWarnWith ScopeShadowing+module Main where++import Prelude++-- No warning at the definition, only when the name is later resolved+data Unit = Unit++-- This is only a warning as the `Prelude` import is implicit. If `Unit` was+-- named explicitly in an import list, then this refernce to `Unit`+-- would be a `ScopeConflict` error instead.+test :: Unit+test = const Unit unit
@@ -0,0 +1,5 @@+-- @shouldWarnWith ShadowedTypeVar+module Main where++f :: forall a. (forall a. a -> a) -> a -> a+f g x = g x
@@ -0,0 +1,1 @@+exports.out = null;
@@ -0,0 +1,5 @@+-- @shouldWarnWith UnnecessaryFFIModule+module Main where++t :: Boolean+t = true
@@ -0,0 +1,8 @@+-- @shouldWarnWith UnusedDctorExplicitImport+module Main where++import Data.Ordering (Ordering(EQ, LT))++f :: Ordering -> Ordering+f EQ = EQ+f x = x
@@ -0,0 +1,7 @@+-- @shouldWarnWith UnusedDctorImport+module Main where++import Data.Ordering (Ordering(..))++f :: Ordering -> Ordering+f x = x
@@ -0,0 +1,7 @@+-- @shouldWarnWith UnusedDctorImport+module Main where++import Data.Ordering (Ordering(EQ))++f :: Ordering -> Ordering+f x = x
@@ -0,0 +1,8 @@+-- @shouldWarnWith UnusedExplicitImport+module Main where++import Prelude (Unit, unit, pure, bind)+import Control.Monad.Eff (Eff)++main :: Eff () Unit+main = pure unit
@@ -0,0 +1,2 @@+exports.yes = true;+exports.no = false;
@@ -0,0 +1,4 @@+-- @shouldWarnWith UnusedFFIImplementations+module Main where++foreign import yes :: Boolean
@@ -0,0 +1,14 @@+-- @shouldWarnWith UnusedImport+-- @shouldWarnWith UnusedImport+-- @shouldWarnWith UnusedImport+module Main where++import Data.Unit (Unit, unit)++-- All of the below are unused+import Control.Monad.Eff+import Control.Monad.Eff.Console as Console+import Test.Assert ()++main :: Unit+main = unit
@@ -0,0 +1,5 @@+-- @shouldWarnWith UnusedTypeVar+module Main where++f :: forall a b. a -> a+f x = x
@@ -0,0 +1,23 @@+-- @shouldWarnWith WildcardInferredType+-- @shouldWarnWith WildcardInferredType+-- @shouldWarnWith WildcardInferredType+-- @shouldWarnWith WildcardInferredType+module Main where++x :: Int+x = 0 :: _++y :: _+y = 0++z :: Int+z =+ let n :: _+ n = 0+ in n++w :: Int+w = n+ where+ n :: _+ n = 0
@@ -65,7 +65,7 @@ input <- glob inputGlob modules <- readInput input case modules of- Left errs -> hPutStr stderr (P.prettyPrintMultipleErrors False errs) >> exitFailure+ Left errs -> hPutStr stderr (P.prettyPrintMultipleErrors P.defaultPPEOptions errs) >> exitFailure Right ms -> do for_ ms $ \(P.Module _ _ moduleName decls _) -> let name = runModuleName moduleName@@ -84,7 +84,7 @@ superClasses :: P.Declaration -> [SuperMap] superClasses (P.TypeClassDeclaration sub _ supers@(_:_) _) =- fmap (\(P.Qualified _ super, _) -> SuperMap (Right (super, sub))) supers+ fmap (\(P.Constraint (P.Qualified _ super) _ _) -> SuperMap (Right (super, sub))) supers superClasses (P.TypeClassDeclaration sub _ _ _) = [SuperMap (Left sub)] superClasses (P.PositionedDeclaration _ _ decl) = superClasses decl superClasses _ = []@@ -113,4 +113,3 @@ infoModList = fullDesc <> headerInfo <> footerInfo headerInfo = header "hierarchy - Creates a GraphViz directed graph of PureScript TypeClasses" footerInfo = footer $ "hierarchy " ++ showVersion Paths.version-
@@ -6,7 +6,6 @@ -- | Bundles compiled PureScript modules for the browser. module Main (main) where -import Data.Maybe import Data.Traversable (for) import Data.Version (showVersion) @@ -36,7 +35,6 @@ , optionsEntryPoints :: [String] , optionsMainModule :: Maybe String , optionsNamespace :: String- , optionsRequirePath :: Maybe FilePath } deriving Show -- | Given a filename, assuming it is in the correct place on disk, infer a ModuleIdentifier.@@ -63,7 +61,7 @@ let entryIds = map (`ModuleIdentifier` Regular) optionsEntryPoints - bundle input entryIds optionsMainModule optionsNamespace optionsRequirePath+ bundle input entryIds optionsMainModule optionsNamespace -- | Command line options parser. options :: Parser Options@@ -72,7 +70,6 @@ <*> many entryPoint <*> optional mainModule <*> namespace- <*> optional requirePath where inputFile :: Parser FilePath inputFile = strArgument $@@ -104,19 +101,12 @@ <> showDefault <> help "Specify the namespace that PureScript modules will be exported to when running in the browser." - requirePath :: Parser FilePath- requirePath = strOption $- short 'r'- <> long "require-path"- <> help "The path prefix used in require() calls in the generated JavaScript [deprecated]"- -- | Make it go. main :: IO () main = do hSetEncoding stdout utf8 hSetEncoding stderr utf8 opts <- execParser (info (version <*> helper <*> options) infoModList)- when (isJust (optionsRequirePath opts)) $ hPutStrLn stderr "The require-path option is deprecated and will be removed in PureScript 0.9." output <- runExceptT (app opts) case output of Left err -> do
@@ -95,7 +95,7 @@ Right x -> return x Left err -> do- hPutStrLn stderr $ P.prettyPrintMultipleErrors False err+ hPutStrLn stderr $ P.prettyPrintMultipleErrors P.defaultPPEOptions err exitFailure takeByName = takeModulesByName D.modName
@@ -35,7 +35,7 @@ client :: PortID -> IO () client port = do h <-- connectTo "localhost" port `catch`+ connectTo "127.0.0.1" port `catch` (\(SomeException e) -> putStrLn ("Couldn't connect to psc-ide-server on port: " ++
@@ -12,7 +12,6 @@ -- The server accepting commands for psc-ide ----------------------------------------------------------------------------- -{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-}@@ -40,10 +39,10 @@ import Language.PureScript.Ide.Error import Language.PureScript.Ide.Types import Language.PureScript.Ide.Watcher-import Network hiding (socketPort)+import Network hiding (socketPort, accept) import Network.BSD (getProtocolNumber) import Network.Socket hiding (PortNumber, Type,- accept, sClose)+ sClose) import Options.Applicative import System.Directory import System.FilePath@@ -73,12 +72,13 @@ { optionsDirectory :: Maybe FilePath , optionsOutputPath :: FilePath , optionsPort :: PortID+ , optionsNoWatch :: Bool , optionsDebug :: Bool } main :: IO () main = do- Options dir outputPath port debug <- execParser opts+ Options dir outputPath port noWatch debug <- execParser opts maybe (pure ()) setCurrentDirectory dir serverState <- newTVarIO emptyPscIdeState cwd <- getCurrentDirectory@@ -89,31 +89,23 @@ (do putStrLn ("Your output directory didn't exist. I'll create it at: " <> fullOutputPath) createDirectory fullOutputPath putStrLn "This usually means you didn't compile your project yet."- putStrLn "psc-ide needs you to compile your project (for example by running pulp build)"- )+ putStrLn "psc-ide needs you to compile your project (for example by running pulp build)") - _ <- forkFinally (watcher serverState fullOutputPath) print- let conf =- Configuration- {- confDebug = debug- , confOutputPath = outputPath- }- let env =- PscIdeEnvironment- {- envStateVar = serverState- , envConfiguration = conf- }+ unless noWatch $+ void (forkFinally (watcher serverState fullOutputPath) print)++ let conf = Configuration {confDebug = debug, confOutputPath = outputPath}+ env = PscIdeEnvironment {envStateVar = serverState, envConfiguration = conf} startServer port env where parser =- Options <$>- optional (strOption (long "directory" <> short 'd')) <*>- strOption (long "output-directory" <> value "output/") <*>- (PortNumber . fromIntegral <$>- option auto (long "port" <> short 'p' <> value (4242 :: Integer))) <*>- switch (long "debug")+ Options+ <$> optional (strOption (long "directory" <> short 'd'))+ <*> strOption (long "output-directory" <> value "output/")+ <*> (PortNumber . fromIntegral <$>+ option auto (long "port" <> short 'p' <> value (4242 :: Integer)))+ <*> switch (long "no-watch")+ <*> switch (long "debug") opts = info (version <*> helper <*> parser) mempty version = abortOption (InfoMsg (showVersion Paths.version))@@ -167,7 +159,9 @@ pure (cmd, h) where acceptConnection = liftIO $ do- (h,_,_) <- accept sock+ -- Use low level accept to prevent accidental reverse name resolution+ (s,_) <- accept sock+ h <- socketToHandle s ReadWriteMode hSetEncoding h utf8 hSetBuffering h LineBuffering pure h
@@ -1,56 +1,54 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} module Main where -import Control.Applicative-import Control.Monad-import Control.Monad.Error.Class (MonadError(..))-import Control.Monad.Writer.Strict+import Control.Applicative+import Control.Monad+import Control.Monad.Writer.Strict -import Data.List (isSuffixOf, partition)-import Data.Version (showVersion)-import qualified Data.Map as M import qualified Data.Aeson as A+import Data.Bool (bool) import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.UTF8 as BU8+import qualified Data.Map as M+import Data.Version (showVersion) -import Options.Applicative as Opts+import qualified Language.PureScript as P+import Language.PureScript.Errors.JSON+import Language.PureScript.Make -import System.Exit (exitSuccess, exitFailure)-import System.IO (hSetEncoding, hPutStrLn, stdout, stderr, utf8)-import System.IO.UTF8-import System.FilePath.Glob (glob)+import Options.Applicative as Opts -import qualified Language.PureScript as P import qualified Paths_purescript as Paths -import Language.PureScript.Make-import Language.PureScript.Errors.JSON+import qualified System.Console.ANSI as ANSI+import System.Exit (exitSuccess, exitFailure)+import System.FilePath.Glob (glob)+import System.IO (hSetEncoding, hPutStrLn, stdout, stderr, utf8)+import System.IO.UTF8 data PSCMakeOptions = PSCMakeOptions { pscmInput :: [FilePath]- , pscmForeignInput :: [FilePath] , pscmOutputDir :: FilePath , pscmOpts :: P.Options , pscmUsePrefix :: Bool , pscmJSONErrors :: Bool } -data InputOptions = InputOptions- { ioInputFiles :: [FilePath]- }- -- | Argumnets: verbose, use JSON, warnings, errors printWarningsAndErrors :: Bool -> Bool -> P.MultipleErrors -> Either P.MultipleErrors a -> IO () printWarningsAndErrors verbose False warnings errors = do+ cc <- bool Nothing (Just P.defaultCodeColor) <$> ANSI.hSupportsANSI stderr+ let ppeOpts = P.defaultPPEOptions { P.ppeCodeColor = cc, P.ppeFull = verbose } when (P.nonEmpty warnings) $- hPutStrLn stderr (P.prettyPrintMultipleWarnings verbose warnings)+ hPutStrLn stderr (P.prettyPrintMultipleWarnings ppeOpts warnings) case errors of Left errs -> do- hPutStrLn stderr (P.prettyPrintMultipleErrors verbose errs)+ hPutStrLn stderr (P.prettyPrintMultipleErrors ppeOpts errs) exitFailure Right _ -> return () printWarningsAndErrors verbose True warnings errors = do@@ -65,14 +63,12 @@ when (null input && not pscmJSONErrors) $ do hPutStrLn stderr "psc: No input files." exitFailure- let (jsFiles, pursFiles) = partition (isSuffixOf ".js") input- moduleFiles <- readInput (InputOptions pursFiles)- inputForeign <- globWarningOnMisses (unless pscmJSONErrors . warnFileTypeNotFound) pscmForeignInput- foreignFiles <- forM (inputForeign ++ jsFiles) (\inFile -> (inFile,) <$> readUTF8File inFile)+ moduleFiles <- readInput input (makeErrors, makeWarnings) <- runMake pscmOpts $ do- (ms, foreigns) <- parseInputs moduleFiles foreignFiles- let filePathMap = M.fromList $ map (\(fp, P.Module _ _ mn _ _) -> (mn, fp)) ms- makeActions = buildMakeActions pscmOutputDir filePathMap foreigns pscmUsePrefix+ ms <- P.parseModulesFromFiles id moduleFiles+ let filePathMap = M.fromList $ map (\(fp, P.Module _ _ mn _ _) -> (mn, Right fp)) ms+ foreigns <- inferForeignModules filePathMap+ let makeActions = buildMakeActions pscmOutputDir filePathMap foreigns pscmUsePrefix P.make makeActions (map snd ms) printWarningsAndErrors (P.optionsVerboseErrors pscmOpts) pscmJSONErrors makeWarnings makeErrors exitSuccess@@ -89,28 +85,14 @@ return paths concatMapM f = liftM concat . mapM f -readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]-readInput InputOptions{..} = forM ioInputFiles $ \inFile -> (Right inFile, ) <$> readUTF8File inFile--parseInputs :: (MonadError P.MultipleErrors m, MonadWriter P.MultipleErrors m)- => [(Either P.RebuildPolicy FilePath, String)]- -> [(FilePath, P.ForeignJS)]- -> m ([(Either P.RebuildPolicy FilePath, P.Module)], M.Map P.ModuleName FilePath)-parseInputs modules foreigns =- (,) <$> P.parseModulesFromFiles (either (const "") id) modules- <*> P.parseForeignModulesFromFiles foreigns+readInput :: [FilePath] -> IO [(FilePath, String)]+readInput inputFiles = forM inputFiles $ \inFile -> (inFile, ) <$> readUTF8File inFile inputFile :: Parser FilePath inputFile = strArgument $ metavar "FILE" <> help "The input .purs file(s)" -inputForeignFile :: Parser FilePath-inputForeignFile = strOption $- short 'f'- <> long "ffi"- <> help "The input .js file(s) providing foreign import implementations"- outputDirectory :: Parser FilePath outputDirectory = strOption $ short 'o'@@ -119,12 +101,6 @@ <> showDefault <> help "The output directory" -requirePath :: Parser (Maybe FilePath)-requirePath = optional $ strOption $- short 'r'- <> long "require-path"- <> help "The path prefix to use for require() calls in the generated JavaScript [deprecated]"- noTco :: Parser Bool noTco = switch $ long "no-tco"@@ -175,12 +151,10 @@ <*> noOpts <*> verboseErrors <*> (not <$> comments)- <*> requirePath <*> sourceMaps pscMakeOptions :: Parser PSCMakeOptions pscMakeOptions = PSCMakeOptions <$> many inputFile- <*> many inputForeignFile <*> outputDirectory <*> options <*> (not <$> noPrefix)
@@ -0,0 +1,132 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DoAndIfThenElse #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TupleSections #-}++module Main (main) where++import Prelude ()+import Prelude.Compat++import Data.Monoid ((<>))+import Data.Version (showVersion)++import Control.Applicative (many)+import Control.Monad+import Control.Monad.IO.Class (liftIO)+import Control.Monad.Trans.Class+import Control.Monad.Trans.Except (ExceptT(..), runExceptT)+import Control.Monad.Trans.State.Strict (StateT, evalStateT)+import Control.Monad.Trans.Reader (ReaderT, runReaderT)++import qualified Language.PureScript as P+import Language.PureScript.Interactive++import qualified Options.Applicative as Opts++import qualified Paths_purescript as Paths++import System.Console.Haskeline+import System.Exit+import System.FilePath.Glob (glob)++-- | Command line options+data PSCiOptions = PSCiOptions+ { psciMultiLineMode :: Bool+ , psciInputFile :: [FilePath]+ , psciInputNodeFlags :: [String]+ }++multiLineMode :: Opts.Parser Bool+multiLineMode = Opts.switch $+ Opts.long "multi-line-mode"+ <> Opts.short 'm'+ <> Opts.help "Run in multi-line mode (use ^D to terminate commands)"++inputFile :: Opts.Parser FilePath+inputFile = Opts.strArgument $+ Opts.metavar "FILE"+ <> Opts.help "Optional .purs files to load on start"++nodeFlagsFlag :: Opts.Parser [String]+nodeFlagsFlag = Opts.option parser $+ Opts.long "node-opts"+ <> Opts.metavar "NODE_OPTS"+ <> Opts.value []+ <> Opts.help "Flags to pass to node, separated by spaces"+ where+ parser = words <$> Opts.str++psciOptions :: Opts.Parser PSCiOptions+psciOptions = PSCiOptions <$> multiLineMode+ <*> many inputFile+ <*> nodeFlagsFlag++version :: Opts.Parser (a -> a)+version = Opts.abortOption (Opts.InfoMsg (showVersion Paths.version)) $+ Opts.long "version" <>+ Opts.help "Show the version number" <>+ Opts.hidden++getOpt :: IO PSCiOptions+getOpt = Opts.execParser opts+ where+ opts = Opts.info (version <*> Opts.helper <*> psciOptions) infoModList+ infoModList = Opts.fullDesc <> headerInfo <> footerInfo+ headerInfo = Opts.header "psci - Interactive mode for PureScript"+ footerInfo = Opts.footer $ "psci " ++ showVersion Paths.version++-- | Parses the input and returns either a command, or an error as a 'String'.+getCommand :: forall m. MonadException m => Bool -> InputT m (Either String (Maybe Command))+getCommand singleLineMode = handleInterrupt (return (Right Nothing)) $ do+ firstLine <- withInterrupt $ getInputLine "> "+ case firstLine of+ Nothing -> return (Right (Just QuitPSCi)) -- Ctrl-D when input is empty+ Just "" -> return (Right Nothing)+ Just s | singleLineMode || head s == ':' -> return . fmap Just $ parseCommand s+ Just s -> fmap Just . parseCommand <$> go [s]+ where+ go :: [String] -> InputT m String+ go ls = maybe (return . unlines $ reverse ls) (go . (:ls)) =<< getInputLine " "++-- | Get command line options and drop into the REPL+main :: IO ()+main = getOpt >>= loop+ where+ loop :: PSCiOptions -> IO ()+ loop PSCiOptions{..} = do+ inputFiles <- concat <$> traverse glob psciInputFile+ e <- runExceptT $ do+ modules <- ExceptT (loadAllModules inputFiles)+ unless (supportModuleIsDefined (map snd modules)) . liftIO $ do+ putStrLn supportModuleMessage+ exitFailure+ (externs, env) <- ExceptT . runMake . make $ modules+ return (modules, externs, env)+ case e of+ Left errs -> putStrLn (P.prettyPrintMultipleErrors P.defaultPPEOptions errs) >> exitFailure+ Right (modules, externs, env) -> do+ historyFilename <- getHistoryFilename+ let settings = defaultSettings { historyFile = Just historyFilename }+ initialState = PSCiState [] [] (zip (map snd modules) externs)+ config = PSCiConfig inputFiles psciInputNodeFlags env+ runner = flip runReaderT config+ . flip evalStateT initialState+ . runInputT (setComplete completion settings)+ putStrLn prologueMessage+ runner go+ where+ go :: InputT (StateT PSCiState (ReaderT PSCiConfig IO)) ()+ go = do+ c <- getCommand (not psciMultiLineMode)+ case c of+ Left err -> outputStrLn err >> go+ Right Nothing -> go+ Right (Just QuitPSCi) -> outputStrLn quitMessage+ Right (Just c') -> do+ handleInterrupt (outputStrLn "Interrupted.")+ (withInterrupt (lift (handleCommand c')))+ go
@@ -1,372 +0,0 @@-{-# LANGUAGE DoAndIfThenElse #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE TupleSections #-}-{-# LANGUAGE DataKinds #-}---- |--- PureScript Compiler Interactive.----module PSCi (runPSCi) where--import Prelude ()-import Prelude.Compat--import Data.Foldable (traverse_)-import Data.List (intercalate, nub, sort, find)-import Data.Tuple (swap)-import qualified Data.Map as M--import Control.Arrow (first)-import Control.Monad-import Control.Monad.Error.Class (MonadError(..))-import Control.Monad.Trans.Class-import Control.Monad.Trans.Except (ExceptT(), runExceptT)-import Control.Monad.Trans.State.Strict-import Control.Monad.IO.Class (liftIO)-import Control.Monad.Writer.Strict (Writer(), runWriter)--import System.Console.Haskeline-import System.Directory (doesFileExist, getHomeDirectory, getCurrentDirectory)-import System.Exit-import System.FilePath ((</>))-import System.FilePath.Glob (glob)-import System.Process (readProcessWithExitCode)-import System.IO.Error (tryIOError)-import System.IO.UTF8 (readUTF8File)--import qualified Language.PureScript as P-import qualified Language.PureScript.Names as N--import PSCi.Completion (completion)-import PSCi.Parser (parseCommand)-import PSCi.Option-import PSCi.Types-import PSCi.Message-import PSCi.IO-import PSCi.Printer-import PSCi.Module---- |--- PSCI monad----newtype PSCI a = PSCI { runPSCI :: InputT (StateT PSCiState IO) a } deriving (Functor, Applicative, Monad)--psciIO :: IO a -> PSCI a-psciIO io = PSCI . lift $ lift io---- |--- The runner----runPSCi :: IO ()-runPSCi = getOpt >>= loop---- |--- The PSCI main loop.----loop :: PSCiOptions -> IO ()-loop PSCiOptions{..} = do- config <- loadUserConfig- inputFiles <- concat <$> traverse glob psciInputFile- foreignFiles <- concat <$> traverse glob psciForeignInputFiles- modulesOrFirstError <- loadAllModules inputFiles- case modulesOrFirstError of- Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure- Right modules -> do- historyFilename <- getHistoryFilename- let settings = defaultSettings { historyFile = Just historyFilename }- foreignsOrError <- runMake $ do- foreignFilesContent <- forM foreignFiles (\inFile -> (inFile,) <$> makeIO (const (P.ErrorMessage [] $ P.CannotReadFile inFile)) (readUTF8File inFile))- P.parseForeignModulesFromFiles foreignFilesContent- case foreignsOrError of- Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure- Right foreigns ->- flip evalStateT (mkPSCiState [] modules foreigns [] psciInputNodeFlags) . runInputT (setComplete completion settings) $ do- outputStrLn prologueMessage- traverse_ (traverse_ (runPSCI . handleCommand)) config- modules' <- lift $ gets psciLoadedModules- unless (consoleIsDefined (map snd modules')) . outputStrLn $ unlines- [ "PSCi requires the purescript-console module to be installed."- , "For help getting started, visit http://wiki.purescript.org/PSCi"- ]- go- where- go :: InputT (StateT PSCiState IO) ()- go = do- c <- getCommand (not psciMultiLineMode)- case c of- Left err -> outputStrLn err >> go- Right Nothing -> go- Right (Just QuitPSCi) -> outputStrLn quitMessage- Right (Just c') -> do- handleInterrupt (outputStrLn "Interrupted.")- (withInterrupt (runPSCI (loadAllImportedModules >> handleCommand c')))- go---- Compile the module---- |--- Load all modules, updating the application state----loadAllImportedModules :: PSCI ()-loadAllImportedModules = do- files <- PSCI . lift $ fmap psciImportedFilenames get- modulesOrFirstError <- psciIO $ loadAllModules files- case modulesOrFirstError of- Left errs -> PSCI $ printErrors errs- Right modules -> PSCI . lift . modify $ updateModules modules---- | This is different than the runMake in 'Language.PureScript.Make' in that it specifies the--- options and ignores the warning messages.-runMake :: P.Make a -> IO (Either P.MultipleErrors a)-runMake mk = fst <$> P.runMake P.defaultOptions mk--makeIO :: (IOError -> P.ErrorMessage) -> IO a -> P.Make a-makeIO f io = do- e <- liftIO $ tryIOError io- either (throwError . P.singleError . f) return e--make :: PSCiState -> [P.Module] -> P.Make P.Environment-make st@PSCiState{..} ms = P.make actions' (map snd loadedModules ++ ms)- where- filePathMap = M.fromList $ (first P.getModuleName . swap) `map` allModules- actions = P.buildMakeActions modulesDir filePathMap psciForeignFiles False- actions' = actions { P.progress = const (return ()) }- loadedModules = psciLoadedModules st- allModules = map (first Right) loadedModules ++ map (Left P.RebuildAlways,) ms----- Commands---- |--- Parses the input and returns either a Metacommand, or an error as a string.----getCommand :: Bool -> InputT (StateT PSCiState IO) (Either String (Maybe Command))-getCommand singleLineMode = handleInterrupt (return (Right Nothing)) $ do- firstLine <- withInterrupt $ getInputLine "> "- case firstLine of- Nothing -> return (Right (Just QuitPSCi)) -- Ctrl-D when input is empty- Just "" -> return (Right Nothing)- Just s | singleLineMode || head s == ':' -> return .fmap Just $ parseCommand s- Just s -> fmap Just . parseCommand <$> go [s]- where- go :: [String] -> InputT (StateT PSCiState IO) String- go ls = maybe (return . unlines $ reverse ls) (go . (:ls)) =<< getInputLine " "---- |--- Performs an action for each meta-command given, and also for expressions.----handleCommand :: Command -> PSCI ()-handleCommand (Expression val) = handleExpression val-handleCommand ShowHelp = PSCI $ outputStrLn helpMessage-handleCommand (Import im) = handleImport im-handleCommand (Decls l) = handleDecls l-handleCommand (LoadFile filePath) = PSCI $ whenFileExists filePath $ \absPath -> do- m <- lift . lift $ loadModule absPath- case m of- Left err -> outputStrLn err- Right mods -> lift $ modify (updateModules (map (absPath,) mods))-handleCommand (LoadForeign filePath) = PSCI $ whenFileExists filePath $ \absPath -> do- foreignsOrError <- lift . lift . runMake $ do- foreignFile <- makeIO (const (P.ErrorMessage [] $ P.CannotReadFile absPath)) (readUTF8File absPath)- P.parseForeignModulesFromFiles [(absPath, foreignFile)]- case foreignsOrError of- Left err -> outputStrLn $ P.prettyPrintMultipleErrors False err- Right foreigns -> lift $ modify (updateForeignFiles foreigns)-handleCommand ResetState = do- PSCI . lift . modify $ \st ->- st { psciImportedModules = []- , psciLetBindings = []- }- loadAllImportedModules-handleCommand (TypeOf val) = handleTypeOf val-handleCommand (KindOf typ) = handleKindOf typ-handleCommand (BrowseModule moduleName) = handleBrowse moduleName-handleCommand (ShowInfo QueryLoaded) = handleShowLoadedModules-handleCommand (ShowInfo QueryImport) = handleShowImportedModules-handleCommand QuitPSCi = P.internalError "`handleCommand QuitPSCi` was called. This is a bug."----- |--- Takes a value expression and evaluates it with the current state.----handleExpression :: P.Expr -> PSCI ()-handleExpression val = do- st <- PSCI $ lift get- let m = createTemporaryModule True st val- let nodeArgs = psciNodeFlags st ++ [indexFile]- e <- psciIO . runMake $ make st [supportModule, m]- case e of- Left errs -> PSCI $ printErrors errs- Right _ -> do- psciIO $ writeFile indexFile "require('$PSCI')['$main']();"- process <- psciIO findNodeProcess- result <- psciIO $ traverse (\node -> readProcessWithExitCode node nodeArgs "") process- case result of- Just (ExitSuccess, out, _) -> PSCI $ outputStrLn out- Just (ExitFailure _, _, err) -> PSCI $ outputStrLn err- Nothing -> PSCI $ outputStrLn "Couldn't find node.js"---- |--- Takes a list of declarations and updates the environment, then run a make. If the declaration fails,--- restore the original environment.----handleDecls :: [P.Declaration] -> PSCI ()-handleDecls ds = do- st <- PSCI $ lift get- let st' = updateLets ds st- let m = createTemporaryModule False st' (P.Literal (P.ObjectLiteral []))- e <- psciIO . runMake $ make st' [m]- case e of- Left err -> PSCI $ printErrors err- Right _ -> PSCI $ lift (put st')---- |--- Show actual loaded modules in psci.----handleShowLoadedModules :: PSCI ()-handleShowLoadedModules = do- loadedModules <- PSCI $ lift $ gets psciLoadedModules- psciIO $ readModules loadedModules >>= putStrLn- return ()- where readModules = return . unlines . sort . nub . map toModuleName- toModuleName = N.runModuleName . (\ (P.Module _ _ mdName _ _) -> mdName) . snd---- |--- Show the imported modules in psci.----handleShowImportedModules :: PSCI ()-handleShowImportedModules = do- PSCiState { psciImportedModules = importedModules } <- PSCI $ lift get- psciIO $ showModules importedModules >>= putStrLn- return ()- where- showModules = return . unlines . sort . map showModule- showModule (mn, declType, asQ) =- "import " ++ N.runModuleName mn ++ showDeclType declType ++- foldMap (\mn' -> " as " ++ N.runModuleName mn') asQ-- showDeclType P.Implicit = ""- showDeclType (P.Explicit refs) = refsList refs- showDeclType (P.Hiding refs) = " hiding " ++ refsList refs- refsList refs = " (" ++ commaList (map showRef refs) ++ ")"-- showRef :: P.DeclarationRef -> String- showRef (P.TypeRef pn dctors) = N.runProperName pn ++ "(" ++ maybe ".." (commaList . map N.runProperName) dctors ++ ")"- showRef (P.TypeOpRef ident) = "type (" ++ N.runIdent ident ++ ")"- showRef (P.ValueRef ident) = N.runIdent ident- showRef (P.TypeClassRef pn) = "class " ++ N.runProperName pn- showRef (P.ProperRef pn) = pn- showRef (P.TypeInstanceRef ident) = N.runIdent ident- showRef (P.ModuleRef name) = "module " ++ N.runModuleName name- showRef (P.PositionedDeclarationRef _ _ ref) = showRef ref-- commaList :: [String] -> String- commaList = intercalate ", "---- |--- Imports a module, preserving the initial state on failure.----handleImport :: ImportedModule -> PSCI ()-handleImport im = do- st <- updateImportedModules im <$> PSCI (lift get)- let m = createTemporaryModuleForImports st- e <- psciIO . runMake $ make st [m]- case e of- Left errs -> PSCI $ printErrors errs- Right _ -> do- PSCI $ lift $ put st- return ()---- |--- Takes a value and prints its type----handleTypeOf :: P.Expr -> PSCI ()-handleTypeOf val = do- st <- PSCI $ lift get- let m = createTemporaryModule False st val- e <- psciIO . runMake $ make st [m]- case e of- Left errs -> PSCI $ printErrors errs- Right env' ->- case M.lookup (P.ModuleName [P.ProperName "$PSCI"], P.Ident "it") (P.names env') of- Just (ty, _, _) -> PSCI . outputStrLn . P.prettyPrintType $ ty- Nothing -> PSCI $ outputStrLn "Could not find type"---- |--- Browse a module and displays its signature (if module exists).----handleBrowse :: P.ModuleName -> PSCI ()-handleBrowse moduleName = do- st <- PSCI $ lift get- env <- psciIO . runMake $ make st []- case env of- Left errs -> PSCI $ printErrors errs- Right env' ->- if isModInEnv moduleName st- then PSCI $ printModuleSignatures moduleName env'- else case lookupUnQualifiedModName moduleName st of- Just unQualifiedName ->- if isModInEnv unQualifiedName st- then PSCI $ printModuleSignatures unQualifiedName env'- else failNotInEnv moduleName- Nothing ->- failNotInEnv moduleName- where- isModInEnv modName =- any ((== modName) . P.getModuleName . snd) . psciLoadedModules- failNotInEnv modName =- PSCI $ outputStrLn $ "Module '" ++ N.runModuleName modName ++ "' is not valid."- lookupUnQualifiedModName quaModName st =- (\(modName,_,_) -> modName) <$> find ( \(_, _, mayQuaName) -> mayQuaName == Just quaModName) (psciImportedModules st)---- |--- Takes a value and prints its kind----handleKindOf :: P.Type -> PSCI ()-handleKindOf typ = do- st <- PSCI $ lift get- let m = createTemporaryModuleForKind st typ- mName = P.ModuleName [P.ProperName "$PSCI"]- e <- psciIO . runMake $ make st [m]- case e of- Left errs -> PSCI $ printErrors errs- Right env' ->- case M.lookup (P.Qualified (Just mName) $ P.ProperName "IT") (P.typeSynonyms env') of- Just (_, typ') -> do- let chk = (P.emptyCheckState env') { P.checkCurrentModule = Just mName }- k = check (P.kindOf typ') chk-- check :: StateT P.CheckState (ExceptT P.MultipleErrors (Writer P.MultipleErrors)) a -> P.CheckState -> Either P.MultipleErrors (a, P.CheckState)- check sew = fst . runWriter . runExceptT . runStateT sew- case k of- Left errStack -> PSCI . outputStrLn . P.prettyPrintMultipleErrors False $ errStack- Right (kind, _) -> PSCI . outputStrLn . P.prettyPrintKind $ kind- Nothing -> PSCI $ outputStrLn "Could not find kind"---- Misc---- |--- Attempts to read initial commands from '.psci' in the present working--- directory then the user's home----loadUserConfig :: IO (Maybe [Command])-loadUserConfig = onFirstFileMatching readCommands pathGetters- where- pathGetters = [getCurrentDirectory, getHomeDirectory]- readCommands :: IO FilePath -> IO (Maybe [Command])- readCommands path = do- configFile <- (</> ".psci") <$> path- exists <- doesFileExist configFile- if exists- then do- ls <- lines <$> readUTF8File configFile- case traverse parseCommand ls of- Left err -> print err >> exitFailure- Right cs -> return $ Just cs- else- return Nothing---- | Checks if the Console module is defined-consoleIsDefined :: [P.Module] -> Bool-consoleIsDefined = any ((== P.ModuleName (map P.ProperName [ "Control", "Monad", "Eff", "Console" ])) . P.getModuleName)
@@ -1,226 +0,0 @@-{-# LANGUAGE DataKinds #-}--module PSCi.Completion where--import Prelude ()-import Prelude.Compat--import Data.Maybe (mapMaybe)-import Data.List (nub, nubBy, sortBy, isPrefixOf, stripPrefix)-import Data.Char (isUpper)-import Data.Function (on)--import Control.Arrow (second)-import Control.Monad.Trans.Reader (asks, runReaderT, ReaderT)-import Control.Monad.Trans.State.Strict--import System.Console.Haskeline--import qualified Language.PureScript as P-import qualified Language.PureScript.Names as N--import qualified PSCi.Directive as D-import PSCi.Types---- Completions may read the state, but not modify it.-type CompletionM = ReaderT PSCiState IO---- Lift a `CompletionM` action to a `StateT PSCiState IO` one.-liftCompletionM :: CompletionM a -> StateT PSCiState IO a-liftCompletionM act = StateT (\s -> (\a -> (a, s)) <$> runReaderT act s)---- Haskeline completions--data CompletionContext- = CtxDirective String- | CtxFilePath String- | CtxModule- | CtxIdentifier- | CtxType- | CtxFixed String- deriving (Show, Read)---- |--- Loads module, function, and file completions.----completion :: CompletionFunc (StateT PSCiState IO)-completion = liftCompletionM . completion'--completion' :: CompletionFunc CompletionM-completion' = completeWordWithPrev Nothing " \t\n\r" findCompletions---- |--- Decide what kind of completion we need based on input. This function expects--- a list of complete words (to the left of the cursor) as the first argument,--- and the current word as the second argument.-completionContext :: [String] -> String -> [CompletionContext]-completionContext [] _ = [CtxDirective "", CtxIdentifier, CtxFixed "import"]-completionContext ws w | headSatisfies (":" `isPrefixOf`) ws = completeDirective ws w-completionContext ws w | headSatisfies (== "import") ws = completeImport ws w-completionContext _ _ = [CtxIdentifier]--completeDirective :: [String] -> String -> [CompletionContext]-completeDirective ws w =- case ws of- [] -> [CtxDirective w]- [dir] -> case D.directivesFor <$> stripPrefix ":" dir of- -- only offer completions if the directive is unambiguous- Just [dir'] -> directiveArg w dir'- _ -> []-- -- All directives take exactly one argument. If we haven't yet matched,- -- that means one argument has already been supplied. So don't complete- -- any others.- _ -> []--directiveArg :: String -> Directive -> [CompletionContext]-directiveArg _ Browse = [CtxModule]-directiveArg w Load = [CtxFilePath w]-directiveArg w Foreign = [CtxFilePath w]-directiveArg _ Quit = []-directiveArg _ Reset = []-directiveArg _ Help = []-directiveArg _ Show = map CtxFixed replQueryStrings-directiveArg _ Type = [CtxIdentifier]-directiveArg _ Kind = [CtxType]--completeImport :: [String] -> String -> [CompletionContext]-completeImport ws w' =- case (ws, w') of- (["import"], w) | headSatisfies isUpper w -> [CtxModule]- (["import"], _) -> [CtxModule, CtxFixed "qualified"]- (["import", "qualified"], _) -> [CtxModule]- _ -> []--headSatisfies :: (a -> Bool) -> [a] -> Bool-headSatisfies p str =- case str of- (c:_) -> p c- _ -> False---- | Callback for Haskeline's `completeWordWithPrev`.--- Expects:--- * Line contents to the left of the word, reversed--- * Word to be completed-findCompletions :: String -> String -> CompletionM [Completion]-findCompletions prev word = do- let ctx = completionContext (words (reverse prev)) word- completions <- concat <$> traverse getCompletions ctx- return $ sortBy directivesFirst completions- where- getCompletions :: CompletionContext -> CompletionM [Completion]- getCompletions = fmap (mapMaybe (either (prefixedBy word) Just)) . getCompletion-- prefixedBy :: String -> String -> Maybe Completion- prefixedBy w cand = if w `isPrefixOf` cand- then Just (simpleCompletion cand)- else Nothing--getCompletion :: CompletionContext -> CompletionM [Either String Completion]-getCompletion ctx =- case ctx of- CtxFilePath f -> map Right <$> listFiles f- CtxModule -> map Left <$> getModuleNames- CtxIdentifier -> map Left <$> ((++) <$> getIdentNames <*> getDctorNames)- CtxType -> map Left <$> getTypeNames- CtxFixed str -> return [Left str]- CtxDirective d -> return (map Left (completeDirectives d))-- where- completeDirectives :: String -> [String]- completeDirectives = map (':' :) . D.directiveStringsFor---getLoadedModules :: CompletionM [P.Module]-getLoadedModules = asks (map snd . psciLoadedModules)--getImportedModules :: CompletionM [ImportedModule]-getImportedModules = asks psciImportedModules--getModuleNames :: CompletionM [String]-getModuleNames = moduleNames <$> getLoadedModules--mapLoadedModulesAndQualify :: (a -> String) -> (P.Module -> [(a, P.Declaration)]) -> CompletionM [String]-mapLoadedModulesAndQualify sho f = do- ms <- getLoadedModules- let argPairs = do m <- ms- fm <- f m- return (m, fm)- concat <$> traverse (uncurry (getAllQualifications sho)) argPairs--getIdentNames :: CompletionM [String]-getIdentNames = mapLoadedModulesAndQualify P.showIdent identNames--getDctorNames :: CompletionM [String]-getDctorNames = mapLoadedModulesAndQualify P.runProperName dctorNames--getTypeNames :: CompletionM [String]-getTypeNames = mapLoadedModulesAndQualify P.runProperName typeDecls---- | Given a module and a declaration in that module, return all possible ways--- it could have been referenced given the current PSCiState - including fully--- qualified, qualified using an alias, and unqualified.-getAllQualifications :: (a -> String) -> P.Module -> (a, P.Declaration) -> CompletionM [String]-getAllQualifications sho m (declName, decl) = do- imports <- getAllImportsOf m- let fullyQualified = qualifyWith (Just (P.getModuleName m))- let otherQuals = nub (concatMap qualificationsUsing imports)- return $ fullyQualified : otherQuals- where- qualifyWith mMod = P.showQualified sho (P.Qualified mMod declName)- referencedBy refs = P.isExported (Just refs) decl-- qualificationsUsing (_, importType, asQ') =- let q = qualifyWith asQ'- in case importType of- P.Implicit -> [q]- P.Explicit refs -> [q | referencedBy refs]- P.Hiding refs -> [q | not $ referencedBy refs]----- | Returns all the ImportedModule values referring to imports of a particular--- module.-getAllImportsOf :: P.Module -> CompletionM [ImportedModule]-getAllImportsOf = asks . allImportsOf--nubOnFst :: Eq a => [(a, b)] -> [(a, b)]-nubOnFst = nubBy ((==) `on` fst)--typeDecls :: P.Module -> [(N.ProperName 'N.TypeName, P.Declaration)]-typeDecls = mapMaybe getTypeName . filter P.isDataDecl . P.exportedDeclarations- where- getTypeName :: P.Declaration -> Maybe (N.ProperName 'N.TypeName, P.Declaration)- getTypeName d@(P.TypeSynonymDeclaration name _ _) = Just (name, d)- getTypeName d@(P.DataDeclaration _ name _ _) = Just (name, d)- getTypeName (P.PositionedDeclaration _ _ d) = getTypeName d- getTypeName _ = Nothing--identNames :: P.Module -> [(N.Ident, P.Declaration)]-identNames = nubOnFst . concatMap getDeclNames . P.exportedDeclarations- where- getDeclNames :: P.Declaration -> [(P.Ident, P.Declaration)]- getDeclNames d@(P.ValueDeclaration ident _ _ _) = [(ident, d)]- getDeclNames d@(P.TypeDeclaration ident _ ) = [(ident, d)]- getDeclNames d@(P.ExternDeclaration ident _) = [(ident, d)]- getDeclNames d@(P.TypeClassDeclaration _ _ _ ds) = map (second (const d)) $ concatMap getDeclNames ds- getDeclNames (P.PositionedDeclaration _ _ d) = getDeclNames d- getDeclNames _ = []--dctorNames :: P.Module -> [(N.ProperName 'N.ConstructorName, P.Declaration)]-dctorNames = nubOnFst . concatMap go . P.exportedDeclarations- where- go :: P.Declaration -> [(N.ProperName 'N.ConstructorName, P.Declaration)]- go decl@(P.DataDeclaration _ _ _ ctors) = map (\n -> (n, decl)) (map fst ctors)- go (P.PositionedDeclaration _ _ d) = go d- go _ = []--moduleNames :: [P.Module] -> [String]-moduleNames ms = nub [P.runModuleName moduleName | P.Module _ _ moduleName _ _ <- ms]--directivesFirst :: Completion -> Completion -> Ordering-directivesFirst (Completion _ d1 _) (Completion _ d2 _) = go d1 d2- where- go (':' : xs) (':' : ys) = compare xs ys- go (':' : _) _ = LT- go _ (':' : _) = GT- go xs ys = compare xs ys
@@ -1,119 +0,0 @@------------------------------------------------------------------------------------ Module : Directive--- Copyright :--- License : MIT------ Maintainer :--- Stability : experimental--- Portability :------ |--- Directives for PSCI.-----------------------------------------------------------------------------------module PSCi.Directive where--import Prelude ()-import Prelude.Compat---import Data.Maybe (fromJust, listToMaybe)-import Data.List (isPrefixOf)-import Data.Tuple (swap)--import PSCi.Types---- |--- List of all avaliable directives.----directives :: [Directive]-directives = map fst directiveStrings---- |--- A mapping of directives to the different strings that can be used to invoke--- them.----directiveStrings :: [(Directive, [String])]-directiveStrings =- [ (Help , ["?", "help"])- , (Quit , ["quit"])- , (Reset , ["reset"])- , (Browse , ["browse"])- , (Load , ["load", "module"])- , (Foreign, ["foreign"])- , (Type , ["type"])- , (Kind , ["kind"])- , (Show , ["show"])- ]---- |--- Like directiveStrings, but the other way around.----directiveStrings' :: [(String, Directive)]-directiveStrings' = concatMap go directiveStrings- where- go (dir, strs) = map (\s -> (s, dir)) strs---- |--- List of all directive strings.----strings :: [String]-strings = concatMap snd directiveStrings---- |--- Returns all possible string representations of a directive.----stringsFor :: Directive -> [String]-stringsFor d = fromJust (lookup d directiveStrings)---- |--- Returns the default string representation of a directive.----stringFor :: Directive -> String-stringFor = head . stringsFor---- |--- Returns the list of directives which could be expanded from the string--- argument, together with the string alias that matched.----directivesFor' :: String -> [(Directive, String)]-directivesFor' str = go directiveStrings'- where- go = map swap . filter ((str `isPrefixOf`) . fst)--directivesFor :: String -> [Directive]-directivesFor = map fst . directivesFor'--directiveStringsFor :: String -> [String]-directiveStringsFor = map snd . directivesFor'--parseDirective :: String -> Maybe Directive-parseDirective = listToMaybe . directivesFor---- |--- True if the given directive takes an argument, false otherwise.-hasArgument :: Directive -> Bool-hasArgument Help = False-hasArgument Quit = False-hasArgument Reset = False-hasArgument _ = True---- |--- The help menu.----help :: [(Directive, String, String)]-help =- [ (Help, "", "Show this help menu")- , (Quit, "", "Quit PSCi")- , (Reset, "", "Discard all imported modules and declared bindings")- , (Browse, "<module>", "See all functions in <module>")- , (Load, "<file>", "Load <file> for importing")- , (Foreign, "<file>", "Load foreign module <file>")- , (Type, "<expr>", "Show the type of <expr>")- , (Kind, "<type>", "Show the kind of <type>")- , (Show, "import", "Show all imported modules")- , (Show, "loaded", "Show all loaded modules")- ]-
@@ -1,68 +0,0 @@------------------------------------------------------------------------------------ Module : IO--- Copyright : (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributors--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :------ |-----------------------------------------------------------------------------------module PSCi.IO where--import Prelude ()-import Prelude.Compat--import System.Directory (createDirectoryIfMissing, getHomeDirectory, findExecutable, doesFileExist)-import System.FilePath (takeDirectory, (</>), isPathSeparator)-import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)-import Control.Monad (msum)-import Control.Monad.IO.Class (MonadIO, liftIO)-import System.Console.Haskeline (outputStrLn, InputT)--mkdirp :: FilePath -> IO ()-mkdirp = createDirectoryIfMissing True . takeDirectory---- File helpers--onFirstFileMatching :: Monad m => (b -> m (Maybe a)) -> [b] -> m (Maybe a)-onFirstFileMatching f pathVariants = runMaybeT . msum $ map (MaybeT . f) pathVariants---- |--- Locates the node executable.--- Checks for either @nodejs@ or @node@.----findNodeProcess :: IO (Maybe String)-findNodeProcess = onFirstFileMatching findExecutable names- where names = ["nodejs", "node"]---- |--- Grabs the filename where the history is stored.----getHistoryFilename :: IO FilePath-getHistoryFilename = do- home <- getHomeDirectory- let filename = home </> ".purescript" </> "psci_history"- mkdirp filename- return filename----- |--- Expands tilde in path.----expandTilde :: FilePath -> IO FilePath-expandTilde ('~':p:rest) | isPathSeparator p = (</> rest) <$> getHomeDirectory-expandTilde p = return p---whenFileExists :: MonadIO m => FilePath -> (FilePath -> InputT m ()) -> InputT m ()-whenFileExists filePath f = do- absPath <- liftIO $ expandTilde filePath- exists <- liftIO $ doesFileExist absPath- if exists- then f absPath- else outputStrLn $ "Couldn't locate: " ++ filePath
@@ -1,53 +0,0 @@-module PSCi.Message where---import Data.List (intercalate)-import qualified PSCi.Directive as D-import PSCi.Types---- Messages---- |--- The help message.----helpMessage :: String-helpMessage = "The following commands are available:\n\n " ++- intercalate "\n " (map line D.help) ++- "\n\n" ++ extraHelp- where- line :: (Directive, String, String) -> String- line (dir, arg, desc) =- let cmd = ':' : D.stringFor dir- in unwords [ cmd- , replicate (11 - length cmd) ' '- , arg- , replicate (11 - length arg) ' '- , desc- ]-- extraHelp =- "Further information is available on the PureScript wiki:\n" ++- " --> https://github.com/purescript/purescript/wiki/psci"----- |--- The welcome prologue.----prologueMessage :: String-prologueMessage = intercalate "\n"- [ " ____ ____ _ _ "- , "| _ \\ _ _ _ __ ___/ ___| ___ _ __(_)_ __ | |_ "- , "| |_) | | | | '__/ _ \\___ \\ / __| '__| | '_ \\| __|"- , "| __/| |_| | | | __/___) | (__| | | | |_) | |_ "- , "|_| \\__,_|_| \\___|____/ \\___|_| |_| .__/ \\__|"- , " |_| "- , ""- , ":? shows help"- ]---- |--- The quit message.----quitMessage :: String-quitMessage = "See ya!"-
@@ -1,107 +0,0 @@-module PSCi.Module where--import Prelude ()-import Prelude.Compat--import qualified Language.PureScript as P-import PSCi.Types-import System.FilePath (pathSeparator)-import System.IO.UTF8 (readUTF8File)-import Control.Monad---- | The name of the PSCI support module-supportModuleName :: P.ModuleName-supportModuleName = P.ModuleName [P.ProperName "$PSCI", P.ProperName "Support"]---- | Support module, contains code to evaluate terms-supportModule :: P.Module-supportModule =- case P.parseModulesFromFiles id [("", code)] of- Right [(_, P.Module ss cs _ ds exps)] -> P.Module ss cs supportModuleName ds exps- _ -> P.internalError "Support module could not be parsed"- where- code :: String- code = unlines- [ "module S where"- , ""- , "import Prelude"- , "import Control.Monad.Eff"- , "import Control.Monad.Eff.Console"- , "import Control.Monad.Eff.Unsafe"- , ""- , "class Eval a where"- , " eval :: a -> Eff (console :: CONSOLE) Unit"- , ""- , "instance evalShow :: (Show a) => Eval a where"- , " eval = print"- , ""- , "instance evalEff :: (Eval a) => Eval (Eff eff a) where"- , " eval x = unsafeInterleaveEff x >>= eval"- ]---- Module Management---- |--- Loads a file for use with imports.----loadModule :: FilePath -> IO (Either String [P.Module])-loadModule filename = do- content <- readUTF8File filename- return $ either (Left . P.prettyPrintMultipleErrors False) (Right . map snd) $ P.parseModulesFromFiles id [(filename, content)]---- |--- Load all modules.----loadAllModules :: [FilePath] -> IO (Either P.MultipleErrors [(FilePath, P.Module)])-loadAllModules files = do- filesAndContent <- forM files $ \filename -> do- content <- readUTF8File filename- return (filename, content)- return $ P.parseModulesFromFiles id filesAndContent----- |--- Makes a volatile module to execute the current expression.----createTemporaryModule :: Bool -> PSCiState -> P.Expr -> P.Module-createTemporaryModule exec PSCiState{psciImportedModules = imports, psciLetBindings = lets} val =- let- moduleName = P.ModuleName [P.ProperName "$PSCI"]- trace = P.Var (P.Qualified (Just supportModuleName) (P.Ident "eval"))- mainValue = P.App trace (P.Var (P.Qualified Nothing (P.Ident "it")))- itDecl = P.ValueDeclaration (P.Ident "it") P.Public [] $ Right val- mainDecl = P.ValueDeclaration (P.Ident "$main") P.Public [] $ Right mainValue- decls = if exec then [itDecl, mainDecl] else [itDecl]- in- P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName ((importDecl `map` imports) ++ lets ++ decls) Nothing----- |--- Makes a volatile module to hold a non-qualified type synonym for a fully-qualified data type declaration.----createTemporaryModuleForKind :: PSCiState -> P.Type -> P.Module-createTemporaryModuleForKind PSCiState{psciImportedModules = imports, psciLetBindings = lets} typ =- let- moduleName = P.ModuleName [P.ProperName "$PSCI"]- itDecl = P.TypeSynonymDeclaration (P.ProperName "IT") [] typ- in- P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName ((importDecl `map` imports) ++ lets ++ [itDecl]) Nothing---- |--- Makes a volatile module to execute the current imports.----createTemporaryModuleForImports :: PSCiState -> P.Module-createTemporaryModuleForImports PSCiState{psciImportedModules = imports} =- let- moduleName = P.ModuleName [P.ProperName "$PSCI"]- in- P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName (importDecl `map` imports) Nothing--importDecl :: ImportedModule -> P.Declaration-importDecl (mn, declType, asQ) = P.ImportDeclaration mn declType asQ False--indexFile :: FilePath-indexFile = ".psci_modules" ++ pathSeparator : "index.js"--modulesDir :: FilePath-modulesDir = ".psci_modules" ++ pathSeparator : "node_modules"
@@ -1,57 +0,0 @@-module PSCi.Option (- getOpt-) where--import Prelude ()-import Prelude.Compat--import Options.Applicative as Opts-import Data.Version (showVersion)--import PSCi.Types-import qualified Paths_purescript as Paths---- Parse Command line option--multiLineMode :: Parser Bool-multiLineMode = switch $- long "multi-line-mode"- <> short 'm'- <> Opts.help "Run in multi-line mode (use ^D to terminate commands)"--inputFile :: Parser FilePath-inputFile = strArgument $- metavar "FILE"- <> Opts.help "Optional .purs files to load on start"--inputForeignFile :: Parser FilePath-inputForeignFile = strOption $- short 'f'- <> long "ffi"- <> help "The input .js file(s) providing foreign import implementations"--nodeFlagsFlag :: Parser [String]-nodeFlagsFlag = option parser $- long "node-opts"- <> metavar "NODE_OPTS"- <> value []- <> Opts.help "Flags to pass to node, separated by spaces"- where- parser = words <$> str--psciOptions :: Parser PSCiOptions-psciOptions = PSCiOptions <$> multiLineMode- <*> many inputFile- <*> many inputForeignFile- <*> nodeFlagsFlag--version :: Parser (a -> a)-version = abortOption (InfoMsg (showVersion Paths.version)) $ long "version" <> Opts.help "Show the version number" <> hidden--getOpt :: IO PSCiOptions-getOpt = execParser opts- where- opts = info (version <*> helper <*> psciOptions) infoModList- infoModList = fullDesc <> headerInfo <> footerInfo- headerInfo = header "psci - Interactive mode for PureScript"- footerInfo = footer $ "psci " ++ showVersion Paths.version
@@ -1,140 +0,0 @@------------------------------------------------------------------------------------ Module : Parser--- Copyright : (c) Phil Freeman 2014--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :------ |--- Parser for PSCI.-----------------------------------------------------------------------------------module PSCi.Parser- ( parseCommand- ) where--import Prelude ()-import Prelude.Compat hiding (lex)--import Data.Char (isSpace)-import Data.List (intercalate)--import Text.Parsec hiding ((<|>))--import qualified Language.PureScript as P-import Language.PureScript.Parser.Common (mark, same)--import qualified PSCi.Directive as D-import PSCi.Types---- |--- Parses PSCI metacommands or expressions input from the user.----parseCommand :: String -> Either String Command-parseCommand cmdString =- case cmdString of- (':' : cmd) -> parseDirective cmd- _ -> parseRest psciCommand cmdString--parseRest :: P.TokenParser a -> String -> Either String a-parseRest p s = either (Left . show) Right $ do- ts <- P.lex "" s- P.runTokenParser "" (p <* eof) ts--psciCommand :: P.TokenParser Command-psciCommand = choice (map try parsers)- where- parsers =- [ psciLet- , psciImport- , psciOtherDeclaration- , psciExpression- ]--trim :: String -> String-trim = trimEnd . trimStart--trimStart :: String -> String-trimStart = dropWhile isSpace--trimEnd :: String -> String-trimEnd = reverse . trimStart . reverse--parseDirective :: String -> Either String Command-parseDirective cmd =- case D.directivesFor' dstr of- [(d, _)] -> commandFor d- [] -> Left "Unrecognized directive. Type :? for help."- ds -> Left ("Ambiguous directive. Possible matches: " ++- intercalate ", " (map snd ds) ++ ". Type :? for help.")- where- (dstr, arg) = break isSpace cmd-- commandFor d = case d of- Help -> return ShowHelp- Quit -> return QuitPSCi- Reset -> return ResetState- Browse -> BrowseModule <$> parseRest P.moduleName arg- Load -> return $ LoadFile (trim arg)- Foreign -> return $ LoadForeign (trim arg)- Show -> ShowInfo <$> parseReplQuery' (trim arg)- Type -> TypeOf <$> parseRest P.parseValue arg- Kind -> KindOf <$> parseRest P.parseType arg---- |--- Parses expressions entered at the PSCI repl.----psciExpression :: P.TokenParser Command-psciExpression = Expression <$> P.parseValue---- |--- PSCI version of @let@.--- This is essentially let from do-notation.--- However, since we don't support the @Eff@ monad,--- we actually want the normal @let@.----psciLet :: P.TokenParser Command-psciLet = Decls <$> (P.reserved "let" *> P.indented *> manyDecls)- where- manyDecls :: P.TokenParser [P.Declaration]- manyDecls = mark (many1 (same *> P.parseLocalDeclaration))---- | Imports must be handled separately from other declarations, so that--- :show import works, for example.-psciImport :: P.TokenParser Command-psciImport = do- (mn, declType, asQ, _) <- P.parseImportDeclaration'- return $ Import (mn, declType, asQ)---- | Any other declaration that we don't need a 'special case' parser for--- (like let or import declarations).-psciOtherDeclaration :: P.TokenParser Command-psciOtherDeclaration = Decls . (:[]) <$> do- decl <- discardPositionInfo <$> P.parseDeclaration- if acceptable decl- then return decl- else fail "this kind of declaration is not supported in psci"--discardPositionInfo :: P.Declaration -> P.Declaration-discardPositionInfo (P.PositionedDeclaration _ _ d) = d-discardPositionInfo d = d--acceptable :: P.Declaration -> Bool-acceptable P.DataDeclaration{} = True-acceptable P.TypeSynonymDeclaration{} = True-acceptable P.ExternDeclaration{} = True-acceptable P.ExternDataDeclaration{} = True-acceptable P.TypeClassDeclaration{} = True-acceptable P.TypeInstanceDeclaration{} = True-acceptable _ = False--parseReplQuery' :: String -> Either String ReplQuery-parseReplQuery' str =- case parseReplQuery str of- Nothing -> Left ("Don't know how to show " ++ str ++ ". Try one of: " ++- intercalate ", " replQueryStrings ++ ".")- Just query -> Right query
@@ -1,131 +0,0 @@-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE DataKinds #-}--module PSCi.Printer where--import Prelude ()-import Prelude.Compat--import qualified Language.PureScript as P-import qualified Text.PrettyPrint.Boxes as Box-import qualified Data.Map as M-import System.Console.Haskeline-import Data.Maybe (mapMaybe)-import Data.List (intersperse)-import Control.Monad.IO.Class (MonadIO)---- Printers---- |--- Pretty print a module's signatures----printModuleSignatures :: MonadIO m => P.ModuleName -> P.Environment -> InputT m ()-printModuleSignatures moduleName (P.Environment {..}) =- -- get relevant components of a module from environment- let moduleNamesIdent = (filter ((== moduleName) . fst) . M.keys) names- moduleTypeClasses = (filter (\(P.Qualified maybeName _) -> maybeName == Just moduleName) . M.keys) typeClasses- moduleTypes = (filter (\(P.Qualified maybeName _) -> maybeName == Just moduleName) . M.keys) types-- in- -- print each component- (outputStr . unlines . map trimEnd . lines . Box.render . Box.vsep 1 Box.left)- [ printModule's (mapMaybe (showTypeClass . findTypeClass typeClasses)) moduleTypeClasses -- typeClasses- , printModule's (mapMaybe (showType typeClasses dataConstructors typeSynonyms . findType types)) moduleTypes -- types- , printModule's (map (showNameType . findNameType names)) moduleNamesIdent -- functions- ]-- where printModule's showF = Box.vsep 1 Box.left . showF-- findNameType :: M.Map (P.ModuleName, P.Ident) (P.Type, P.NameKind, P.NameVisibility) -> (P.ModuleName, P.Ident) -> (P.Ident, Maybe (P.Type, P.NameKind, P.NameVisibility))- findNameType envNames m@(_, mIdent) = (mIdent, M.lookup m envNames)-- showNameType :: (P.Ident, Maybe (P.Type, P.NameKind, P.NameVisibility)) -> Box.Box- showNameType (mIdent, Just (mType, _, _)) = Box.text (P.showIdent mIdent ++ " :: ") Box.<> P.typeAsBox mType- showNameType _ = P.internalError "The impossible happened in printModuleSignatures."-- findTypeClass- :: M.Map (P.Qualified (P.ProperName 'P.ClassName)) ([(String, Maybe P.Kind)], [(P.Ident, P.Type)], [P.Constraint])- -> P.Qualified (P.ProperName 'P.ClassName)- -> (P.Qualified (P.ProperName 'P.ClassName), Maybe ([(String, Maybe P.Kind)], [(P.Ident, P.Type)], [P.Constraint]))- findTypeClass envTypeClasses name = (name, M.lookup name envTypeClasses)-- showTypeClass- :: (P.Qualified (P.ProperName 'P.ClassName), Maybe ([(String, Maybe P.Kind)], [(P.Ident, P.Type)], [P.Constraint]))- -> Maybe Box.Box- showTypeClass (_, Nothing) = Nothing- showTypeClass (P.Qualified _ name, Just (vars, body, constrs)) =- let constraints =- if null constrs- then Box.text ""- else Box.text "("- Box.<> Box.hcat Box.left (intersperse (Box.text ", ") $ map (\(P.Qualified _ pn, lt) -> Box.text (P.runProperName pn) Box.<+> Box.hcat Box.left (map P.typeAtomAsBox lt)) constrs)- Box.<> Box.text ") <= "- className =- Box.text (P.runProperName name)- Box.<> Box.text (concatMap ((' ':) . fst) vars)- classBody =- Box.vcat Box.top (map (\(i, t) -> Box.text (P.showIdent i ++ " ::") Box.<+> P.typeAsBox t) body)-- in- Just $- (Box.text "class "- Box.<> constraints- Box.<> className- Box.<+> if null body then Box.text "" else Box.text "where")- Box.// Box.moveRight 2 classBody--- findType- :: M.Map (P.Qualified (P.ProperName 'P.TypeName)) (P.Kind, P.TypeKind)- -> P.Qualified (P.ProperName 'P.TypeName)- -> (P.Qualified (P.ProperName 'P.TypeName), Maybe (P.Kind, P.TypeKind))- findType envTypes name = (name, M.lookup name envTypes)-- showType- :: M.Map (P.Qualified (P.ProperName 'P.ClassName)) ([(String, Maybe P.Kind)], [(P.Ident, P.Type)], [P.Constraint])- -> M.Map (P.Qualified (P.ProperName 'P.ConstructorName)) (P.DataDeclType, P.ProperName 'P.TypeName, P.Type, [P.Ident])- -> M.Map (P.Qualified (P.ProperName 'P.TypeName)) ([(String, Maybe P.Kind)], P.Type)- -> (P.Qualified (P.ProperName 'P.TypeName), Maybe (P.Kind, P.TypeKind))- -> Maybe Box.Box- showType typeClassesEnv dataConstructorsEnv typeSynonymsEnv (n@(P.Qualified modul name), typ) =- case (typ, M.lookup n typeSynonymsEnv) of- (Just (_, P.TypeSynonym), Just (typevars, dtType)) ->- if M.member (fmap P.coerceProperName n) typeClassesEnv- then- Nothing- else- Just $- Box.text ("type " ++ P.runProperName name ++ concatMap ((' ':) . fst) typevars)- Box.// Box.moveRight 2 (Box.text "=" Box.<+> P.typeAsBox dtType)-- (Just (_, P.DataType typevars pt), _) ->- let prefix =- case pt of- [(dtProperName,_)] ->- case M.lookup (P.Qualified modul dtProperName) dataConstructorsEnv of- Just (dataDeclType, _, _, _) -> P.showDataDeclType dataDeclType- _ -> "data"- _ -> "data"-- in- Just $ Box.text (prefix ++ " " ++ P.runProperName name ++ concatMap ((' ':) . fst) typevars) Box.// printCons pt-- _ ->- Nothing-- where printCons pt =- Box.moveRight 2 $- Box.vcat Box.left $- mapFirstRest (Box.text "=" Box.<+>) (Box.text "|" Box.<+>) $- map (\(cons,idents) -> (Box.text (P.runProperName cons) Box.<> Box.hcat Box.left (map prettyPrintType idents))) pt-- prettyPrintType t = Box.text " " Box.<> P.typeAtomAsBox t-- mapFirstRest _ _ [] = []- mapFirstRest f g (x:xs) = f x : map g xs-- trimEnd = reverse . dropWhile (== ' ') . reverse---- | Pretty-print errors-printErrors :: MonadIO m => P.MultipleErrors -> InputT m ()-printErrors = outputStrLn . P.prettyPrintMultipleErrors False
@@ -1,218 +0,0 @@------------------------------------------------------------------------------------ Module : Types--- Copyright : (c) Phil Freeman 2014--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :------ |--- Type declarations and associated basic functions for PSCI.-----------------------------------------------------------------------------------module PSCi.Types where--import Prelude ()-import Prelude.Compat--import Control.Arrow (second)-import Data.Map (Map)-import qualified Data.Map as Map-import qualified Language.PureScript as P--data PSCiOptions = PSCiOptions- { psciMultiLineMode :: Bool- , psciInputFile :: [FilePath]- , psciForeignInputFiles :: [FilePath]- , psciInputNodeFlags :: [String]- }---- |--- The PSCI state.--- Holds a list of imported modules, loaded files, and partial let bindings.--- The let bindings are partial,--- because it makes more sense to apply the binding to the final evaluated expression.----data PSCiState = PSCiState- { psciImportedModules :: [ImportedModule]- , _psciLoadedModules :: Map FilePath [P.Module]- , psciForeignFiles :: Map P.ModuleName FilePath- , psciLetBindings :: [P.Declaration]- , psciNodeFlags :: [String]- }--initialPSCiState :: PSCiState-initialPSCiState =- PSCiState [] Map.empty Map.empty [] []--mkPSCiState :: [ImportedModule]- -> [(FilePath, P.Module)]- -> Map P.ModuleName FilePath- -> [P.Declaration]- -> [String]- -> PSCiState-mkPSCiState imported loaded foreigns lets nodeFlags =- (initialPSCiState- |> each imported updateImportedModules- |> updateModules loaded)- { psciForeignFiles = foreigns- , psciLetBindings = lets- , psciNodeFlags = nodeFlags- }- where- x |> f = f x- each xs f st = foldl (flip f) st xs---- Public psci state accessors---- | Get the imported filenames as a list.-psciImportedFilenames :: PSCiState -> [FilePath]-psciImportedFilenames = Map.keys . _psciLoadedModules---- | Get the loaded modules as a list.-psciLoadedModules :: PSCiState -> [(FilePath, P.Module)]-psciLoadedModules = collect . Map.toList . _psciLoadedModules- where- collect :: [(k, [v])] -> [(k, v)]- collect vss = [ (k, v) | (k, vs) <- vss, v <- vs ]---- | All of the data that is contained by an ImportDeclaration in the AST.--- That is:------ * A module name, the name of the module which is being imported--- * An ImportDeclarationType which specifies whether there is an explicit--- import list, a hiding list, or neither.--- * If the module is imported qualified, its qualified name in the importing--- module. Otherwise, Nothing.----type ImportedModule = (P.ModuleName, P.ImportDeclarationType, Maybe P.ModuleName)--psciImportedModuleNames :: PSCiState -> [P.ModuleName]-psciImportedModuleNames (PSCiState{psciImportedModules = is}) =- map (\(mn, _, _) -> mn) is--allImportsOf :: P.Module -> PSCiState -> [ImportedModule]-allImportsOf m (PSCiState{psciImportedModules = is}) =- filter isImportOfThis is- where- name = P.getModuleName m- isImportOfThis (name', _, _) = name == name'---- State helpers---- |--- Updates the state to have more imported modules.----updateImportedModules :: ImportedModule -> PSCiState -> PSCiState-updateImportedModules im st = st { psciImportedModules = im : psciImportedModules st }---- |--- Updates the state to have more loaded modules (available for import, but--- not necessarily imported).----updateModules :: [(FilePath, P.Module)] -> PSCiState -> PSCiState-updateModules modules st =- st { _psciLoadedModules = Map.union (go modules) (_psciLoadedModules st) }- where- go = Map.fromListWith (++) . map (second (:[]))---- |--- Updates the state to have more let bindings.----updateLets :: [P.Declaration] -> PSCiState -> PSCiState-updateLets ds st = st { psciLetBindings = psciLetBindings st ++ ds }---- |--- Updates the state to have more let bindings.----updateForeignFiles :: Map P.ModuleName FilePath -> PSCiState -> PSCiState-updateForeignFiles fs st = st { psciForeignFiles = psciForeignFiles st `Map.union` fs }---- |--- Valid Meta-commands for PSCI----data Command- -- |- -- A purescript expression- --- = Expression P.Expr- -- |- -- Show the help (ie, list of directives)- --- | ShowHelp- -- |- -- Import a module from a loaded file- --- | Import ImportedModule- -- |- -- Browse a module- --- | BrowseModule P.ModuleName- -- |- -- Load a file for use with importing- --- | LoadFile FilePath- -- |- -- Load a foreign module- --- | LoadForeign FilePath- -- |- -- Exit PSCI- --- | QuitPSCi- -- |- -- Reset the state of the REPL- --- | ResetState- -- |- -- Add some declarations to the current evaluation context.- --- | Decls [P.Declaration]- -- |- -- Find the type of an expression- --- | TypeOf P.Expr- -- |- -- Find the kind of an expression- --- | KindOf P.Type- -- |- -- Shows information about the current state of the REPL- --- | ShowInfo ReplQuery--data ReplQuery- = QueryLoaded- | QueryImport- deriving (Eq, Show)---- | A list of all ReplQuery values.-replQueries :: [ReplQuery]-replQueries = [QueryLoaded, QueryImport]--replQueryStrings :: [String]-replQueryStrings = map showReplQuery replQueries--showReplQuery :: ReplQuery -> String-showReplQuery QueryLoaded = "loaded"-showReplQuery QueryImport = "import"--parseReplQuery :: String -> Maybe ReplQuery-parseReplQuery "loaded" = Just QueryLoaded-parseReplQuery "import" = Just QueryImport-parseReplQuery _ = Nothing--data Directive- = Help- | Quit- | Reset- | Browse- | Load- | Foreign- | Type- | Kind- | Show- deriving (Eq, Show)
@@ -1,6 +0,0 @@-module Main where--import PSCi--main :: IO ()-main = runPSCi
@@ -1,5 +1,5 @@ name: purescript-version: 0.8.5.0+version: 0.9.1 cabal-version: >=1.8 build-type: Simple license: MIT@@ -20,27 +20,73 @@ tested-with: GHC==7.10.3 extra-source-files: examples/passing/*.purs+ , examples/passing/*.js+ , examples/passing/2018/*.purs+ , examples/passing/2138/*.purs+ , examples/passing/ClassRefSyntax/*.purs+ , examples/passing/DctorOperatorAlias/*.purs+ , examples/passing/ExplicitImportReExport/*.purs+ , examples/passing/ExportExplicit/*.purs+ , examples/passing/ExportExplicit2/*.purs+ , examples/passing/Import/*.purs+ , examples/passing/ImportExplicit/*.purs+ , examples/passing/ImportQualified/*.purs+ , examples/passing/Module/*.purs+ , examples/passing/ModuleDeps/*.purs+ , examples/passing/ModuleExport/*.purs+ , examples/passing/ModuleExportDupes/*.purs+ , examples/passing/ModuleExportExcluded/*.purs+ , examples/passing/ModuleExportQualified/*.purs+ , examples/passing/ModuleExportSelf/*.purs+ , examples/passing/NonConflictingExports/*.purs+ , examples/passing/OperatorAliasElsewhere/*.purs+ , examples/passing/Operators/*.purs+ , examples/passing/PendingConflictingImports/*.purs+ , examples/passing/PendingConflictingImports2/*.purs+ , examples/passing/QualifiedNames/*.purs+ , examples/passing/RedefinedFixity/*.purs+ , examples/passing/ReExportQualified/*.purs+ , examples/passing/ResolvableScopeConflict/*.purs+ , examples/passing/ResolvableScopeConflict2/*.purs+ , examples/passing/ResolvableScopeConflict3/*.purs+ , examples/passing/ShadowedModuleName/*.purs+ , examples/passing/TransitiveImport/*.purs+ , examples/passing/TypeOperators/*.purs+ , examples/passing/TypeWithoutParens/*.purs , examples/failing/*.purs+ , examples/failing/1733/*.purs+ , examples/failing/ConflictingExports/*.purs+ , examples/failing/ConflictingImports/*.purs+ , examples/failing/ConflictingImports2/*.purs+ , examples/failing/ConflictingQualifiedImports/*.purs+ , examples/failing/ConflictingQualifiedImports2/*.purs+ , examples/failing/ExportConflictClass/*.purs+ , examples/failing/ExportConflictCtor/*.purs+ , examples/failing/ExportConflictType/*.purs+ , examples/failing/ExportConflictTypeOp/*.purs+ , examples/failing/ExportConflictValue/*.purs+ , examples/failing/ExportConflictValueOp/*.purs+ , examples/failing/ExportExplicit1/*.purs+ , examples/failing/ExportExplicit3/*.purs+ , examples/failing/ImportExplicit/*.purs+ , examples/failing/ImportExplicit2/*.purs+ , examples/failing/ImportHidingModule/*.purs+ , examples/failing/ImportModule/*.purs+ , examples/failing/InstanceExport/*.purs+ , examples/failing/OrphanInstance/*.purs+ , examples/warning/*.purs+ , examples/warning/*.js , examples/docs/bower_components/purescript-prelude/src/*.purs , examples/docs/bower.json , examples/docs/src/*.purs- , tests/support/setup.js , tests/support/package.json- , tests/support/prelude/bower.json- , tests/support/prelude/src/*.purs- , tests/support/prelude/src/*.js- , tests/support/prelude/LICENSE , tests/support/bower.json , tests/support/setup-win.cmd- , tests/support/flattened/*.purs- , tests/support/flattened/*.js , tests/support/psci/*.purs , tests/support/pscide/src/*.purs , tests/support/pscide/src/*.js , tests/support/pscide/src/*.fail , stack.yaml- , stack-lts-5.yaml- , stack-nightly.yaml , README.md , INSTALL.md , CONTRIBUTORS.md@@ -52,47 +98,49 @@ library build-depends: base >=4.8 && <5,+ aeson >= 0.8 && < 0.12,+ aeson-better-errors >= 0.8,+ ansi-terminal >= 0.6.2 && < 0.7, base-compat >=0.6.0,- lifted-base >= 0.2.3 && < 0.2.4,- monad-control >= 1.0.0.0 && < 1.1,- transformers-base >= 0.4.0 && < 0.5,+ bower-json >= 0.8,+ boxes >= 0.1.4 && < 0.2.0,+ bytestring -any, containers -any,- unordered-containers -any,- dlist -any, directory >= 1.2,+ dlist -any,+ edit-distance -any, filepath -any,+ fsnotify >= 0.2.1,+ Glob >= 0.7 && < 0.8,+ haskeline >= 0.7.0.0,+ http-types -any,+ language-javascript == 0.6.*,+ lifted-base >= 0.2.3 && < 0.2.4,+ monad-control >= 1.0.0.0 && < 1.1,+ monad-logger >= 0.3 && < 0.4, mtl >= 2.1.0 && < 2.3.0,- parsec -any,- transformers >= 0.3.0 && < 0.6,- transformers-compat >= 0.3.0,- utf8-string >= 1 && < 2,+ parallel >= 3.2 && < 3.3,+ parsec >=3.1.10, pattern-arrows >= 0.0.2 && < 0.1,- time -any,- boxes >= 0.1.4 && < 0.2.0,- aeson >= 0.8 && < 0.12,- vector -any,- bower-json >= 0.8,- aeson-better-errors >= 0.8,- bytestring -any,- text -any,- split -any,- language-javascript == 0.6.*,- syb -any,- Glob >= 0.7 && < 0.8,+ pipes >= 4.0.0 && < 4.2.0,+ pipes-http -any, process >= 1.2.0 && < 1.5,+ regex-tdfa -any, safe >= 0.3.9 && < 0.4, semigroups >= 0.16.2 && < 0.19,- parallel >= 3.2 && < 3.3, sourcemap >= 0.1.6,+ spdx == 0.2.*,+ split -any, stm >= 0.2.4.0,- regex-tdfa -any,- edit-distance -any,- fsnotify >= 0.2.1,- monad-logger >= 0.3 && < 0.4,- pipes >= 4.0.0 && < 4.2.0 ,- pipes-http -any,- http-types -any,- spdx == 0.2.*+ syb -any,+ text -any,+ time -any,+ transformers >= 0.3.0 && < 0.6,+ transformers-base >= 0.4.0 && < 0.5,+ transformers-compat >= 0.3.0,+ unordered-containers -any,+ utf8-string >= 1 && < 2,+ vector -any exposed-modules: Language.PureScript Language.PureScript.AST@@ -142,7 +190,6 @@ Language.PureScript.Parser.Lexer Language.PureScript.Parser.Common Language.PureScript.Parser.Declarations- Language.PureScript.Parser.JS Language.PureScript.Parser.Kinds Language.PureScript.Parser.State Language.PureScript.Parser.Types@@ -158,9 +205,10 @@ Language.PureScript.Sugar.CaseDeclarations Language.PureScript.Sugar.DoNotation Language.PureScript.Sugar.Names+ Language.PureScript.Sugar.Names.Common Language.PureScript.Sugar.Names.Env- Language.PureScript.Sugar.Names.Imports Language.PureScript.Sugar.Names.Exports+ Language.PureScript.Sugar.Names.Imports Language.PureScript.Sugar.ObjectWildcards Language.PureScript.Sugar.Operators Language.PureScript.Sugar.Operators.Common@@ -220,13 +268,38 @@ Language.PureScript.Ide.Util Language.PureScript.Ide.Rebuild + Language.PureScript.Interactive+ Language.PureScript.Interactive.Types+ Language.PureScript.Interactive.Parser+ Language.PureScript.Interactive.Directive+ Language.PureScript.Interactive.Completion+ Language.PureScript.Interactive.IO+ Language.PureScript.Interactive.Message+ Language.PureScript.Interactive.Module+ Language.PureScript.Interactive.Printer+ Control.Monad.Logger Control.Monad.Supply Control.Monad.Supply.Class System.IO.UTF8 - extensions: DataKinds+ extensions: ConstraintKinds+ DataKinds+ DeriveFunctor+ EmptyDataDecls+ FlexibleContexts+ KindSignatures+ LambdaCase+ MultiParamTypeClasses+ NoImplicitPrelude+ PatternGuards+ PatternSynonyms+ RankNTypes+ RecordWildCards+ ScopedTypeVariables+ TupleSections+ ViewPatterns exposed: True buildable: True hs-source-dirs: src@@ -234,11 +307,23 @@ ghc-options: -Wall -O2 executable psc- build-depends: base >=4 && <5, base-compat >=0.6.0,- containers -any, directory -any, filepath -any,- mtl -any, optparse-applicative >= 0.12.1, parsec -any, purescript -any,- time -any, transformers -any, transformers-compat -any, Glob >= 0.7 && < 0.8,- aeson >= 0.8 && < 0.12, bytestring -any, utf8-string >= 1 && < 2+ build-depends: base >=4 && <5,+ purescript -any,+ aeson >= 0.8 && < 0.12,+ ansi-terminal >= 0.6.2 && < 0.7,+ base-compat >=0.6.0,+ bytestring -any,+ containers -any,+ directory -any,+ filepath -any,+ Glob >= 0.7 && < 0.8,+ mtl -any,+ optparse-applicative >= 0.12.1,+ parsec -any,+ time -any,+ transformers -any,+ transformers-compat -any,+ utf8-string >= 1 && < 2 main-is: Main.hs buildable: True hs-source-dirs: psc@@ -246,33 +331,40 @@ ghc-options: -Wall -O2 -fno-warn-unused-do-bind -threaded -rtsopts "-with-rtsopts=-N" executable psci- build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,- mtl -any, optparse-applicative >= 0.12.1, parsec -any,- haskeline >= 0.7.0.0, purescript -any, transformers -any,- transformers-compat -any, process -any, time -any, Glob -any, base-compat >=0.6.0,- boxes >= 0.1.4 && < 0.2.0-+ build-depends: base >=4 && <5,+ purescript -any,+ base-compat >=0.6.0,+ boxes >= 0.1.4 && < 0.2.0,+ containers -any,+ directory -any,+ filepath -any,+ Glob -any,+ haskeline >= 0.7.0.0,+ mtl -any,+ optparse-applicative >= 0.12.1,+ parsec -any,+ process -any,+ time -any,+ transformers -any,+ transformers-compat -any main-is: Main.hs buildable: True- hs-source-dirs: psci psci/main- other-modules: PSCi- PSCi.Types- PSCi.Parser- PSCi.Directive- PSCi.Completion- PSCi.IO- PSCi.Message- PSCi.Option- PSCi.Module- PSCi.Printer- Paths_purescript+ hs-source-dirs: psci+ other-modules: Paths_purescript ghc-options: -Wall -O2 executable psc-docs- build-depends: base >=4 && <5, purescript -any,- optparse-applicative >= 0.12.1, process -any, mtl -any,- split -any, ansi-wl-pprint -any, directory -any,- filepath -any, Glob -any, transformers -any,+ build-depends: base >=4 && <5,+ purescript -any,+ ansi-wl-pprint -any,+ directory -any,+ filepath -any,+ Glob -any,+ mtl -any,+ optparse-applicative >= 0.12.1,+ process -any,+ split -any,+ transformers -any, transformers-compat -any main-is: Main.hs other-modules: Paths_purescript@@ -284,7 +376,11 @@ ghc-options: -Wall -O2 executable psc-publish- build-depends: base >=4 && <5, purescript -any, bytestring -any, aeson -any, optparse-applicative -any+ build-depends: base >=4 && <5,+ purescript -any,+ aeson -any,+ bytestring -any,+ optparse-applicative -any main-is: Main.hs other-modules: Paths_purescript buildable: True@@ -292,9 +388,15 @@ ghc-options: -Wall -O2 executable psc-hierarchy- build-depends: base >=4 && <5, purescript -any, optparse-applicative >= 0.12.1,- process -any, mtl -any, parsec -any, filepath -any, directory -any,- Glob -any+ build-depends: base >=4 && <5,+ purescript -any,+ directory -any,+ filepath -any,+ Glob -any,+ mtl -any,+ optparse-applicative >= 0.12.1,+ parsec -any,+ process -any main-is: Main.hs other-modules: Paths_purescript buildable: True@@ -308,13 +410,13 @@ other-extensions: build-depends: base >=4 && <5, purescript -any,- filepath -any, directory -any,+ filepath -any,+ Glob -any, mtl -any,- transformers -any,- transformers-compat -any, optparse-applicative >= 0.12.1,- Glob -any+ transformers -any,+ transformers-compat -any ghc-options: -Wall -O2 hs-source-dirs: psc-bundle @@ -322,19 +424,19 @@ main-is: Main.hs other-modules: Paths_purescript other-extensions:- build-depends: base >=4 && <5- , purescript -any- , directory -any- , filepath -any- , monad-logger -any- , mtl -any- , transformers -any- , transformers-compat -any- , network -any- , optparse-applicative >= 0.12.1- , stm -any- , text -any- , base-compat >=0.6.0+ build-depends: base >=4 && <5,+ purescript -any,+ base-compat >=0.6.0,+ directory -any,+ filepath -any,+ monad-logger -any,+ mtl -any,+ network -any,+ optparse-applicative >= 0.12.1,+ stm -any,+ text -any,+ transformers -any,+ transformers-compat -any ghc-options: -Wall -O2 -threaded hs-source-dirs: psc-ide-server @@ -342,23 +444,43 @@ main-is: Main.hs other-modules: Paths_purescript other-extensions:- build-depends: base >=4 && <5- , mtl -any- , text -any- , optparse-applicative >= 0.12.1- , network -any- , base-compat >=0.6.0+ build-depends: base >=4 && <5,+ base-compat >=0.6.0,+ mtl -any,+ network -any,+ optparse-applicative >= 0.12.1,+ text -any ghc-options: -Wall -O2 hs-source-dirs: psc-ide-client test-suite tests- build-depends: base >=4 && <5, containers -any, directory -any,- filepath -any, mtl -any, parsec -any, purescript -any,- transformers -any, process -any, transformers-compat -any, time -any,- Glob -any, aeson-better-errors -any, bytestring -any, aeson -any,- base-compat -any, haskeline >= 0.7.0.0, optparse-applicative -any,- boxes -any, HUnit -any, hspec -any, hspec-discover -any, stm -any, text -any,- vector -any, utf8-string -any+ build-depends: base >=4 && <5,+ purescript -any,+ aeson -any,+ aeson-better-errors -any,+ base-compat -any,+ boxes -any,+ bytestring -any,+ containers -any,+ directory -any,+ filepath -any,+ Glob -any,+ haskeline >= 0.7.0.0,+ hspec -any,+ hspec-discover -any,+ HUnit -any,+ mtl -any,+ optparse-applicative -any,+ parsec -any,+ process -any,+ silently -any,+ stm -any,+ text -any,+ time -any,+ transformers -any,+ transformers-compat -any,+ utf8-string -any,+ vector -any ghc-options: -Wall type: exitcode-stdio-1.0 main-is: Main.hs@@ -377,9 +499,5 @@ Language.PureScript.Ide.RebuildSpec Language.PureScript.Ide.ReexportsSpec Language.PureScript.IdeSpec- PSCi.Completion- PSCi.Directive- PSCi.Module- PSCi.Types buildable: True- hs-source-dirs: tests psci+ hs-source-dirs: tests
@@ -1,33 +1,20 @@------------------------------------------------------------------------------------ Module : Control.Monad.Logger--- Author : Phil Freeman--- License : MIT (http://opensource.org/licenses/MIT)------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :------ | A replacement for WriterT IO which uses mutable references.---------------------------------------------------------------------------------- {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} +-- |+-- A replacement for WriterT IO which uses mutable references.+-- module Control.Monad.Logger where -import Prelude () import Prelude.Compat -import Data.IORef- import Control.Monad (ap)-import Control.Monad.IO.Class-import Control.Monad.Writer.Class import Control.Monad.Base (MonadBase(..))+import Control.Monad.IO.Class import Control.Monad.Trans.Control (MonadBaseControl(..))+import Control.Monad.Writer.Class++import Data.IORef -- | A replacement for WriterT IO which uses mutable references. newtype Logger w a = Logger { runLogger :: IORef w -> IO a }
@@ -1,31 +1,18 @@------------------------------------------------------------------------------------ Module : Control.Monad.Supply--- Copyright : (c) Phil Freeman 2014--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :---+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+ -- | -- Fresh variable supply ----------------------------------------------------------------------------------{-# LANGUAGE GeneralizedNewtypeDeriving #-}- module Control.Monad.Supply where -import Prelude () import Prelude.Compat -import Data.Functor.Identity--import Control.Monad.State import Control.Monad.Error.Class (MonadError(..)) import Control.Monad.Reader+import Control.Monad.State import Control.Monad.Writer++import Data.Functor.Identity newtype SupplyT m a = SupplyT { unSupplyT :: StateT Integer m a } deriving (Functor, Applicative, Monad, MonadTrans, MonadError e, MonadWriter w, MonadReader r)
@@ -1,24 +1,24 @@-{-# LANGUAGE MultiParamTypeClasses #-}- -- | -- A class for monads supporting a supply of fresh names -- module Control.Monad.Supply.Class where +import Prelude.Compat+ import Control.Monad.Supply import Control.Monad.State -class (Monad m) => MonadSupply m where+class Monad m => MonadSupply m where fresh :: m Integer -instance (Monad m) => MonadSupply (SupplyT m) where+instance Monad m => MonadSupply (SupplyT m) where fresh = SupplyT $ do n <- get put (n + 1) return n -instance (MonadSupply m) => MonadSupply (StateT s m) where+instance MonadSupply m => MonadSupply (StateT s m) where fresh = lift fresh -freshName :: (MonadSupply m) => m String+freshName :: MonadSupply m => m String freshName = fmap (('$' :) . show) fresh
@@ -1,33 +1,22 @@------------------------------------------------------------------------------------ Module : Language.PureScript--- Copyright : (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributors--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :--- -- | -- The main compiler module ----------------------------------------------------------------------------------{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}- module Language.PureScript ( module P , version ) where ++import Control.Monad.Supply as P+ import Data.Version (Version) import Language.PureScript.AST as P-import Language.PureScript.Crash as P import Language.PureScript.Comments as P+import Language.PureScript.Crash as P import Language.PureScript.Environment as P import Language.PureScript.Errors as P hiding (indent)+import Language.PureScript.Externs as P import Language.PureScript.Kinds as P import Language.PureScript.Linter as P import Language.PureScript.Make as P@@ -38,7 +27,6 @@ import Language.PureScript.Pretty as P import Language.PureScript.Renamer as P import Language.PureScript.Sugar as P-import Control.Monad.Supply as P import Language.PureScript.TypeChecker as P import Language.PureScript.Types as P
@@ -3,6 +3,8 @@ -- module Language.PureScript.AST.Binders where +import Prelude.Compat+ import Language.PureScript.AST.SourcePos import Language.PureScript.AST.Literals import Language.PureScript.Names@@ -33,7 +35,7 @@ -- A operator alias binder. During the rebracketing phase of desugaring, -- this data constructor will be removed. --- | OpBinder (Qualified Ident)+ | OpBinder (Qualified (OpName 'ValueOpName)) -- | -- Binary operator application. During the rebracketing phase of desugaring, -- this data constructor will be removed.
@@ -1,23 +1,17 @@-{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE LambdaCase #-} -- | -- Data types for modules and declarations -- module Language.PureScript.AST.Declarations where -import Prelude () import Prelude.Compat -import Data.Aeson.TH-import Data.List (nub, (\\))-import Data.Maybe (mapMaybe)+import Control.Monad.Identity +import Data.Aeson.TH import qualified Data.Map as M -import Control.Monad.Identity- import Language.PureScript.AST.Binders import Language.PureScript.AST.Literals import Language.PureScript.AST.Operators@@ -47,9 +41,9 @@ addDefaultImport :: ModuleName -> Module -> Module addDefaultImport toImport m@(Module ss coms mn decls exps) = if isExistingImport `any` decls || mn == toImport then m- else Module ss coms mn (ImportDeclaration toImport Implicit Nothing False : decls) exps+ else Module ss coms mn (ImportDeclaration toImport Implicit Nothing : decls) exps where- isExistingImport (ImportDeclaration mn' _ _ _) | mn' == toImport = True+ isExistingImport (ImportDeclaration mn' _ _) | mn' == toImport = True isExistingImport (PositionedDeclaration _ _ d) = isExistingImport d isExistingImport _ = False @@ -64,16 +58,20 @@ -- | -- A type operator --- | TypeOpRef Ident+ | TypeOpRef (OpName 'TypeOpName) -- | -- A value -- | ValueRef Ident -- |+ -- A value-level operator+ --+ | ValueOpRef (OpName 'ValueOpName)+ -- | -- A type class -- | TypeClassRef (ProperName 'ClassName)- -- |+ -- | -- A type class instance, created during typeclass desugaring (name, class name, instance types) -- | TypeInstanceRef Ident@@ -82,10 +80,6 @@ -- | ModuleRef ModuleName -- |- -- An unspecified ProperName ref. This will be replaced with a TypeClassRef- -- or TypeRef during name desugaring.- | ProperRef String- -- | -- A declaration reference with source position information -- | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef@@ -95,42 +89,45 @@ (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors' (TypeOpRef name) == (TypeOpRef name') = name == name' (ValueRef name) == (ValueRef name') = name == name'+ (ValueOpRef name) == (ValueOpRef name') = name == name' (TypeClassRef name) == (TypeClassRef name') = name == name' (TypeInstanceRef name) == (TypeInstanceRef name') = name == name' (ModuleRef name) == (ModuleRef name') = name == name'- (ProperRef name) == (ProperRef name') = name == name' (PositionedDeclarationRef _ _ r) == r' = r == r' r == (PositionedDeclarationRef _ _ r') = r == r' _ == _ = False +getTypeRef :: DeclarationRef -> Maybe (ProperName 'TypeName, Maybe [ProperName 'ConstructorName])+getTypeRef (TypeRef name dctors) = Just (name, dctors)+getTypeRef (PositionedDeclarationRef _ _ r) = getTypeRef r+getTypeRef _ = Nothing++getTypeOpRef :: DeclarationRef -> Maybe (OpName 'TypeOpName)+getTypeOpRef (TypeOpRef op) = Just op+getTypeOpRef (PositionedDeclarationRef _ _ r) = getTypeOpRef r+getTypeOpRef _ = Nothing++getValueRef :: DeclarationRef -> Maybe Ident+getValueRef (ValueRef name) = Just name+getValueRef (PositionedDeclarationRef _ _ r) = getValueRef r+getValueRef _ = Nothing++getValueOpRef :: DeclarationRef -> Maybe (OpName 'ValueOpName)+getValueOpRef (ValueOpRef op) = Just op+getValueOpRef (PositionedDeclarationRef _ _ r) = getValueOpRef r+getValueOpRef _ = Nothing++getTypeClassRef :: DeclarationRef -> Maybe (ProperName 'ClassName)+getTypeClassRef (TypeClassRef name) = Just name+getTypeClassRef (PositionedDeclarationRef _ _ r) = getTypeClassRef r+getTypeClassRef _ = Nothing+ isModuleRef :: DeclarationRef -> Bool isModuleRef (PositionedDeclarationRef _ _ r) = isModuleRef r isModuleRef (ModuleRef _) = True isModuleRef _ = False -- |--- Finds duplicate values in a list of declaration refs. The returned values--- are the duplicate refs with data constructors elided, and then a separate--- list of duplicate data constructors.----findDuplicateRefs :: [DeclarationRef] -> ([DeclarationRef], [ProperName 'ConstructorName])-findDuplicateRefs refs =- let positionless = stripPosInfo `map` refs- simplified = simplifyTypeRefs `map` positionless- dupeRefs = nub $ simplified \\ nub simplified- dupeCtors = concat $ flip mapMaybe positionless $ \case- TypeRef _ (Just dctors) ->- let dupes = dctors \\ nub dctors- in if null dupes then Nothing else Just dupes- _ -> Nothing- in (dupeRefs, dupeCtors)- where- stripPosInfo (PositionedDeclarationRef _ _ ref) = stripPosInfo ref- stripPosInfo other = other- simplifyTypeRefs (TypeRef pn _) = TypeRef pn Nothing- simplifyTypeRefs other = other---- | -- The data type which specifies type of import declaration -- data ImportDeclarationType@@ -193,14 +190,13 @@ -- | ExternDataDeclaration (ProperName 'TypeName) Kind -- |- -- A fixity declaration (fixity data, operator name, value the operator is an alias for)+ -- A fixity declaration --- | FixityDeclaration Fixity String (Maybe (Qualified FixityAlias))+ | FixityDeclaration (Either ValueFixity TypeFixity) -- | -- A module import (module name, qualified/unqualified/hiding, optional "qualified as" name)- -- TODO: also a boolean specifying whether the old `qualified` syntax was used, so a warning can be raised in desugaring (remove for 0.9) --- | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName) Bool+ | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName) -- | -- A type class declaration (name, argument, implies, member declarations) --@@ -216,30 +212,14 @@ | PositionedDeclaration SourceSpan [Comment] Declaration deriving (Show, Read) -data FixityAlias- = AliasValue Ident- | AliasConstructor (ProperName 'ConstructorName)- | AliasType (ProperName 'TypeName)+data ValueFixity = ValueFixity Fixity (Qualified (Either Ident (ProperName 'ConstructorName))) (OpName 'ValueOpName) deriving (Eq, Ord, Show, Read) -foldFixityAlias- :: (Ident -> a)- -> (ProperName 'ConstructorName -> a)- -> (ProperName 'TypeName -> a)- -> FixityAlias- -> a-foldFixityAlias f _ _ (AliasValue name) = f name-foldFixityAlias _ g _ (AliasConstructor name) = g name-foldFixityAlias _ _ h (AliasType name) = h name--getValueAlias :: FixityAlias -> Maybe (Either Ident (ProperName 'ConstructorName))-getValueAlias (AliasValue name) = Just $ Left name-getValueAlias (AliasConstructor name) = Just $ Right name-getValueAlias _ = Nothing+data TypeFixity = TypeFixity Fixity (Qualified (ProperName 'TypeName)) (OpName 'TypeOpName)+ deriving (Eq, Ord, Show, Read) -getTypeAlias :: FixityAlias -> Maybe (ProperName 'TypeName)-getTypeAlias (AliasType name) = Just name-getTypeAlias _ = Nothing+pattern ValueFixityDeclaration fixity name op = FixityDeclaration (Left (ValueFixity fixity name op))+pattern TypeFixityDeclaration fixity name op = FixityDeclaration (Right (TypeFixity fixity name op)) -- | The members of a type class instance declaration data TypeInstanceBody@@ -298,6 +278,11 @@ isFixityDecl (PositionedDeclaration _ _ d) = isFixityDecl d isFixityDecl _ = False +getFixityDecl :: Declaration -> Maybe (Either ValueFixity TypeFixity)+getFixityDecl (FixityDeclaration fixity) = Just fixity+getFixityDecl (PositionedDeclaration _ _ d) = getFixityDecl d+getFixityDecl _ = Nothing+ -- | -- Test if a declaration is a foreign import --@@ -361,12 +346,8 @@ -- | Parens Expr -- |- -- Operator section. This will be removed during desugaring and replaced with lambda.- --- | OperatorSection Expr (Either Expr Expr)- -- |- -- An object property getter (e.g. `_.x`). This will be removed during- -- desugaring and expanded into a lambda that reads a property from an object.+ -- A record property getter (e.g. `_.x`). This will be removed during+ -- desugaring and expanded into a lambda that reads a property from a record. -- | ObjectGetter String -- |@@ -390,6 +371,11 @@ -- | Var (Qualified Ident) -- |+ -- An operator. This will be desugared into a function during the "operators"+ -- phase of desugaring.+ --+ | Op (Qualified (OpName 'ValueOpName))+ -- | -- Conditional (if-then-else expression) -- | IfThenElse Expr Expr Expr@@ -487,4 +473,3 @@ $(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''DeclarationRef) $(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ImportDeclarationType)-$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''FixityAlias)
@@ -3,7 +3,10 @@ , isExported ) where +import Prelude.Compat+ import Control.Category ((>>>))+ import Data.Maybe (mapMaybe) import Language.PureScript.AST.Declarations@@ -99,7 +102,7 @@ Left className : (concatMap fromConstraint constraints ++ concatMap fromType tys) where - fromConstraint (name, tys') = Left name : concatMap fromType tys'+ fromConstraint c = Left (constraintClass c) : concatMap fromType (constraintArgs c) fromType = everythingOnTypes (++) go -- Note that type synonyms are disallowed in instance declarations, so@@ -124,21 +127,15 @@ isExported exps (PositionedDeclaration _ _ d) = isExported exps d isExported (Just exps) decl = any (matches decl) exps where- matches (TypeDeclaration ident _) (ValueRef ident') = ident == ident'- matches (ValueDeclaration ident _ _ _) (ValueRef ident') = ident == ident'- matches (ExternDeclaration ident _) (ValueRef ident') = ident == ident'- matches (DataDeclaration _ ident _ _) (TypeRef ident' _) = ident == ident'- matches (ExternDataDeclaration ident _) (TypeRef ident' _) = ident == ident'- matches (TypeSynonymDeclaration ident _ _) (TypeRef ident' _) = ident == ident'+ matches (TypeDeclaration ident _) (ValueRef ident') = ident == ident'+ matches (ValueDeclaration ident _ _ _) (ValueRef ident') = ident == ident'+ matches (ExternDeclaration ident _) (ValueRef ident') = ident == ident'+ matches (DataDeclaration _ ident _ _) (TypeRef ident' _) = ident == ident'+ matches (ExternDataDeclaration ident _) (TypeRef ident' _) = ident == ident'+ matches (TypeSynonymDeclaration ident _ _) (TypeRef ident' _) = ident == ident' matches (TypeClassDeclaration ident _ _ _) (TypeClassRef ident') = ident == ident'-- matches (DataDeclaration _ ident _ _) (ProperRef ident') = runProperName ident == ident'- matches (TypeClassDeclaration ident _ _ _) (ProperRef ident') = runProperName ident == ident'-- matches (FixityDeclaration _ name (Just (Qualified _ (AliasValue _)))) (ValueRef ident') = name == runIdent ident'- matches (FixityDeclaration _ name (Just (Qualified _ (AliasConstructor _)))) (ValueRef ident') = name == runIdent ident'- matches (FixityDeclaration _ name (Just (Qualified _ (AliasType _)))) (TypeOpRef ident') = name == runIdent ident'-+ matches (ValueFixityDeclaration _ _ op) (ValueOpRef op') = op == op'+ matches (TypeFixityDeclaration _ _ op) (TypeOpRef op') = op == op' matches (PositionedDeclaration _ _ d) r = d `matches` r matches d (PositionedDeclarationRef _ _ r) = d `matches` r matches _ _ = False
@@ -1,9 +1,9 @@-{-# LANGUAGE DeriveFunctor #-}- -- | -- The core functional representation for literal values. -- module Language.PureScript.AST.Literals where++import Prelude.Compat -- | -- Data type for literal values. Parameterised so it can be used for Exprs and
@@ -5,6 +5,8 @@ -- module Language.PureScript.AST.Operators where +import Prelude.Compat+ import Data.Aeson ((.=)) import qualified Data.Aeson as A
@@ -1,5 +1,3 @@-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-} -- |@@ -7,7 +5,6 @@ -- module Language.PureScript.AST.SourcePos where -import Prelude () import Prelude.Compat import Data.Aeson ((.=), (.:))
@@ -1,21 +1,18 @@-{-# LANGUAGE ScopedTypeVariables #-}- -- | -- AST traversal helpers -- module Language.PureScript.AST.Traversals where -import Prelude () import Prelude.Compat -import Data.Maybe (mapMaybe)-import Data.List (mapAccumL)-import Data.Foldable (fold)-import qualified Data.Set as S- import Control.Monad import Control.Arrow ((***), (+++)) +import Data.Foldable (fold)+import Data.List (mapAccumL)+import Data.Maybe (mapMaybe)+import qualified Data.Set as S+ import Language.PureScript.AST.Binders import Language.PureScript.AST.Literals import Language.PureScript.AST.Declarations@@ -47,8 +44,6 @@ g' (UnaryMinus v) = g (UnaryMinus (g' v)) g' (BinaryNoParens op v1 v2) = g (BinaryNoParens (g' op) (g' v1) (g' v2)) g' (Parens v) = g (Parens (g' v))- g' (OperatorSection op (Left v)) = g (OperatorSection (g' op) (Left $ g' v))- g' (OperatorSection op (Right v)) = g (OperatorSection (g' op) (Right $ g' v)) g' (TypeClassDictionaryConstructorApp name v) = g (TypeClassDictionaryConstructorApp name (g' v)) g' (Accessor prop v) = g (Accessor prop (g' v)) g' (ObjectUpdate obj vs) = g (ObjectUpdate (g' obj) (map (fmap g') vs))@@ -116,8 +111,6 @@ g' (UnaryMinus v) = UnaryMinus <$> (g v >>= g') g' (BinaryNoParens op v1 v2) = BinaryNoParens <$> (g op >>= g') <*> (g v1 >>= g') <*> (g v2 >>= g') g' (Parens v) = Parens <$> (g v >>= g')- g' (OperatorSection op (Left v)) = OperatorSection <$> (g op >>= g') <*> (Left <$> (g v >>= g'))- g' (OperatorSection op (Right v)) = OperatorSection <$> (g op >>= g') <*> (Right <$> (g v >>= g')) g' (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> (g v >>= g') g' (Accessor prop v) = Accessor prop <$> (g v >>= g') g' (ObjectUpdate obj vs) = ObjectUpdate <$> (g obj >>= g') <*> traverse (sndM (g' <=< g)) vs@@ -185,8 +178,6 @@ g' (UnaryMinus v) = (UnaryMinus <$> g' v) >>= g g' (BinaryNoParens op v1 v2) = (BinaryNoParens <$> g' op <*> g' v1 <*> g' v2) >>= g g' (Parens v) = (Parens <$> g' v) >>= g- g' (OperatorSection op (Left v)) = (OperatorSection <$> g' op <*> (Left <$> g' v)) >>= g- g' (OperatorSection op (Right v)) = (OperatorSection <$> g' op <*> (Right <$> g' v)) >>= g g' (TypeClassDictionaryConstructorApp name v) = (TypeClassDictionaryConstructorApp name <$> g' v) >>= g g' (Accessor prop v) = (Accessor prop <$> g' v) >>= g g' (ObjectUpdate obj vs) = (ObjectUpdate <$> g' obj <*> traverse (sndM g') vs) >>= g@@ -259,8 +250,6 @@ g' v@(UnaryMinus v1) = g v <> g' v1 g' v@(BinaryNoParens op v1 v2) = g v <> g' op <> g' v1 <> g' v2 g' v@(Parens v1) = g v <> g' v1- g' v@(OperatorSection op (Left v1)) = g v <> g' op <> g' v1- g' v@(OperatorSection op (Right v1)) = g v <> g' op <> g' v1 g' v@(TypeClassDictionaryConstructorApp _ v1) = g v <> g' v1 g' v@(Accessor _ v1) = g v <> g' v1 g' v@(ObjectUpdate obj vs) = foldl (<>) (g v <> g' obj) (map (g' . snd) vs)@@ -338,8 +327,6 @@ g' s (UnaryMinus v1) = g'' s v1 g' s (BinaryNoParens op v1 v2) = g'' s op <> g'' s v1 <> g'' s v2 g' s (Parens v1) = g'' s v1- g' s (OperatorSection op (Left v)) = g'' s op <> g'' s v- g' s (OperatorSection op (Right v)) = g'' s op <> g'' s v g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1 g' s (Accessor _ v1) = g'' s v1 g' s (ObjectUpdate obj vs) = foldl (<>) (g'' s obj) (map (g'' s . snd) vs)@@ -419,8 +406,6 @@ g' s (UnaryMinus v) = UnaryMinus <$> g'' s v g' s (BinaryNoParens op v1 v2) = BinaryNoParens <$> g'' s op <*> g'' s v1 <*> g'' s v2 g' s (Parens v) = Parens <$> g'' s v- g' s (OperatorSection op (Left v)) = OperatorSection <$> g'' s op <*> (Left <$> g'' s v)- g' s (OperatorSection op (Right v)) = OperatorSection <$> g'' s op <*> (Right <$> g'' s v) g' s (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> g'' s v g' s (Accessor prop v) = Accessor prop <$> g'' s v g' s (ObjectUpdate obj vs) = ObjectUpdate <$> g'' s obj <*> traverse (sndM (g'' s)) vs@@ -510,8 +495,6 @@ g' s (UnaryMinus v1) = g'' s v1 g' s (BinaryNoParens op v1 v2) = g'' s op <> g'' s v1 <> g'' s v2 g' s (Parens v1) = g'' s v1- g' s (OperatorSection op (Left v)) = g'' s op <> g'' s v- g' s (OperatorSection op (Right v)) = g'' s op <> g'' s v g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1 g' s (Accessor _ v1) = g'' s v1 g' s (ObjectUpdate obj vs) = g'' s obj <> foldMap (g'' s . snd) vs@@ -593,13 +576,13 @@ where forDecls (DataDeclaration _ _ _ dctors) = mconcat (concatMap (map f . snd) dctors) forDecls (ExternDeclaration _ ty) = f ty- forDecls (TypeClassDeclaration _ _ implies _) = mconcat (concatMap (map f . snd) implies)- forDecls (TypeInstanceDeclaration _ cs _ tys _) = mconcat (concatMap (map f . snd) cs) `mappend` mconcat (map f tys)+ forDecls (TypeClassDeclaration _ _ implies _) = mconcat (concatMap (map f . constraintArgs) implies)+ forDecls (TypeInstanceDeclaration _ cs _ tys _) = mconcat (concatMap (map f . constraintArgs) cs) `mappend` mconcat (map f tys) forDecls (TypeSynonymDeclaration _ _ ty) = f ty forDecls (TypeDeclaration _ ty) = f ty forDecls _ = mempty - forValues (TypeClassDictionary (_, cs) _) = mconcat (map f cs)+ forValues (TypeClassDictionary c _) = mconcat (map f (constraintArgs c)) forValues (SuperClassDictionary _ tys) = mconcat (map f tys) forValues (TypedValue _ _ ty) = f ty forValues _ = mempty
@@ -1,48 +1,32 @@------------------------------------------------------------------------------------ Module : psc-bundle--- Copyright : (c) Phil Freeman 2015--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :------ | Bundles compiled PureScript modules for the browser.+-- |+-- Bundles compiled PureScript modules for the browser. -- -- This module takes as input the individual generated modules from 'Language.PureScript.Make' and -- performs dead code elimination, filters empty modules, -- and generates the final Javascript bundle.--------------------------------------------------------------------------------{-# LANGUAGE PatternGuards #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TupleSections #-}--module Language.PureScript.Bundle (- bundle- , ModuleIdentifier(..)- , moduleName- , ModuleType(..)- , ErrorMessage(..)- , printErrorMessage- , getExportedIdentifiers-) where+module Language.PureScript.Bundle+ ( bundle+ , ModuleIdentifier(..)+ , moduleName+ , ModuleType(..)+ , ErrorMessage(..)+ , printErrorMessage+ , getExportedIdentifiers+ ) where -import Prelude () import Prelude.Compat -import Data.List (nub, stripPrefix)-import Data.Maybe (mapMaybe, catMaybes, fromMaybe)+import Control.Monad+import Control.Monad.Error.Class++import Data.Char (chr, digitToInt) import Data.Generics (everything, everywhere, mkQ, mkT) import Data.Graph+import Data.List (nub, stripPrefix)+import Data.Maybe (mapMaybe, catMaybes) import Data.Version (showVersion)- import qualified Data.Set as S -import Control.Monad-import Control.Monad.Error.Class import Language.JavaScript.Parser import Language.JavaScript.Parser.AST @@ -134,13 +118,13 @@ name ++ " (" ++ showModuleType ty ++ ")" -- | Calculate the ModuleIdentifier which a require(...) statement imports.-checkImportPath :: Maybe FilePath -> String -> ModuleIdentifier -> S.Set String -> Either String ModuleIdentifier-checkImportPath _ "./foreign" m _ =+checkImportPath :: String -> ModuleIdentifier -> S.Set String -> Either String ModuleIdentifier+checkImportPath "./foreign" m _ = Right (ModuleIdentifier (moduleName m) Foreign)-checkImportPath requirePath name _ names- | Just name' <- stripPrefix (fromMaybe "../" requirePath) name+checkImportPath name _ names+ | Just name' <- stripPrefix "../" name , name' `S.member` names = Right (ModuleIdentifier name' Regular)-checkImportPath _ name _ _ = Left name+checkImportPath name _ _ = Left name -- | Compute the dependencies of all elements in a module, and add them to the tree. --@@ -203,11 +187,34 @@ -- String literals include the quote chars fromStringLiteral :: JSExpression -> Maybe String-fromStringLiteral (JSStringLiteral _ str) = Just $ trimStringQuotes str+fromStringLiteral (JSStringLiteral _ str) = Just $ strValue str fromStringLiteral _ = Nothing -trimStringQuotes :: String -> String-trimStringQuotes str = reverse $ drop 1 $ reverse $ drop 1 $ str+strValue :: String -> String+strValue str = go $ drop 1 str+ where+ go ('\\' : 'b' : xs) = '\b' : go xs+ go ('\\' : 'f' : xs) = '\f' : go xs+ go ('\\' : 'n' : xs) = '\n' : go xs+ go ('\\' : 'r' : xs) = '\r' : go xs+ go ('\\' : 't' : xs) = '\t' : go xs+ go ('\\' : 'v' : xs) = '\v' : go xs+ go ('\\' : '0' : xs) = '\0' : go xs+ go ('\\' : 'x' : a : b : xs) = chr (a' + b') : go xs+ where+ a' = 16 * digitToInt a+ b' = digitToInt b+ go ('\\' : 'u' : a : b : c : d : xs) = chr (a' + b' + c' + d') : go xs+ where+ a' = 16 * 16 * 16 * digitToInt a+ b' = 16 * 16 * digitToInt b+ c' = 16 * digitToInt c+ d' = digitToInt d+ go ('\\' : x : xs) = x : go xs+ go "\"" = ""+ go "'" = ""+ go (x : xs) = x : go xs+ go "" = "" commaList :: JSCommaList a -> [a] commaList JSLNil = []@@ -222,8 +229,8 @@ -- -- Each type of module element is matched using pattern guards, and everything else is bundled into the -- Other constructor.-toModule :: forall m. (MonadError ErrorMessage m) => Maybe FilePath -> S.Set String -> ModuleIdentifier -> JSAST -> m Module-toModule requirePath mids mid top+toModule :: forall m. (MonadError ErrorMessage m) => S.Set String -> ModuleIdentifier -> JSAST -> m Module+toModule mids mid top | JSAstProgram smts _ <- top = Module mid <$> traverse toModuleElement smts | otherwise = err InvalidTopLevel where@@ -231,7 +238,7 @@ toModuleElement :: JSStatement -> m ModuleElement toModuleElement stmt- | Just (importName, importPath) <- matchRequire requirePath mids mid stmt+ | Just (importName, importPath) <- matchRequire mids mid stmt = pure (Require stmt importName importPath) toModuleElement stmt | Just (exported, name, decl) <- matchMember stmt@@ -291,12 +298,11 @@ -- Matches JS statements like this: -- var ModuleName = require("file");-matchRequire :: Maybe FilePath- -> S.Set String+matchRequire :: S.Set String -> ModuleIdentifier -> JSStatement -> Maybe (String, Either String ModuleIdentifier)-matchRequire requirePath mids mid stmt+matchRequire mids mid stmt | JSVariable _ jsInit _ <- stmt , [JSVarInitExpression var varInit] <- commaList jsInit , JSIdentifier _ importName <- var@@ -304,7 +310,7 @@ , JSMemberExpression req _ argsE _ <- jsInitEx , JSIdentifier _ "require" <- req , [ Just importPath ] <- map fromStringLiteral (commaList argsE)- , importPath' <- checkImportPath requirePath importPath mid mids+ , importPath' <- checkImportPath importPath mid mids = Just (importName, importPath') | otherwise = Nothing@@ -350,7 +356,7 @@ = Nothing extractLabel :: JSPropertyName -> Maybe String-extractLabel (JSPropertyString _ nm) = Just (trimStringQuotes nm)+extractLabel (JSPropertyString _ nm) = Just $ strValue nm extractLabel (JSPropertyIdent _ nm) = Just nm extractLabel _ = Nothing @@ -590,16 +596,15 @@ -> [ModuleIdentifier] -- ^ Entry points. These module identifiers are used as the roots for dead-code elimination -> Maybe String -- ^ An optional main module. -> String -- ^ The namespace (e.g. PS).- -> Maybe FilePath -- ^ The require path prefix -> m String-bundle inputStrs entryPoints mainModule namespace requirePath = do+bundle inputStrs entryPoints mainModule namespace = do input <- forM inputStrs $ \(ident, js) -> do ast <- either (throwError . ErrorInModule ident . UnableToParseModule) pure $ parse js (moduleName ident) return (ident, ast) let mids = S.fromList (map (moduleName . fst) input) - modules <- traverse (fmap withDeps . uncurry (toModule requirePath mids)) input+ modules <- traverse (fmap withDeps . uncurry (toModule mids)) input let compiled = compile modules entryPoints sorted = sortModules (filter (not . isModuleEmpty) compiled)
@@ -1,20 +1,8 @@------------------------------------------------------------------------------------ Module : Language.PureScript.CodeGen--- Copyright : (c) Phil Freeman 2013--- License : MIT------ Maintainer : Phil Freeman <paf31@cantab.net>--- Stability : experimental--- Portability :------ |--- A collection of modules related to code generation:------ [@Language.PureScript.CodeGen.JS@] Code generator for Javascript-----------------------------------------------------------------------------------module Language.PureScript.CodeGen (module C) where--import Language.PureScript.CodeGen.JS as C+-- | +-- A collection of modules related to code generation: +-- +-- [@Language.PureScript.CodeGen.JS@] Code generator for Javascript +-- +module Language.PureScript.CodeGen (module C) where + +import Language.PureScript.CodeGen.JS as C
@@ -1,8 +1,3 @@-{-# LANGUAGE GADTs #-}-{-# LANGUAGE ViewPatterns #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}- -- | -- This module generates code in the simplified Javascript intermediate representation from Purescript code --@@ -12,29 +7,28 @@ , moduleToJs ) where -import Prelude () import Prelude.Compat -import Data.List ((\\), delete, intersect)-import Data.Maybe (isNothing, fromMaybe)-import qualified Data.Map as M-import qualified Data.Foldable as F-import qualified Data.Traversable as T- import Control.Arrow ((&&&)) import Control.Monad (replicateM, forM, void) import Control.Monad.Error.Class (MonadError(..)) import Control.Monad.Reader (MonadReader, asks) import Control.Monad.Supply.Class -import Language.PureScript.Crash+import Data.List ((\\), delete, intersect)+import Data.Maybe (isNothing, fromMaybe)+import qualified Data.Foldable as F+import qualified Data.Map as M+import qualified Data.Traversable as T+ import Language.PureScript.AST.SourcePos import Language.PureScript.CodeGen.JS.AST as AST import Language.PureScript.CodeGen.JS.Common as Common+import Language.PureScript.CodeGen.JS.Optimizer import Language.PureScript.CoreFn-import Language.PureScript.Names+import Language.PureScript.Crash import Language.PureScript.Errors-import Language.PureScript.CodeGen.JS.Optimizer+import Language.PureScript.Names import Language.PureScript.Options import Language.PureScript.Traversals (sndM) import qualified Language.PureScript.Constants as C@@ -109,9 +103,8 @@ -- importToJs :: M.Map ModuleName (Ann, ModuleName) -> ModuleName -> m JS importToJs mnLookup mn' = do- path <- asks optionsRequirePath let ((ss, _, _, _), mnSafe) = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup- let moduleBody = JSApp Nothing (JSVar Nothing "require") [JSStringLiteral Nothing (fromMaybe ".." path </> runModuleName mn')]+ let moduleBody = JSApp Nothing (JSVar Nothing "require") [JSStringLiteral Nothing (".." </> runModuleName mn')] withPos ss $ JSVariableIntroduction Nothing (moduleNameToJs mnSafe) (Just moduleBody) -- |@@ -180,7 +173,6 @@ -- accessor :: Ident -> JS -> JS accessor (Ident prop) = accessorString prop- accessor (Op op) = JSIndexer Nothing (JSStringLiteral Nothing op) accessor (GenIdent _ _) = internalError "GenIdent in accessor" accessorString :: String -> JS -> JS
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff
file too large to diff