### Starting PureScript PSCi REPL Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Launches the PureScript interactive environment (PSCi) using the Spago build tool. ```Command Line spago repl ``` -------------------------------- ### Installing PureScript Compiler with npm Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Installs the PureScript compiler globally using the npm package manager. Requires Node.js and npm to be installed. ```bash npm install -g purescript ``` -------------------------------- ### Installing Dependencies with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Installs specified library dependencies (`lists` and `foldable-traversable`) for the PureScript project using the Spago package manager. The libraries are downloaded and made available for compilation. ```bash spago install lists foldable-traversable ``` -------------------------------- ### Installing PureScript Library with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Command to install the 'assert' library dependency for the PureScript project using the Spago package manager, required for writing tests. ```Shell spago install assert ``` -------------------------------- ### Installing Spago Build Tool with npm Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Installs the Spago package manager and build tool globally using the npm package manager. Spago is recommended for PureScript projects. ```bash npm install -g spago ``` -------------------------------- ### Displaying PSCi Help Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Shows a list of available commands and their descriptions within the PSCi REPL. ```PSCi :? ``` -------------------------------- ### Setting up PSCi with Spago Source: https://github.com/purescript/documentation/blob/master/guides/PSCi.md These commands demonstrate how to install Spago, initialize a new project, and start the PSCi REPL. ```text $ npm install -g spago $ cd my-project $ spago init $ spago repl ``` -------------------------------- ### Example of PureScript Compiled to JavaScript (JavaScript) Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Shows a snippet of the JavaScript code generated by the PureScript compiler. Illustrates how PureScript modules, functions, and variables are translated into JavaScript, including dead code elimination and module structure. ```JavaScript (() => { // output/Data.Show/foreign.js var showIntImpl = function(n) { return n.toString(); }; ... // output/Euler/index.js var ns = /* @__PURE__ */ function() { return range2(0)(999); }(); var multiples = /* @__PURE__ */ function() { return filter(function(n) { return mod(euclideanRingInt)(n)(3) === 0 || mod(euclideanRingInt)(n)(5) === 0; })(ns); }(); var answer = /* @__PURE__ */ function() { return sum(foldableList)(semiringInt)(multiples); }(); // output/Main/index.js var main = /* @__PURE__ */ function() { return log("The answer is " + show(showInt)(answer)); }(); // main(); })(); ``` -------------------------------- ### Verifying PureScript Compiler Installation Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Runs the `purs` command on the command line to check if the PureScript compiler executable is available in the system's PATH. ```bash purs ``` -------------------------------- ### Quitting PSCi REPL Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Exits the PureScript interactive environment (PSCi). ```PSCi :quit ``` -------------------------------- ### Creating a New PureScript Project with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Creates a new directory, navigates into it, and initializes a new PureScript project using `spago init`. This sets up the basic project structure and configuration files. ```bash mkdir my-project cd my-project spago init ``` -------------------------------- ### Running PureScript Project Tests with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Executes the test suite defined in the PureScript project using the Spago build tool. This verifies the project's functionality. ```bash spago test ``` -------------------------------- ### Building a PureScript Project with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Compiles the PureScript project source files using the Spago build tool. This command processes the code and dependencies. ```bash spago build ``` -------------------------------- ### Compiling PureScript Project with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Shows the command to compile the PureScript source files in the 'src/' directory into JavaScript files in the 'output/' directory using the Spago build tool. ```Shell spago build ``` -------------------------------- ### Importing Modules in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Imports the standard Prelude and Data.List modules into the current PSCi session, making their functions available. ```PSCi import Prelude import Data.List ``` -------------------------------- ### Running PureScript Executable with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Command to compile and execute the 'Main' module of the PureScript project using Spago. This runs the code defined in 'src/Main.purs'. ```Shell $ spago run [info] Build succeeded. The answer is 233168 ``` -------------------------------- ### Running PureScript Tests with Spago Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Command to execute the test suite defined in the project, typically located in the 'test/' directory, using the Spago build tool. ```Shell spago test ``` -------------------------------- ### Bundle PureScript for Browser with Spago (Shell) Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Executes the Spago command to compile and bundle PureScript code into a single JavaScript file (index.js) suitable for web browsers. Shows the command output including file size and completion time. ```Shell $ spago bundle-app index.js 11.8kb ⚡ Done in 14ms [info] Bundle succeeded and output file to index.js ``` -------------------------------- ### Loading Module into PureScript REPL Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Demonstrates how to load the 'Euler' module into the Spago REPL for interactive testing and exploration. Shows importing the module and accessing the 'answer' value. ```Shell spago repl > import Euler > answer 233168 > :quit See ya! ``` -------------------------------- ### Example PureScript Module Triggering Error Source: https://github.com/purescript/documentation/blob/master/errors/CannotUseBindWithDo.md This code snippet provides a minimal example of a PureScript module structure where the 'CannotUseBindWithDo' error might occur. It serves as a starting point to understand the context of the error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Importing Data.Foldable in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Imports the Data.Foldable module into the current PSCi session to access functions like 'sum'. ```PSCi import Data.Foldable ``` -------------------------------- ### Generating a Range of Numbers in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Uses the 'range' function from Data.List to create a list of integers from 0 up to 999 (inclusive). ```PureScript range 0 999 ``` -------------------------------- ### Installing psc-ide plugin for VIM Source: https://github.com/purescript/documentation/blob/master/guides/psc-ide-FAQ.md This snippet shows the command to install the psc-ide plugin for the VIM editor using the NeoBundle plugin manager. This is required to get psc-ide support within VIM. ```Vim script NeoBundle "frigoeu/psc-ide-vim" ``` -------------------------------- ### HTML Structure Including Bundled PureScript Output (HTML) Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Provides a basic HTML document structure that includes the bundled JavaScript file (index.js) generated by spago bundle-app. This demonstrates how to integrate the compiled PureScript code into a web page. ```HTML Euler Exercise ``` -------------------------------- ### Build PureScript as ES Modules with Spago (Shell) Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Executes the Spago command to compile PureScript code into separate ES modules. This is useful for Node.js projects or larger web projects using module systems. Shows the command output indicating successful build. ```Shell $ spago build ... Build succeeded. ``` -------------------------------- ### Writing Test Suite in PureScript Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Provides a basic test suite in PureScript using the 'Test.Assert' library. It defines a 'main' function that asserts the calculated 'answer' from the 'Euler' module is equal to the expected value. Requires the 'assert' library. ```PureScript module Test.Main where import Prelude import Euler (answer) import Test.Assert (assert) main = do assert (answer == 233168) ``` -------------------------------- ### Creating Executable Main Module in PureScript Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Modifies the 'src/Main.purs' module to create an executable. It imports the 'answer' from the 'Euler' module and uses 'Effect.Console.log' to print the result to the console. Requires the 'effect' library (implicitly via Prelude or other dependencies). ```PureScript module Main where import Prelude import Euler (answer) import Effect.Console (log) main = do log ("The answer is " <> show answer) ``` -------------------------------- ### Calculating Sum of List in PureScript Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Uses the 'sum' function from Data.Foldable to calculate the sum of all elements in the 'multiples' list. ```PureScript sum multiples ``` -------------------------------- ### Example of PossiblyInfiniteInstance Error Context in PureScript Source: https://github.com/purescript/documentation/blob/master/errors/PossiblyInfiniteInstance.md This snippet provides a minimal example of a PureScript module structure where the `PossiblyInfiniteInstance` error might manifest. It serves as a starting point to illustrate the context of the error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example of New Polymorphic Proxy Usage - PureScript Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.14-Migration-Guide.md Shows the recommended way to use the new polymorphic `Proxy` type in PureScript 0.14 and later, replacing deprecated monomorphic proxies like `SProxy`. ```PureScript -- Code written for PureScript 0.14 which will continue to work with -- PureScript 0.15. getFoo = Record.get (Proxy :: Proxy "foo") ``` -------------------------------- ### PureScript Documentation Comment (bool) Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Example of a documentation comment for a function, starting with `-- |`. These comments are used by documentation generation tools. ```purescript -- | `bool` performs case analysis for the `Boolean` data type, like an `if` statement. bool :: forall a. Boolean -> a -> a -> a bool true x _ = x bool false _ x = x ``` -------------------------------- ### Evaluating Variable in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Evaluates and prints the value currently assigned to the 'multiples' variable in the PSCi session. ```PureScript multiples ``` -------------------------------- ### Defining Euler Module in PureScript Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Defines a PureScript module 'Euler' that calculates the sum of multiples of 3 or 5 below 1000. It imports 'Prelude', 'Data.List' for 'range' and 'filter', and 'Data.Foldable' for 'sum'. ```PureScript module Euler where import Prelude import Data.List (range, filter) import Data.Foldable (sum) ns = range 0 999 multiples = filter (\n -> mod n 3 == 0 || mod n 5 == 0) ns answer = sum multiples ``` -------------------------------- ### Example Values for ZipList Alt Instance Issue in PureScript Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.14-Migration-Guide.md These PureScript values `f`, `g`, and `x` are used to demonstrate the failure of the old `ZipList` `Alt` instance to satisfy the `Alternative` distributivity law, showing different results for the left and right sides of the equation. ```PureScript f = g = ZipList ((_ + 1) : Nil) x = ZipList (0 : Nil) ``` -------------------------------- ### Example of Deprecated SProxy Usage - PureScript Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.14-Migration-Guide.md Demonstrates how a monomorphic proxy like `SProxy` was used before PureScript 0.14. This code will compile in 0.14 but is deprecated and will not compile in 0.15. ```PureScript -- Code written pre-PureScript 0.14, which will compile with PureScript 0.14 -- but will not compile with PureScript 0.15. getFoo = Record.get (SProxy :: SProxy "foo") ``` -------------------------------- ### Example Purescript Module for UserDefinedWarning Source: https://github.com/purescript/documentation/blob/master/errors/UserDefinedWarning.md An example Purescript module illustrating the context where a 'UserDefinedWarning' error might occur. This snippet serves as a minimal failing example. ```Purescript module ShortFailingExample where ... ``` -------------------------------- ### Filtering Multiples of 3 or 5 in PureScript Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Filters the list 'ns' to keep only numbers that are multiples of 3 or 5, using a lambda function as the predicate. ```PureScript multiples = filter (\n -> mod n 3 == 0 || mod n 5 == 0) ns ``` -------------------------------- ### Example Module Definition - PureScript Source: https://github.com/purescript/documentation/blob/master/errors/UnverifiableSuperclassInstance.md This snippet shows a basic PureScript module definition that serves as an example context where the `UnverifiableSuperclassInstance` warning might occur. The '...' indicates placeholder code. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Checking Type of Data.List.zip in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Displays the inferred type signature of the 'zip' function from the Data.List module within the PSCi REPL. ```PSCi :type zip ``` -------------------------------- ### Evaluating Basic Expressions in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/PSCi.md Examples of evaluating simple expressions, arithmetic, and importing/using effects within the PSCi REPL. ```PureScript > "hello" "hello" > import Prelude > 1 + 2 * 3 7 > import Effect.Console > log "print this to the screen" print this to the screen unit ``` -------------------------------- ### PureScript Documentation Comment (sort) Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Another example of documentation comments, showing how multiple lines can be marked as documentation and how regular comments can coexist. ```purescript -- | Sort an array based on its `Ord` instance. -- | -- | This implementation runs in `O(n^2)` time, where `n` is the length of the -- | input array. -- TODO: try to optimise this? sort :: forall a. (Ord a) => Array a -> Array a sort xs = [...] ``` -------------------------------- ### Checking Type of Function in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Displays the inferred type signature of the 'map' function from an imported module within the PSCi REPL. ```PSCi :type map ``` -------------------------------- ### Simple Function Declaration Example in PureScript Source: https://github.com/purescript/documentation/blob/master/language/Pattern-Matching.md Provides a basic example of a function declaration in PureScript, illustrating the syntax where arguments are simple variable patterns. ```purescript example x y z = x * y + z ``` -------------------------------- ### Example PureScript Module for Error Documentation Source: https://github.com/purescript/documentation/blob/master/errors/Template.md An example PureScript module demonstrating the structure used within the `ErrorCode` error documentation. It shows a basic module definition. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Assigning Range to Variable in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Assigns the list generated by 'range 0 999' to the variable 'ns' for later use in the PSCi session. ```PureScript ns = range 0 999 ``` -------------------------------- ### JavaScript Equivalent of PureScript Lambda Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Provides the equivalent JavaScript code for the PureScript anonymous function example, showing how currying is handled. ```javascript function (a) { return function (b) { return a + b; } } ``` -------------------------------- ### Basic PureScript Module Example Source: https://github.com/purescript/documentation/blob/master/errors/ExpectedWildcard.md This snippet shows a basic PureScript module definition, likely used as an example to demonstrate the ExpectedWildcard error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Purescript Module Demonstrating Error Context Source: https://github.com/purescript/documentation/blob/master/errors/UnusedFFIImplementations.md This snippet shows a basic Purescript module structure, likely used as a minimal example to trigger or illustrate the 'UnusedFFIImplementations' error. ```Purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Module for Incomplete Exhaustivity Check Source: https://github.com/purescript/documentation/blob/master/errors/IncompleteExhaustivityCheck.md A minimal PureScript module example demonstrating the context where the `IncompleteExhaustivityCheck` error might occur. This snippet shows the basic structure of a module that could trigger the error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Module Definition - PureScript Source: https://github.com/purescript/documentation/blob/master/errors/CycleInTypeSynonym.md This snippet shows a basic PureScript module definition used as an example to illustrate the `CycleInTypeSynonym` error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example of UnknownExportDataConstructor Error in Purescript Source: https://github.com/purescript/documentation/blob/master/errors/UnknownExportDataConstructor.md Provides a minimal Purescript module structure used as an example to demonstrate the `UnknownExportDataConstructor` error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Deprecated Monomorphic Proxy Types - PureScript Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.14-Migration-Guide.md Shows examples of various monomorphic proxy types (`Proxy`, `Proxy2`, `SProxy`, etc.) used before PureScript 0.14, which are now deprecated in favor of a single polymorphic `Proxy`. ```PureScript data Proxy (a :: Type) = Proxy data Proxy2 (a :: Type -> Type) = Proxy2 data Proxy3 (a :: Type -> Type -> Type) = Proxy3 data SProxy (a :: Symbol) = SProxy data RProxy (row :: # Type) = RProxy data RLProxy (row :: RowList) = RLProxy -- ...and so on. ``` -------------------------------- ### PureScript Module Definition Example Source: https://github.com/purescript/documentation/blob/master/errors/ExpectedTypeConstructor.md This snippet shows a basic PureScript module definition, likely used as part of an example demonstrating the `ExpectedTypeConstructor` error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example PureScript Module Source: https://github.com/purescript/documentation/blob/master/errors/IncorrectConstructorArity.md An example PureScript module intended to demonstrate the IncorrectConstructorArity error. The '...' indicates placeholder code that would trigger the error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Purescript Module Triggering InfiniteKind Error Source: https://github.com/purescript/documentation/blob/master/errors/InfiniteKind.md This code snippet provides a minimal example of a Purescript module structure that is intended to demonstrate or trigger the 'InfiniteKind' error. The '...' placeholder indicates where the specific problematic code would be located. ```Purescript module ShortFailingExample where ... ``` -------------------------------- ### Example PureScript Module Definition Source: https://github.com/purescript/documentation/blob/master/errors/MultipleValueOpFixities.md This snippet shows a basic PureScript module definition used as an example within the documentation for the MultipleValueOpFixities error. It serves as a placeholder to illustrate the context where the error might occur. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Module Declaration - PureScript Source: https://github.com/purescript/documentation/blob/master/errors/InvalidFFIIdentifier.md A minimal PureScript module declaration used as an example that might encounter the `InvalidFFIIdentifier` error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Purescript Module for UnknownClass Error Source: https://github.com/purescript/documentation/blob/master/errors/UnknownClass.md This snippet provides a minimal example of a Purescript module structure, likely intended to demonstrate code that could trigger the 'UnknownClass' error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Purescript Module for UnknownExport Error Source: https://github.com/purescript/documentation/blob/master/errors/UnknownExport.md A minimal Purescript module definition used as an example to demonstrate the `UnknownExport` error. It shows the basic structure of a module declaration. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Triggering ImplicitQualifiedImportReExport Warning Source: https://github.com/purescript/documentation/blob/master/errors/ImplicitQualifiedImportReExport.md This PureScript code snippet provides a minimal example that is intended to trigger the `ImplicitQualifiedImportReExport` warning, demonstrating the scenario where the warning occurs. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example Code for OverlappingInstances Error (Purescript) Source: https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md This code snippet provides a minimal example that might trigger the OverlappingInstances error in Purescript. It serves as a starting point for understanding the context where this error occurs. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example of AdditionalProperty Error (Purescript) Source: https://github.com/purescript/documentation/blob/master/errors/AdditionalProperty.md This Purescript code snippet provides a minimal example module intended to demonstrate or trigger the 'AdditionalProperty' error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Example of ShadowedTypeVar Error in PureScript Source: https://github.com/purescript/documentation/blob/master/errors/ShadowedTypeVar.md This code snippet provides a minimal example module in PureScript designed to demonstrate or trigger the ShadowedTypeVar compiler error. It serves as a starting point for understanding the context in which this error occurs. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Example PureScript Module Triggering Error Source: https://github.com/purescript/documentation/blob/master/errors/MissingFFIImplementations.md This snippet shows a minimal PureScript module structure that is used as an example to demonstrate the context in which the MissingFFIImplementations error might occur. The '...' placeholder indicates where the specific code causing the error would be located. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Purescript Module Definition Example Source: https://github.com/purescript/documentation/blob/master/errors/ConstrainedTypeUnified.md A minimal Purescript module definition used as an example, likely to demonstrate a scenario that triggers the 'ConstrainedTypeUnified' error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### PureScript Module Definition Example Source: https://github.com/purescript/documentation/blob/master/errors/AmbiguousTypeVariables.md An example PureScript module definition used to demonstrate the 'AmbiguousTypeVariables' error. This snippet shows the basic structure of a module declaration. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### PureScript Numeric Literals Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Examples of integer (`Int`) and floating-point (`Number`) literals, including hexadecimal notation for integers. ```purescript 16 :: Int 0xF0 :: Int 16.0 :: Number ``` -------------------------------- ### Checking Type of Variable in PSCi Source: https://github.com/purescript/documentation/blob/master/guides/Getting-Started.md Displays the inferred type of the 'multiples' variable within the PSCi REPL. ```PSCi :type multiples ``` -------------------------------- ### Example of MissingNewtypeSuperclassInstance Warning in PureScript Source: https://github.com/purescript/documentation/blob/master/errors/MissingNewtypeSuperclassInstance.md This snippet provides a minimal example demonstrating the context in which the `MissingNewtypeSuperclassInstance` warning might occur in PureScript code. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Example PureScript Module Definition Source: https://github.com/purescript/documentation/blob/master/errors/HoleInferredType.md This snippet shows a basic PureScript module definition, likely used as a minimal example to demonstrate the `HoleInferredType` error. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Generics Module Renaming Mapping - Text Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.14-Migration-Guide.md Lists the mapping of old `Data.Generic.Rep` module names to their new locations in `prelude` or `enums` after the `generics-rep` library was merged. ```text Data.Generic.Rep.Bounded -> Data.Bounded.Generic Data.Generic.Rep.Enum -> Data.Enum.Generic (in the `enums` package) Data.Generic.Rep.Eq -> Data.Eq.Generic Data.Generic.Rep.HeytingAlgebra -> Data.HeytingAlgebra.Generic Data.Generic.Rep.Monoid -> Data.Monoid.Generic Data.Generic.Rep.Ord -> Data.Ord.Generic Data.Generic.Rep.Ring -> Data.Ring.Generic Data.Generic.Rep.Semigroup -> Data.Semigroup.Generic Data.Generic.Rep.Semiring -> Data.Semiring.Generic Data.Generic.Rep.Show -> Data.Show.Generic ``` -------------------------------- ### Example PureScript module demonstrating MultipleTypeOpFixities error Source: https://github.com/purescript/documentation/blob/master/errors/MultipleTypeOpFixities.md This snippet provides a minimal example of a PureScript module that is intended to trigger or illustrate the MultipleTypeOpFixities error. The '...' indicates that the problematic code causing the error would be present here. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Example PureScript Module Source: https://github.com/purescript/documentation/blob/master/errors/CycleInTypeClassDeclaration.md An example PureScript module demonstrating the context where the CycleInTypeClassDeclaration error might occur. The '...' indicates placeholder code that would likely trigger the error. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Updating QuickCheck frequency to NonEmptyArray (PureScript) Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.15-Migration-Guide.md Provides examples of how to update code using the `frequency` function in `purescript-quickcheck` to use `NonEmptyArray` instead of `NonEmptyList`, reflecting a change in the library for better array syntax support. Includes examples for constructing the array from a literal list or using `cons'`. ```PureScript import Partial.Unsafe (unsafePartial) import Data.Maybe (fromJust) import Data.Array.NonEmpty as NEA foo = frequency $ unsafePartial $ fromJust $ NEA.fromArray [ Tuple 1 $ pure 1 , Tuple 2 $ pure 2 , Tuple 3 $ pure 3 ] ``` ```PureScript import Data.Array.NonEmpty as NEA foo = frequency $ NEA.cons' (Tuple 1 (pure 1)) someArrayOfTupleGen ``` -------------------------------- ### Example PureScript Module for Export Conflict Source: https://github.com/purescript/documentation/blob/master/errors/ExportConflict.md A minimal PureScript module example intended to illustrate the `ExportConflict` error. The `...` placeholder indicates where conflicting exports or definitions would typically be placed. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Configuring Travis CI for PureScript Projects Source: https://github.com/purescript/documentation/blob/master/guides/Style-Guide.md This YAML configuration file sets up Travis CI for a PureScript project. It specifies Node.js as the environment, installs PureScript and Spago globally, and defines the build script to compile and test the project using Spago. ```yaml language: node_js dist: trusty sudo: required node_js: 6 install: - npm install purescript spago -g script: - spago build && spago test ``` -------------------------------- ### Hello World in PureScript Source: https://github.com/purescript/documentation/blob/master/language/README.md Basic PureScript program that imports the console effect and logs "Hello, World!" to the console. Demonstrates module definition and the `main` function, which is the entry point for the program. ```purescript module Main where import Effect.Console main = log "Hello, World!" ``` -------------------------------- ### Desugared PureScript Do Notation Example Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md This PureScript snippet shows the underlying `bind` operations that the `do` notation from the previous example desugars into. It explicitly uses the `bind` function to sequence monadic operations and the `let-in` structure to define the intermediate `result` before returning the final monadic value using `pure`. ```PureScript maybeSum a b = bind a \n -> bind b \m -> let result = n + m in pure result ``` -------------------------------- ### Example PureScript Module Showing Error Context Source: https://github.com/purescript/documentation/blob/master/errors/ExprDoesNotHaveType.md Provides a minimal PureScript module structure used as an example to illustrate the context in which the ExprDoesNotHaveType error might occur. The '...' indicates where the failing code would be placed. ```purescript module ShortFailingExample where\n\n... ``` -------------------------------- ### Example of DuplicateExportRef Error in PureScript Source: https://github.com/purescript/documentation/blob/master/errors/DuplicateExportRef.md A minimal PureScript module structure illustrating where the `DuplicateExportRef` error might occur. This serves as a starting point for demonstrating the error. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Bundling PureScript output with webpack (Bash) Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.15-Migration-Guide.md Provides basic webpack command examples for bundling, assuming a webpack.config.js file is present according to the documentation. Shows commands for development (unminified) and production (minified) modes. ```bash # Create webpack.config.js according to docs webpack --mode=development # bundle webpack --mode=production # minified bundle ``` -------------------------------- ### Qualified Import Example for Ambiguous Function Names in PureScript Source: https://github.com/purescript/documentation/blob/master/language/Modules.md Provides another example of using a qualified import (`MyWebFramework`) for a function with a non-descriptive name (`run`) to improve code readability and understanding. ```purescript import MyWebFramework as MyWebFramework main :: Effect Unit main = do elem <- domElementById "appContainer" MyWebFramework.run elem -- ^ this may be more clear than -- `run elem` ``` -------------------------------- ### PureScript Function Application Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Demonstrates how functions are applied to arguments in PureScript using simple juxtaposition. ```purescript add 10 20 ``` -------------------------------- ### Example of PropertyIsMissing Error in PureScript Source: https://github.com/purescript/documentation/blob/master/errors/PropertyIsMissing.md This snippet shows the beginning of a PureScript module intended to demonstrate the PropertyIsMissing error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Exhaustive Guards Examples in PureScript Source: https://github.com/purescript/documentation/blob/master/language/Pattern-Matching.md Shows two ways to write exhaustive guards in PureScript, either by using `otherwise` or by providing a final catch-all pattern. ```purescript compare x y | x > y = GT | x < y = LT | otherwise = EQ compare x y | x > y = GT compare x y | x < y = LT compare _ _ = EQ ``` -------------------------------- ### PureScript Declaration with Type Signature Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Example of a top-level function declaration including an explicit type signature, which is considered good practice. ```purescript multiply :: Number -> Number -> Number multiply x y = x * y ``` -------------------------------- ### Example PureScript Module Triggering ExpectedType Error Source: https://github.com/purescript/documentation/blob/master/errors/ExpectedType.md This code snippet provides a minimal example of a PureScript module structure that is used to demonstrate or reproduce the ExpectedType error. The '...' indicates placeholder code that would cause the specific type mismatch. ```PureScript module ShortFailingExample where ... ``` -------------------------------- ### Example module definition - Purescript Source: https://github.com/purescript/documentation/blob/master/errors/InvalidDerivedInstance.md This code snippet provides a minimal example of a Purescript module definition that is intended to illustrate the context in which the InvalidDerivedInstance error might occur. The '...' placeholder indicates that the full code causing the error is omitted for brevity. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Default Kind Inference (PureScript) Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.14-Migration-Guide.md Demonstrates how PureScript 0.13 would default the kind of a type parameter like `a` in `data Proxy a` to `Type`. ```PureScript data Proxy a ``` -------------------------------- ### PureScript Partial Function Application Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Shows how partial application works naturally in PureScript due to functions being curried by default. ```purescript add10 = add 10 ``` -------------------------------- ### PureScript Single-Line Comment Source: https://github.com/purescript/documentation/blob/master/language/Syntax.md Shows the syntax for a single-line comment in PureScript, which starts with two hyphens (`--`). ```purescript -- This is a comment ``` -------------------------------- ### Example Triggering DuplicateTypeClass Error - PureScript Source: https://github.com/purescript/documentation/blob/master/errors/DuplicateTypeClass.md A minimal PureScript code snippet demonstrating the context in which the `DuplicateTypeClass` error might occur. This serves as a starting point for understanding the error. ```purescript module ShortFailingExample where ... ``` -------------------------------- ### Bundling PureScript output with parcel (Bash) Source: https://github.com/purescript/documentation/blob/master/migration-guides/0.15-Migration-Guide.md Illustrates using parcel to build a project, typically starting from an HTML file that includes the compiled PureScript output via a script tag. Shows commands for unoptimized and minified builds, specifying the output directory. ```bash # Note: in the examples below, the `index.html` file # refers to a JavaScript file. If you are including your app # as the entry point, it would have a script tag somewhere in it # that looks something like this: # `