### Quickstart: Running a PureScript Presto Example App Source: https://pursuit.purescript.org/packages/purescript-presto This quickstart guide provides the necessary shell commands to clone the `purescript-presto` repository, navigate to an example application (billpay-react), install its dependencies using `npm` and `bower`, and finally start the development server to view the app in a browser. ```Shell git clone https://github.com/juspay/purescript-presto.git cd purescript-presto/examples/billpay-react npm i bower i npm start ``` -------------------------------- ### Build and Run PureScript Clappr Examples Source: https://pursuit.purescript.org/packages/purescript-clappr Instructions for setting up the development environment, installing dependencies, building the examples, and starting a local HTTP server to view them. Examples are compiled into the ./output directory. ```Shell npm install echo '{ "resolvers": [ "bower-npm-resolver" ] }' >> .bowerrc bower install make ./bin/examples.sh python -m http.server webpack --watch examples/plugins/webpack.config.js ``` -------------------------------- ### Getting Started with purescript-web3-generator Source: https://pursuit.purescript.org/packages/purescript-web3-generator Provides the initial steps to set up and test the `purescript-web3-generator` project locally, including cloning the repository, installing dependencies, and running tests. ```Shell git clone cd purescript-web3-generator npm install pulp build pulp test ``` -------------------------------- ### Run Helix Example Application Source: https://pursuit.purescript.org/packages/purescript-halogen-helix These commands provide instructions for setting up and running the example application associated with the Helix project. It involves installing dependencies and starting the development server. ```Shell npm i npm run example ``` -------------------------------- ### Start Webpack development server for examples Source: https://pursuit.purescript.org/packages/purescript-p5 Starts the webpack development server, allowing the project examples to be viewed in a web browser. After running this command, examples can typically be accessed by visiting `localhost:4008/examples/path-to-example`. ```Shell npm run webpack:server ``` -------------------------------- ### Build and Run Purescript-Concur-React Examples from Source Source: https://pursuit.purescript.org/packages/purescript-concur-react Steps to clone the repository, install dependencies, build the library and examples, start a local development server, and access the examples in a browser. ```Shell git clone https://github.com/purescript-concur/purescript-concur-react.git cd purescript-concur-react npm install # Build library sources npm run build # Build examples npm run examples # Start a local server npm run start # Check examples open localhost:1234 in the browser ``` -------------------------------- ### Running PureScript Web Worker Examples Source: https://pursuit.purescript.org/packages/purescript-workers A step-by-step guide to setting up, compiling, and running the PureScript Web Worker examples, which are based on the Service Worker Cookbook. This process involves initializing Git submodules, installing Node.js dependencies, compiling PureScript code, and starting a local server to view the examples. ```Shell git submodule init git submodule update ``` ```Shell cd examples/serviceworker-cookbook npm i ``` ```Shell cd examples/cache-and-update npm i ``` ```Shell cd examples/cache-and-update npm run build ``` ```Shell cd examples/serviceworker-cookbook gulp start-server ``` ```Shell firefox http://localhost:3003/strategy-cache-and-update_demo.html ``` -------------------------------- ### Build purescript-mathbox Project and Examples Source: https://pursuit.purescript.org/packages/purescript-mathbox Instructions to install project dependencies, build the purescript-mathbox library and its examples, and then open the generated HTML examples in a browser. ```Shell # install project dependencies npm run install # build project and examples npm run build-all open examples/resources/*.html # in your favorite browser ``` -------------------------------- ### Set Up purescript-lit-html Development Environment Source: https://pursuit.purescript.org/packages/purescript-lit-html Provides the necessary steps to set up the local development environment for purescript-lit-html. This includes navigating to the example directory, installing dependencies, building the project, and starting the application. ```Shell cd example yarn pulp -w build -I ../src yarn start ``` -------------------------------- ### Initialize a PureScript Project with Pulp and Bower Source: https://pursuit.purescript.org/packages/purescript-bonsai This snippet demonstrates the initial steps to set up a new PureScript project. It creates a directory, initializes a Pulp project, installs the `purescript-bonsai` package using Bower, and builds the project. ```bash mkdir your-project cd your-project pulp init bower install --save purescript-bonsai pulp build ``` -------------------------------- ### PureScript Gun DB Quickstart: Server and Client Setup Source: https://pursuit.purescript.org/packages/purescript-bf-gun This quickstart provides a complete example of setting up a Gun DB application with a PureScript server and client. The server initializes Gun, exposes an HTTP endpoint, and publishes messages, while the client connects to the server and subscribes to real-time data updates, demonstrating shared state. ```PureScript module Examples.Basic.Server where import Prelude hiding (apply) import Data.Maybe (Maybe(..)) import Data.Options (Options, (:=)) import Effect (Effect) import Effect.Console (log) import Effect.Timer (setInterval) import Gun as Gun import Gun.Configuration (Configuration, fileOption, webOption) import Gun.Node (Saveable(..)) import Node.Express.App (App, listenHttp, get) import Node.Express.Response (send) import Node.HTTP (Server) app :: App app = get "/" do send "body" main :: Effect Server main = do server <- listenHttp app 8080 \_ -> log $ "Server Listening on " <> show 8080 let gunConfig :: Options Configuration gunConfig = webOption := Just server <> fileOption := Just "radata" let gun = Gun.create gunConfig let alice = Gun.get "alice" gun let alicenodeWithData = alice # Gun.put (SaveableRecord {name : "Alice"}) let people = Gun.get "people" gun let _ = people # Gun.set (SaveableNode alicenodeWithData) let messages = Gun.get "messages" gun _ <- setInterval 900 do log "sending message from server" let _ = messages # Gun.put (SaveableRecord { message: "Message from server" }) pure unit pure server ``` ```PureScript module Examples.Basic.Client where import Prelude import Data.Maybe (Maybe(..)) import Data.Options (Options, (:=)) import Debug (trace) import Effect (Effect) import Effect.Class.Console (log) import Gun as Gun import Gun.Configuration (Configuration, peersOption) import Gun.Query.Mapper (Mapper(..)) main :: Effect Unit main = do let gunConfig :: Options Configuration gunConfig = peersOption := Just ["http://localhost:8080/gun"] let gun = Gun.create gunConfig let messages = Gun.get "messages" gun let people = Gun.get "people" gun _ <- do log "listening" let _ = messages # Gun.on (\key message -> pure $ trace {message} identity ) let mappedPeople = people # Gun.map Passthrough let _ = mappedPeople # Gun.on (\key person -> pure $ trace {person} identity ) pure unit pure unit ``` -------------------------------- ### Build the purescript-soundfonts example project Source: https://pursuit.purescript.org/packages/purescript-soundfonts These commands are used to set up and run the example project for purescript-soundfonts. First, `bower install` fetches front-end dependencies, and then `npm run example` executes the predefined script to build and run the example. ```Shell bower install ``` ```Shell npm run example ``` -------------------------------- ### Build and Serve Example for purescript-react-keybind Source: https://pursuit.purescript.org/packages/purescript-react-keybind Commands to install dependencies and run the example project for the purescript-react-keybind library. This helps in verifying the library's functionality locally. ```Shell npm i npm run serve-example ``` -------------------------------- ### Example Express Server Setup with purescript-makkori Source: https://pursuit.purescript.org/packages/purescript-makkori This PureScript example demonstrates how to set up a basic Express-like web server using the purescript-makkori library. It shows how to create an application, listen on a specified port, apply JSON middleware, and define routes for handling both GET and POST requests, including reading the request body for POST operations. ```PureScript main = do app <- M.makeApp server <- M.listen (M.Port 9999) mempty app json <- M.makeJSONMiddleware {} M.use (M.Path "/") json app M.get (M.Path "/get-test") (M.makeHandler (\_ res -> M.sendResponse "GET OK" res)) app M.post (M.Path "/post-test") (M.makeHandler (\req res -> do body <- (readString <=< readProp "a") <$> M.getBody req M.sendResponse "POST OK" res)) app M.close mempty server ``` -------------------------------- ### Run PureScript Halogen Datepicker Examples Source: https://pursuit.purescript.org/packages/purescript-halogen-datepicker Instructions to build the PureScript project and serve the compiled examples using `http-server`. Ensure `http-server` is installed globally via npm. ```shell npm run build http-server example ``` -------------------------------- ### Purescript Project Development Setup Source: https://pursuit.purescript.org/packages/purescript-selection-foldable Provides a step-by-step guide to set up the development environment for a Purescript project. It covers installing necessary global tools like purescript, bower, and pulp, followed by project-specific dependency installation and running tests. ```Shell npm install -g purescript npm install -g bower npm install -g pulp npm install && bower install pulp test ``` -------------------------------- ### Start PureScript Development Server with Pulp Source: https://pursuit.purescript.org/packages/purescript-bonsai This command starts the Pulp development server, which typically watches for file changes, rebuilds the project, and serves the application, allowing for live development. ```bash pulp server ``` -------------------------------- ### Run PureScript Screenfull Example Project Source: https://pursuit.purescript.org/packages/purescript-screenfull Steps to set up and run the example project for purescript-screenfull, demonstrating module API usage. This requires `purs` to be installed and uses `python2` for a simple HTTP server. ```shell $ cd example $ make $ python2 -m SimpleHTTPServer 8000 ``` -------------------------------- ### Development Setup for purescript-format-nix Source: https://pursuit.purescript.org/packages/purescript-format-nix Instructions for setting up the development environment for purescript-format-nix, including npm prefix configuration, package installation, and binary creation using npm and Spago. ```Shell # never use 'sudo' with npm. > npm set prefix ~/.npm > npm install # install purescript and spago in some way # e.g. github.com/justinwoo/easy-purescript-nix # or if you're feeling lucky, npm i -g purescript spago > spago install > npm run mkbin > npm link # update requires mkbin run again > npm run mkbin ``` -------------------------------- ### Run Halogen Example Project Source: https://pursuit.purescript.org/packages/purescript-js-fileio This command executes the Halogen example application associated with the project. It typically runs a script defined in the `package.json` file to start the example. ```Shell npm run halogen-example ``` -------------------------------- ### Install Droplet and Dependencies Source: https://pursuit.purescript.org/packages/purescript-droplet This snippet shows how to install the necessary Node.js packages and PureScript dependencies for the Droplet project. It uses `npm` for JavaScript packages and `spago` for PureScript packages. ```Shell npm i big-integer pg @easafe/pebble spago install droplet ``` -------------------------------- ### npm Commands for Running PureScript Simple Ajax Example Source: https://pursuit.purescript.org/packages/purescript-simple-ajax Provides the necessary `npm` commands to set up the environment for running the `purescript-simple-ajax` example in a console. It includes initializing a project, installing `xhr2` for XHR support, and running the PureScript application with `spago`. ```npm npm init npm install xhr2 spago run ``` -------------------------------- ### Run Purescript Handsontable Example Source: https://pursuit.purescript.org/packages/purescript-handsontable This sequence of commands installs project dependencies using npm and bower, bundles the application with gulp, and then opens the example HTML file in Google Chrome to demonstrate the purescript-handsontable library. ```Shell npm install bower install gulp browserify google-chrome-stable example/index.html ``` -------------------------------- ### Quick Start with Pux Starter App Source: https://pursuit.purescript.org/packages/purescript-pux Instructions to quickly set up and run a new PureScript Pux application using the provided starter app repository. This involves cloning the repository, navigating into the directory, installing dependencies, and starting the development server. ```Shell git clone git://github.com/alexmingoia/pux-starter-app.git my-awesome-pux-app cd my-awesome-pux-app npm install npm start ``` -------------------------------- ### Build purescript-quill example project Source: https://pursuit.purescript.org/packages/purescript-quill These commands prepare and build the example project for `purescript-quill`. First, `bower install` fetches front-end dependencies, and then `npm run example` executes the build script defined in `package.json` to compile the PureScript example. ```Shell $ bower install $ npm run example ``` -------------------------------- ### Run a specific purescript-canvas-action example Source: https://pursuit.purescript.org/packages/purescript-canvas-action Executes a named example or test from the 'purescript-canvas-action' package. This command typically starts a local server and opens a browser window for viewing the example. ```Shell npm run example: ``` -------------------------------- ### Run purescript-flatpickr Example Source: https://pursuit.purescript.org/packages/purescript-flatpickr This snippet provides shell commands to set up and run the purescript-flatpickr example. It involves installing Bower dependencies, bundling the PureScript source with Pulp, and opening the resulting HTML file in Google Chrome. ```Shell $ bower i $ pulp browserify --include example/src --to example/dist/bundle.js $ google-chrome example/dist/index.html ``` -------------------------------- ### Regenerate and Test purescript-graphqlclient Examples Source: https://pursuit.purescript.org/packages/purescript-graphqlclient Commands to regenerate, install dependencies for, and test examples for the purescript-graphqlclient project, including pushing changes to Git. ```Shell spago install spago --config generator-spago.dhall install ./regenerate-examples.sh yarn run examples:test --watch git push ``` -------------------------------- ### Quick Start: Asynchronous HTTP Request in PureScript Source: https://pursuit.purescript.org/packages/purescript-aff This PureScript quick start example demonstrates how to perform an asynchronous HTTP GET request using `purescript-aff`. It launches an `Aff` computation, fetches data from a specified URL, and then logs the body of the response to the console. ```PureScript main :: Effect Unit main = launchAff_ do response <- Ajax.get "http://foo.bar" log response.body ``` -------------------------------- ### Build purescript-sockjs-client example application Source: https://pursuit.purescript.org/packages/purescript-sockjs-client Commands to install project dependencies and compile the example application for purescript-sockjs-client using bower, yarn, and pulp. ```Shell bower install yarn add sockjs-client pulp browserify --include example -O --to example/bundle.js ``` -------------------------------- ### Installing purescript-rationals Package Source: https://pursuit.purescript.org/packages/purescript-rationals Instructions for installing the `purescript-rationals` package using Spago, the PureScript package manager, and also with Bower for older setups. ```Shell spago install rationals # Or with Bower bower install purescript-rationals ``` -------------------------------- ### Set up and Run Local Development for purescript-lumi-components Source: https://pursuit.purescript.org/packages/purescript-lumi-components These commands initialize the local development environment by installing npm and Bower dependencies, building the project, and then starting the development server. Production builds can be generated using `npm run build`. ```Shell npm i; npx bower i; npx pulp build npm start ``` -------------------------------- ### Development Setup for purescript-int-53 Source: https://pursuit.purescript.org/packages/purescript-int-53 Steps to set up the development environment for the `purescript-int-53` project, including cloning the repository, installing Node.js and Bower dependencies, and running tests. ```Shell git clone https://github.com/rgrempel/purescript-int-53 npm install bower install npm test ``` -------------------------------- ### Setup Project Dependencies with npm Source: https://pursuit.purescript.org/packages/purescript-workly This command installs all project dependencies as defined in `package-lock.json` using npm, ensuring consistent installations across environments. ```Shell npm ci ``` -------------------------------- ### Execute a Specific HTTPurple Example Source: https://pursuit.purescript.org/packages/purescript-httpurple Use this Spago command to run one of the provided examples within the HTTPurple project. Replace `` with the actual module name of the example you wish to execute, for instance, `Examples.Basic.Main`. ```Shell spago -x test.dhall run --main Examples..Main ``` -------------------------------- ### Basic Route Matching Example in PureScript Source: https://pursuit.purescript.org/packages/purescript-generic-router This PureScript example demonstrates how to set up a basic router using `purescript-generic-router`. It defines a single GET route for '/apples', creates a router with a fallback, and asserts that a request to '/apples' correctly matches and returns 'Hello!'. It showcases the core components: `makeRoute`, `makeRouter`, and `route`. ```PureScript module Main ( main ) where import Prelude import Router (makeRoute, makeRouter, route) import Data.Map as Map import Data.Tuple (Tuple(..)) import Effect (Effect) import Router.Method as Method import Test.Assert (assert) testRouteMatch :: Effect Unit testRouteMatch = do let route1 = makeRoute { path: "/apples", methods: [ Method.GET ] } routes = (Map.fromFoldable [ Tuple route1 (\_req _ctx -> "Hello!") ]) fallbackResponse = "Not Found" requestToPath = (\_req -> "/apples") requestToMethod = (\_req -> Method.GET) requestToContext = (\_req -> {}) router = makeRouter { routes , fallbackResponse , requestToPath , requestToMethod , requestToContext } resp = route router "" assert $ resp == "Hello!" ``` -------------------------------- ### Run Specific PureScript Examples with Spago Source: https://pursuit.purescript.org/packages/purescript-hyper These commands demonstrate how to run individual examples within the purescript-hyper project. The general format specifies the example file and module, with a concrete example provided for 'HelloHyper'. ```Shell # general format: spago run -p examples/.purs -m Examples. # for instance to run HelloHyper: spago run -p examples/HelloHyper.purs -m Examples.HelloHyper ``` -------------------------------- ### Run PureScript Drawing Example Source: https://pursuit.purescript.org/packages/purescript-drawing Instructions to run the example project for the purescript-drawing library. This command executes the example application using npm. ```shell npm run example ``` -------------------------------- ### Set up purescript-kubernetes development environment Source: https://pursuit.purescript.org/packages/purescript-kubernetes These commands outline the steps to prepare the development environment for purescript-kubernetes. It involves using Nix for environment setup, npm for installing Node.js dependencies, updating Bower dependencies, generating PureScript type definitions from Kubernetes Swagger, and running unit tests. ```Bash nix-shell npm install npm run bower -- update --force-latest # Generate type definitions npm run build:generation npm run generate npm run test:unit ``` -------------------------------- ### Install purescript-graphql-client via Spago or Bower Source: https://pursuit.purescript.org/packages/purescript-graphql-client Instructions for installing the `purescript-graphql-client` library. The recommended method is using Spago, but Bower installation is also provided. ```Shell spago install graphql-client ``` ```Shell bower install purescript-graphql-client ``` -------------------------------- ### Full PureScript Axon REST API Example for Cheese Management Source: https://pursuit.purescript.org/packages/purescript-axon/0.0 A complete PureScript example demonstrating a simple REST API for managing a list of cheeses. It implements `GET /cheeses` to list, `POST /cheeses` to add, and `DELETE /cheeses/:cheese` to remove, showcasing handler definition, state management with `Effect.Ref`, and server setup with `Axon.serveBun`. ```PureScript module Main where import Prelude import Axon as Axon import Axon.Request.Handler as Handler import Axon.Request.Parts.Class (Delete, Get, Path(..), Post) import Axon.Request.Parts.Path (type (/)) import Axon.Response (Response) import Axon.Response.Construct (Json(..), toResponse) import Axon.Response.Status as Status import Data.Filterable (filter) import Data.Foldable (elem) import Data.Tuple.Nested ((/\)) import Effect (Effect) import Effect.Aff (Aff, launchAff_, joinFiber) import Effect.Aff as Aff import Effect.Class (liftEffect) import Effect.Ref (Ref) import Effect.Ref as Ref main :: Effect Unit main = launchAff_ do cheeses :: Ref (Array String) <- liftEffect $ Ref.new [ "cheddar", "swiss", "gouda" ] let getCheeses :: Get -> Path "cheeses" _ -> Aff Response getCheeses _ _ = liftEffect do cheeses' <- Ref.read cheeses toResponse $ Status.ok /\ Json cheeses' deleteCheese :: Delete -> Path ("cheeses" / String) _ -> Aff Response deleteCheese _ (Path id) = liftEffect do cheeses' <- Ref.read cheeses if not $ elem id cheeses' then toResponse Status.notFound else Ref.modify_ (filter (_ /= id)) cheeses *> toResponse Status.accepted postCheese :: Post -> Path "cheeses" _ -> String -> Aff Response postCheese _ _ cheese = let tryInsert as | elem cheese as = { state: as, value: false } | otherwise = { state: as <> [ cheese ], value: true } in liftEffect $ Ref.modify' tryInsert cheeses >>= if _ then toResponse Status.accepted else toResponse Status.conflict handle <- Axon.serveBun { port: 8080, hostname: "localhost" } (getCheeses `Handler.or` postCheese `Handler.or` deleteCheese) joinFiber handle.join ``` -------------------------------- ### Compile and Run PureScript Halogen Hooks Extra Examples Source: https://pursuit.purescript.org/packages/purescript-halogen-hooks-extra This snippet provides commands to compile the example application using `spago` and then open the generated `index.html` file in a web browser. It demonstrates how to set up and run the examples for the `purescript-halogen-hooks-extra` package. ```Shell # Compile the examples spago -x examples.dhall bundle-app --main Examples.Main --to dist/app.js # Then open the `dist/index.html` file in your favorite browser # firefox dist/index.html # google-chrome dist/index.html ``` -------------------------------- ### Establish Database Connection Pool Source: https://pursuit.purescript.org/packages/purescript-droplet This PureScript snippet demonstrates how to configure and establish a connection pool to a PostgreSQL database using the `pg` driver. It shows how to define connection parameters and handle potential connection errors, preparing the application for database interactions. ```PureScript connectionInfo :: Configuration connectionInfo = (Driver.defaultConfiguration "database") { user = Just "user" } example :: Aff Unit example = do pool <- liftEffect $ Pool.newPool connectionInfo -- connection pool from PostgreSQL Driver.withConnection pool case _ of Left error -> pure unit -- or some more sensible handling Right connection -> runSql connection ``` -------------------------------- ### Embed Ace Editor via CDN in HTML Source: https://pursuit.purescript.org/packages/purescript-ace This HTML snippet illustrates how to include the Ace code editor in your web project by linking to a Content Delivery Network (CDN). It's a quick way to get started without local installation. ```HTML Ace Demo ``` -------------------------------- ### Bundle Example Output Files Source: https://pursuit.purescript.org/packages/purescript-emo8 Command to bundle the purescript-emo8 example projects, preparing them for distribution or local viewing in a web browser. ```Shell yarn bundle:example ``` -------------------------------- ### QuickStart: Get PhantomJS Version and Exit in PureScript Source: https://pursuit.purescript.org/packages/purescript-phantom This snippet demonstrates a basic PureScript program using `purescript-phantom` to interact with PhantomJS. It retrieves and logs the PhantomJS version, then exits the process with a success code. This is useful for verifying the library setup and basic functionality. ```PureScript import Prelude ((>>=), bind) import Data.Enum (fromEnum) import ExitCodes (ExitCode(Success)) import PhantomJS.Phantom (version, exit) import Control.Monad.Eff.Console (logShow) main = do version >>= logShow exit (fromEnum Success) ``` -------------------------------- ### PureScript Droplet Modules Source: https://pursuit.purescript.org/packages/purescript-droplet Lists the core modules provided by the purescript-droplet library, detailing their hierarchical structure and purpose within the project. These modules cover driver functionalities, internal migrations, query handling, and language constructs. ```APIDOC Modules: Droplet.Driver Droplet.Driver.Internal.Migration Droplet.Driver.Internal.Pool Droplet.Driver.Internal.Query Droplet.Driver.Migration Droplet.Driver.Unsafe Droplet.Language Droplet.Language.Internal.Condition Droplet.Language.Internal.Definition Droplet.Language.Internal.Function Droplet.Language.Internal.Syntax Droplet.Language.Internal.Token Droplet.Language.Internal.Translate ``` -------------------------------- ### Setting Up PureScript Quantities Development Environment Source: https://pursuit.purescript.org/packages/purescript-quantities This snippet provides instructions for setting up the development environment for the `purescript-quantities` library. It includes commands to install project dependencies using npm and run tests using Spago, the PureScript package manager. ```Shell npm install spago -x test.dhall test ``` -------------------------------- ### Purescript Optparse Full Help Text Output Source: https://pursuit.purescript.org/packages/purescript-optparse Provides an example of the comprehensive help text generated by `purescript-optparse` when the `--help` option is invoked. This output includes the program header, usage instructions, and a detailed list of all available options with their descriptions and default values. ```CLI hello - a test for purescript-optparse Usage: hello --hello TARGET [-q|--quiet] [--enthusiasm INT] Print a greeting for TARGET Available options: --hello TARGET Target for the greeting -q,--quiet Whether to be quiet --enthusiasm INT How enthusiastically to greet (default: 1) -h,--help Show this help text ``` -------------------------------- ### PureScript Homogeneous Record Applicative Example Setup Source: https://pursuit.purescript.org/packages/purescript-homogeneous Initial setup for an example demonstrating `Applicative` usage with homogeneous records. It defines a sample record `r` with numeric values and a `multiply` function wrapped in `pure` to be applied across the record's elements. ```PureScript recordInstances :: Effect Unit recordInstances = do let r = { one: 1, two: 2, three: 3 } multiply = pure (_ * 2) ``` -------------------------------- ### Create a basic HTTPure server Source: https://pursuit.purescript.org/packages/purescript-httpure A minimal PureScript example demonstrating how to set up and serve a basic 'hello world' HTTP server using the `HTTPure` library on port 8080. This snippet shows the core structure for defining a server and a simple router. ```PureScript module Main where import Prelude import Effect.Console (log) import HTTPure (ServerM, serve, ok) main :: ServerM main = serve 8080 router $ log "Server now up on port 8080" where router _ = ok "hello world!" ``` -------------------------------- ### Run PureScript Nodetrout Examples with Bower and Pulp Source: https://pursuit.purescript.org/packages/purescript-nodetrout Instructions to set up and execute PureScript Nodetrout examples using the bower package manager and pulp build tool. Replace `` with the specific example you wish to run. ```Shell bower install pulp run -I example -m Example. ``` -------------------------------- ### Print HTTP Methods in PureScript Source: https://pursuit.purescript.org/packages/purescript-http-methods This PureScript example demonstrates how to convert an HTTP method type to its string representation using the `print` function from the `Data.HTTP.Method` module. It shows how to get the string 'GET' from the `GET` method type. ```PureScript module PrintingExample where import Data.HTTP.Method (Method(..), print) import Data.Either (Either(..)) -- To print an HTTP method, use the `print` function: -- same as "GET" getMethod :: String getMethod = print (Left GET) ``` -------------------------------- ### Quick Start for purescript-gl-matrix Development Source: https://pursuit.purescript.org/packages/purescript-gl-matrix Instructions to set up the project dependencies using npm and run tests with spago. This ensures the development environment is ready for contributing or using the library. ```Shell npm install spago -x test.dhall test ``` -------------------------------- ### Install Propel ML for Node.js Source: https://pursuit.purescript.org/packages/purescript-propel To use `purescript-propel` with Node.js, the corresponding Propel ML library must be installed via npm. This example shows installation for Linux with GPU support; other platforms require different Propel packages. ```Shell npm install propel_linux_gpu ``` -------------------------------- ### Run the PureScript HTTPurple Server Source: https://pursuit.purescript.org/packages/purescript-httpurple Execute this command in your project root to compile and start the HTTPurple server defined in your `Main` module. The output confirms successful build and server startup, typically on `http://0.0.0.0:8080`. ```Shell ➜ spago run Src Lib All Warnings 0 0 0 Errors 0 0 0 [info] Build succeeded. HTTPurple 🪁 up and running on http://0.0.0.0:8080 ``` -------------------------------- ### Example Usage of purescript-simple-moment Source: https://pursuit.purescript.org/packages/purescript-simple-moment This example demonstrates how to get the current time, format it using `M.calendar` for a human-readable date/time string, and then format it relatively using `M.fromNow` to show time elapsed. ```PureScript tNow <- now nowCal <- M.calendar $ M.fromDate tNow print nowCal -- "Today at 9:47 PM" nowStr <- M.fromNow $ M.fromDate tNow print nowStr -- "a few seconds ago" ``` -------------------------------- ### Run HTTPure examples Source: https://pursuit.purescript.org/packages/purescript-httpure Commands to execute specific examples provided with the HTTPure library. Examples can be run either using `nix-shell` for an isolated environment or directly with `spago`. ```Bash nix-shell --run 'example ' ``` ```Bash spago -x test.dhall run --main Examples..Main ``` -------------------------------- ### Build and Run Purescript Examples with Spago and Yarn Source: https://pursuit.purescript.org/packages/purescript-marionette-react-basic-hooks Commands to build the Purescript project using Spago, install JavaScript dependencies with Yarn, and then run a specific example HTML file using Parcel. ```Spago spago build yarn install ``` ```Yarn yarn parcel assets/CountDown.html ``` -------------------------------- ### Load PureScript Example in Spago REPL Source: https://pursuit.purescript.org/packages/purescript-nullable This command shows how to launch the PureScript REPL with the example module loaded, allowing for interactive testing and exploration of the `purescript-nullable` library's functionality. ```Shell spago -x examples.dhall repl ``` -------------------------------- ### Watch purescript-canvas-action examples for development Source: https://pursuit.purescript.org/packages/purescript-canvas-action Starts a watcher process that automatically rebuilds PureScript examples whenever source files change. This is useful for continuous development without manual rebuilds. ```Shell npm run watch:examples ``` -------------------------------- ### Install bucketchain-sslify with Spago Source: https://pursuit.purescript.org/packages/purescript-bucketchain-sslify This command installs the bucketchain-sslify package using Spago, the recommended build tool and package manager for PureScript. Spago simplifies dependency management and project setup. ```Shell $ spago install bucketchain-sslify ``` -------------------------------- ### Launch PureScript Payload Server with Defined Guards Source: https://pursuit.purescript.org/packages/purescript-payload This PureScript example demonstrates how to start a Payload server (Payload.launch) while integrating custom request guard functions. It shows how to define the main handler (adminIndex) which receives the output of the guard, and how to pass a record of all defined guard functions (guards) along with the handlers to the launch function. This setup ensures that guards are executed before their respective handlers. ```PureScript adminIndex :: { guards :: { adminUser :: AdminUser } } -> Aff String adminIndex { guards: { adminUser } } = pure "Response" main = do let guards = { adminUser: getAdminUser, user: getUser } let handlers = { adminIndex, userIndex, unauthenticatedIndex } Payload.launch spec { handlers, guards } ``` -------------------------------- ### Building and Serving PureScript React Examples Source: https://pursuit.purescript.org/packages/purescript-react-spaces These commands provide instructions for compiling and serving the example application included with the purescript-react-spaces library. They utilize npm scripts to automate the build and local server processes, allowing users to quickly run and test the provided examples. ```npm npm run example:build npm run example:serve ``` -------------------------------- ### Run purescript-trout-client example Source: https://pursuit.purescript.org/packages/purescript-trout-client Command to execute the example project for purescript-trout-client, demonstrating its integration with client and server based on Trout routing types. ```Shell make run-example ``` -------------------------------- ### Setting up PureScript Protobuf Development and Generating Code Source: https://pursuit.purescript.org/packages/purescript-protobuf This section outlines how to set up the PureScript Protobuf development environment using Nix, build the `protoc` compiler plugin, and generate PureScript code from `.proto` files. It includes commands to verify the environment and compile well-known Google Protocol Buffer types. ```Shell $ nix develop spago -x spago-plugin.dhall build protoc --purescript_out=. google/protobuf/timestamp.proto protoc --purescript_out=. google/protobuf/any.proto ls $(nix path-info .#protobuf)/src/google/protobuf/*.proto ``` -------------------------------- ### Run PureScript game examples with npm Source: https://pursuit.purescript.org/packages/purescript-game Explains how to run specific examples or tests by replacing `` with the desired example's name. This command sets up a server that auto-rebuilds on source changes and opens a browser window. ```npm npm run example- ``` -------------------------------- ### Install Enzyme and JSDOM Development Dependencies Source: https://pursuit.purescript.org/packages/purescript-elmish-enzyme Instructions for installing the necessary JavaScript development dependencies: `enzyme` for React component testing, `jsdom` for emulating a browser environment, and `global-jsdom` for simplified JSDOM setup. ```npm npm install enzyme jsdom global-jsdom --save-dev ``` -------------------------------- ### Install Chalk JavaScript Library Source: https://pursuit.purescript.org/packages/purescript-lazy-joe This command installs the 'chalk' JavaScript library using npm, a Node.js package manager. 'chalk' is a popular library used for terminal styling and is used in subsequent examples to demonstrate FFI. ```Shell npm install chalk ``` -------------------------------- ### Build Simple Examples for purescript-audiograph Source: https://pursuit.purescript.org/packages/purescript-audiograph Instructions to build the `simple-examples` project, which showcases various uses of `purescript-audiograph`. It uses Bower for PureScript dependencies and npm for JavaScript build processes. ```Shell cd to simple-examples: $ bower install $ npm run build ``` -------------------------------- ### Install PureScript Package with Bower Source: https://pursuit.purescript.org/packages/purescript-console-lifted Command to install a PureScript package using Bower, a package manager for the web. Note: The package name in the example snippet 'purescript-const' may be a placeholder or typo for 'purescript-console-lifted'. ```Shell bower install purescript-const ``` -------------------------------- ### Quickstart: Import and Use a JavaScript Module in PureScript Source: https://pursuit.purescript.org/packages/purescript-lazy-joe This quickstart example demonstrates how to import a default export from a JavaScript module (e.g., 'chalk') into PureScript using 'fromDefault' and then use its functions to log colored text to the console. ```PureScript main :: Effect Unit main = launchAff_ do { red } <- fromDefault "chalk" -- import a module log $ red "Red velvet 🎂" -- use a function ``` -------------------------------- ### Build Instructions for purescript-web3 Source: https://pursuit.purescript.org/packages/purescript-web3 This snippet outlines the steps required to set up, build, and test the `purescript-web3` library. It involves installing Node.js dependencies and running build and test scripts. ```Shell npm install bower install npm run build npm run test ``` -------------------------------- ### Building and Running Example for purescript-behaviors Source: https://pursuit.purescript.org/packages/purescript-behaviors This snippet provides the command-line instructions required to build the purescript-behaviors project using `pulp` and then execute its example using `npm`. ```Shell pulp build npm run example ``` -------------------------------- ### Install freedom-now with Spago Source: https://pursuit.purescript.org/packages/purescript-freedom-now This command installs the freedom-now package using Spago, the recommended build tool and package manager for PureScript. Spago simplifies dependency management and project setup for PureScript applications. ```Shell $ spago install freedom-now ``` -------------------------------- ### Reference: Advanced Bash Scripting Guide Exit Codes Source: https://pursuit.purescript.org/packages/purescript-exitcodes This table provides a comprehensive list of standard exit codes as defined in the Advanced Bash Scripting Guide. It includes the code number, its meaning, an example of its occurrence, and additional comments, serving as a guide for understanding process termination statuses in Bash. ```APIDOC | Exit Code Number | Meaning | Example | Comments | | --- | --- | --- | --- | | 1 | Catchall for general errors | let "var1 = 1/0" | Miscellaneous errors, such as "divide by zero" and other impermissible operations | | 2 | Misuse of shell builtins (according to Bash documentation) | empty_function() {} | Missing keyword or command, or permission problem (and diff return code on a failed binary file comparison). | | 126 | Command invoked cannot execute | /dev/null | Permission problem or command is not an executable | | 127 | "command not found" | illegal_command | Possible problem with $PATH or a typo | | 128 | Invalid argument to exit | exit 3.14159 | exit takes only integer args in the range 0 - 255 (see first footnote) | | 128+n | Fatal error signal "n" | kill -9 $PPID of script | $? returns 137 (128 + 9) | | 130 | Script terminated by Control-C | Ctl-C | Control-C is fatal error signal 2, (130 = 128 + 2, see above) | | 255* | Exit status out of range | exit -1 | exit takes only integer args in the range 0 - 255 | ``` -------------------------------- ### Run and Open purescript-halogen-echarts Example Source: https://pursuit.purescript.org/packages/purescript-halogen-echarts These commands execute the example project for `purescript-halogen-echarts`. The first command runs the example script defined in `package.json`, and the second opens the generated HTML output in a web browser. ```Shell npm run example open example/dist/index.html ``` -------------------------------- ### Start Development Server Source: https://pursuit.purescript.org/packages/purescript-emo8 Command to start the development server for purescript-emo8, facilitating live development and testing. ```Shell yarn dev ``` -------------------------------- ### Trim Substring from Start of String in PureScript Source: https://pursuit.purescript.org/packages/purescript-repr This PureScript example shows how to use the `trimStart` function to remove a specified substring from the beginning of another string. If the substring is not found at the start, the original string is returned unchanged. ```PureScript > trimStart "a" "abc" "bc" > trimStart "d" "abc" "abc" ``` -------------------------------- ### Install Specific React Adapter for Enzyme Source: https://pursuit.purescript.org/packages/purescript-elmish-enzyme Guides on installing the correct Enzyme React adapter package (e.g., `enzyme-adapter-react-16`) based on the version of React used in your project. This adapter is essential for Enzyme to interact with your React components. ```npm npm install enzyme-adapter-react-16 --save-dev ``` -------------------------------- ### Install simple-jwt using Spago Source: https://pursuit.purescript.org/packages/purescript-simple-jwt This command installs the simple-jwt package using Spago, the recommended build tool and package manager for PureScript projects. Spago simplifies dependency management and project setup for PureScript. ```Shell $ spago install simple-jwt ``` -------------------------------- ### Build All PureScript Hyper Examples with Make Source: https://pursuit.purescript.org/packages/purescript-hyper This command uses the 'make' utility to build all available examples within the purescript-hyper project. It's useful for compiling all demonstration code at once. ```Shell make examples ``` -------------------------------- ### Install bucketchain-cors with Spago Source: https://pursuit.purescript.org/packages/purescript-bucketchain-cors This snippet provides the command to install the `bucketchain-cors` package using Spago, the recommended build tool and package manager for PureScript projects. Spago simplifies dependency management and project setup. ```bash $ spago install bucketchain-cors ``` -------------------------------- ### Install React Basic with spago for Hooks and DOM Source: https://pursuit.purescript.org/packages/purescript-react-basic This snippet outlines the steps to set up `purescript-react-basic` using `spago`. It includes installing core React JavaScript libraries via `npm` and then adding the PureScript `react-basic`, `react-basic-dom`, and `react-basic-hooks` packages using `spago`. ```Shell npm i -S react react-dom spago install react-basic react-basic-dom react-basic-hooks ``` -------------------------------- ### Install bucketchain-logger using Spago Source: https://pursuit.purescript.org/packages/purescript-bucketchain-logger This snippet provides the command to install the `bucketchain-logger` package using Spago. Spago is the recommended build tool and package manager for PureScript projects, simplifying dependency management and project setup. ```Spago $ spago install bucketchain-logger ``` -------------------------------- ### Development Workflow for purescript-template-literals Source: https://pursuit.purescript.org/packages/purescript-template-literals Outlines the commands required to set up and run the development environment for the `purescript-template-literals` project. This includes installing dependencies, building the project, and running tests. ```Shell yarn spago build -w yarn jest --watch ``` -------------------------------- ### Create a Basic HTTP Server Endpoint with PureScript QuickServe Source: https://pursuit.purescript.org/packages/purescript-quickserve This snippet demonstrates how to set up a simple HTTP server endpoint that returns a plain text 'Hello, World!' response using `purescript-quickserve`. It initializes the server on `localhost:3000`. ```PureScript server :: GET String server = pure "Hello, World!" main = do let opts = { hostname: "localhost", port: 3000, backlog: Nothing } quickServe opts server ``` -------------------------------- ### Install purescript-safe-coerce Package Source: https://pursuit.purescript.org/packages/purescript-safe-coerce This command installs the `purescript-safe-coerce` package, which provides safe zero-cost coercions, into your PureScript project using the Spago build tool. Spago is a common build tool for PureScript projects, managing dependencies and project setup. ```Shell spago install safe-coerce ``` -------------------------------- ### Run Compiled purescript-phantom Examples with PhantomJS Source: https://pursuit.purescript.org/packages/purescript-phantom After building the PureScript examples, these commands demonstrate how to execute the compiled JavaScript files using the `phantomjs` runtime. It first changes the directory to `examples-output` and then runs `example.js` and `stream.js` via the locally installed `phantomjs-prebuilt` executable. ```Shell cd examples-output ../node_modules/.bin/phantomjs example.js ../node_modules/.bin/phantomjs stream.js ``` -------------------------------- ### Install purescript-web-router with Spago Source: https://pursuit.purescript.org/packages/purescript-web-router Instructions for installing the `purescript-web-router` package using the Spago build tool. ```Shell $ spago install web-router ``` -------------------------------- ### Quick Start Example: Using Data.String.Extra functions in PureScript Source: https://pursuit.purescript.org/packages/purescript-strings-extra This PureScript example illustrates how to import and utilize functions like `words` and `kebabCase` from the `Data.String.Extra` module. It defines a `kebabCaseAll` function that first splits a string into words and then converts the resulting array of words into a single kebab-cased string. ```PureScript module MyModule where import Data.String.Extra (words, kebabCase) kebabCaseAll :: String -> Array String kebabCaseAll = kebabCase <<< words ``` -------------------------------- ### Set up purescript-decimals Development Environment Source: https://pursuit.purescript.org/packages/purescript-decimals Commands to install development dependencies for the purescript-decimals project using Bower and npm, followed by instructions to use `pulp` for building and running tests. ```Shell bower install npm install ``` -------------------------------- ### Development Setup for purescript-d3 Source: https://pursuit.purescript.org/packages/purescript-d3 Commands to set up the development environment for `purescript-d3`, including installing project dependencies and compiling the source code using Yarn. ```Shell yarn # install dependencies from package.json and bower.json yarn build # compile the code ``` -------------------------------- ### Check for Tool Installation and Handle Failure in PureScript Action Source: https://pursuit.purescript.org/packages/purescript-github-actions-toolkit This PureScript example uses `IO.which` to verify if a tool (e.g., `spago`) is installed. If the tool is not found, it logs an error with `Core.error` and sets the job to failed using `Core.setFailed`. Otherwise, it logs the tool's path. ```PureScript main :: Effect Unit main = do result <- runExceptT (IO.which { tool: "spago", check: true }) case result of Left err -> Core.error "spago not found" Core.setFailed "Required tool spago is not available for this job." Right spagoPath -> Core.info $ "spago found at path " <> spagoPath pure unit -- If your job ends without failing, then it succeeded. ``` -------------------------------- ### Perform A* Pathfinding on a 2D Grid in PureScript Source: https://pursuit.purescript.org/packages/purescript-astar This example demonstrates how to use `runAStarNonDiagonal` to find a path between a start and goal point on a 2D grid. It initializes a `world` array representing the grid, defines `start` and `goal` coordinates, and specifies `blocked` tiles. The output shows the resulting path as an array of coordinates. ```PureScript let start = {x: 0, y: 0} goal = {x: 4, y: 4} world = [ [ 0, 0, 0, 0, 0 ] , [ 0, 0, 0, 1, 0 ] , [ 0, 0, 0, 1, 0 ] , [ 0, 1, 1, 1, 0 ] , [ 0, 0, 0, 0, 0 ] ] -- tiles with `1` are non-walkable blocked = [ 1 ] in runAStarNonDiagonal blocked start goal world -- the result will be an array of vectors containing the path coordinates -- including the source and destination cells [ { x: 0, y: 0 }, { x: 0, y: 1 }, { x: 0, y: 2 }, { x: 0, y: 3 }, { x: 0, y: 4 } , { x: 1, y: 4 }, { x: 2, y: 4 }, { x: 3, y: 4 }, { x: 4, y: 4 } ] -- which corresponds to the following path ✯ , , , , = , , , # , = , , , # , = , # , # , # , = , = , = , = , ⚑ ``` -------------------------------- ### Set Up and Run purescript-jest Development Environment Source: https://pursuit.purescript.org/packages/purescript-jest This snippet provides the necessary commands to initialize dependencies, compile the PureScript project using Spago, and run tests using Jest in watch mode for the purescript-jest library. ```shell yarn spago build yarn jest --watch ``` -------------------------------- ### Execute purescript-sudoku example Source: https://pursuit.purescript.org/packages/purescript-sudoku Command to run an example provided with the purescript-sudoku repository using Pulp, ensuring example-specific modules are included. ```Shell pulp run --include examples --main Example.Simple ```