• Stars
    star
    198
  • Rank 196,898 (Top 4 %)
  • Language PureScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An unofficial Cookbook for PureScript

PureScript-Cookbook

An unofficial Cookbook for PureScript (Quick link to recipes table)

The recipes folder contains all the recipes in this repo in no particular order.

If you want to contribute a new recipe, see the CONTRIBUTING.md file.

Usage

Install Dependencies

Install GNU Make (version 4.0 or above), and verify installation with:

make --version

Install all dependencies locally:

make installDeps

Install for Nix users:

# Remove purescript and spago and removing trailing , from package.json
sed --in-place '/purescript\|spago/d' ./package.json && sed --in-place '$!N;s/,\n  }/\n  }/;P;D' package.json
nix-shell

Running Recipes

See a list of available recipe launch commands by running make list:

> make list
Use "make RecipeName-target" to run a recipe

=== Node Recipes ===
make ReadPrintFileContents-node
make HelloLog-node
...

=== Web Recipes ===
make WindowProperties-web
make HelloLog-web
...

Then simply copy and paste one of the listed commands. For example:

Running a node-compatible recipe:

> make HelloLog-node
=== Running HelloLog on the Node.js backend ===
[info] Installation complete.
[info] Build succeeded.
Hello world!

Running a web-compatible recipe:

> make HelloLog-web
=== Building HelloLog ===
[info] Installation complete.
[info] Build succeeded.
=== Launching HelloLog in the web browser ===
...

Current Recipe Suffixes

Recipes ending with ... ... mean the following approach/library is used
HalogenClassic Component-style Halogen
HalogenHooks Hooks-style Halogen
ReactClassic Component-style React via react-basic
ReactHooks Hooks-style React via react-basic
Concur Concur
Js Run plain PureScript only on the web (no node.js) without a web framework
Log Log content to both the browser's dev console and the terminal
Node Run PureScript only on Node.js where no user interaction occurs
CLI Run PureScript only on Node.js with user interaction

Recipes

Note: for the try links in the "Web Browser" column, any content logged to the console will appear in the web browser's console, not in the page rendered by Try PureScript.

Node Web Browser Recipe Description
βœ”οΈ (try - fixme) AddRemoveEventListenerJs This recipe shows how to add and remove an event listener to an HTML element.
βœ”οΈ AffjaxPostNode Performs a simple HTTP Post request using the Affjax library.
βœ”οΈ (try) BasicHalogenHooks Displays a button that toggles the label to "On" and "Off".
βœ”οΈ βœ”οΈ (try) BigIntJs This recipe shows how to print, create, and use values of the BigIntJs type in either the node.js or web browser console.
βœ”οΈ (try) BookHalogenHooks A Halogen port of the "HTTP - Book" Elm Example.
βœ”οΈ (try) BookReactHooks A React port of the "HTTP - Book" Elm Example.
βœ”οΈ (try) ButtonsHalogenHooks A Halogen port of the "User Input - Buttons" Elm Example.
βœ”οΈ (try) ButtonsReactHooks A React port of the "User Input - Buttons" Elm Example.
βœ”οΈ CapabilityPatternNode A skeletal version of an application structuring pattern
βœ”οΈ (try) CardsHalogenHooks A Halogen port of the "Random - Cards" Elm Example.
βœ”οΈ (try) CardsReactHooks A React port of the "Random - Cards" Elm Example.
βœ”οΈ (try) CatGifsHalogenHooks A Halogen port of the "HTTP - Cat GIFs" Elm Example.
βœ”οΈ (try) CatGifsReactHooks A React port of the "HTTP - Cat GIFs" Elm Example.
βœ”οΈ (try) ClockReactHooks A React port of the "User Interface - Clock" Elm Example.
βœ”οΈ (try) ComponentsHalogenHooks Demonstrates how to nest one Halogen-Hooks-based component inside another and send/receive queries between the two.
βœ”οΈ (try) ComponentsInputHalogenHooks Each time a parent re-renders, it will pass a new input value into the child, and the child will update accordingly.
βœ”οΈ (try) ComponentsInputReactHooks Each time the parent's state updates, it will pass a new prop value into the child, and the child will update accordingly.
βœ”οΈ (try) ComponentsMultiTypeHalogenHooks Demonstrates a component that can communicate with its children that have differing types.
βœ”οΈ (try) ComponentsMultiTypeReactHooks Demonstrates a parent component with several children components, each with different prop types.
βœ”οΈ (try) ComponentsReactHooks Demonstrates how to nest one React Hooks-based component inside another and send props from the parent to the child component.
βœ”οΈ βœ”οΈ (try) DateTimeBasicsLog This recipe shows how to use purescript-datetime library to create Time, Date, and DateTime values and adjust/diff them.
βœ”οΈ βœ”οΈ (try) DebuggingLog This recipe shows how to do print-debugging using the Debug module's spy and traceM functions. The compiler will emit warnings to remind you to remove these debug functions before you ship production code.
βœ”οΈ DiceCLI This recipe shows how to create an interactive command line prompt that repeatedly generates a random number between 1 and 6.
βœ”οΈ βœ”οΈ (try) DiceLog This recipe shows how to log a random integer between 1 and 6 (representing a roll of a die) in either the node.js or web browser console.
βœ”οΈ (try) DragAndDropHalogenHooks A Halogen port of the "Files - Drag-and-Drop" Elm Example.
βœ”οΈ (try) DragAndDropReactHooks A React port of the "Files - Drag-and-Drop" Elm Example.
βœ”οΈ (try) FileUploadHalogenHooks A Halogen port of the "Files - Upload" Elm Example.
βœ”οΈ (try) FileUploadReactHooks A React port of the "Files - Upload" Elm Example.
βœ”οΈ FindDomElementJs This recipe shows how to find elements in the DOM by using query selectors.
βœ”οΈ (try) FormsReactHooks A React port of the "User Interface - Forms" Elm Example.
βœ”οΈ (try) GroceriesHalogenHooks A Halogen port of the "HTML - Groceries" Elm Example.
βœ”οΈ (try) GroceriesJs A framework-free port of the "HTML - Groceries" Elm Example.
βœ”οΈ (try) GroceriesReactHooks A React port of the "HTML - Groceries" Elm Example.
βœ”οΈ (try) HelloHalogenHooks A Halogen port of the "HTML - Hello" Elm Example.
βœ”οΈ (try) HelloJs A framework-free port of the "HTML - Hello" Elm Example.
βœ”οΈ βœ”οΈ (try) HelloLog This recipe shows how to run a simple "Hello world!" program in either the node.js or web browser console.
βœ”οΈ (try) HelloReactHooks A React port of the "HTML - Hello" Elm Example.
βœ”οΈ βœ”οΈ (try) HeterogeneousLog This recipe demonstrates how to use purescript-heterogeneous to manipulate records generically.
βœ”οΈ βœ”οΈ (try) HeterogenousArrayLog This recipe demonstrates how to create a heterogenous array and process its elements.
βœ”οΈ (try - fixme) ImagePreviewsHalogenHooks A Halogen port of the "Files - Drag-and-Drop" Elm Example with an additional feature to display image thumbnails.
βœ”οΈ (try) ImagePreviewsReactHooks A React port of the "Files - Image-Previews" Elm Example.
βœ”οΈ (try) InterpretHalogenHooks Demonstrates how to use a custom monad (in this case, using ReaderT with Aff as the effect type) for a component, and then interpreting that custom monad back down to Aff, so it can be run as a normal component.
βœ”οΈ (try) LifecycleHalogenHooks Demonstrates component lifecycle.
βœ”οΈ (try) NumbersHalogenHooks A Halogen port of the "Random - Numbers" Elm Example.
βœ”οΈ (try) NumbersReactHooks A React port of the "Random - Numbers" Elm Example.
βœ”οΈ βœ”οΈ (try) ParallelAppMExampleLog Demonstrates how to use parSequence/parTraverse and how to define a Parallel instance for a ReaderT r Aff-based AppM monad.
βœ”οΈ (try) PositionsHalogenHooks A Halogen port of the "Random - Positions" Elm Example.
βœ”οΈ (try) PositionsReactHooks A React port of the "Random - Positions" Elm Example.
βœ”οΈ RandomNumberGameNode This recipe shows how to build a "guess the random number" game using a custom AppM monad via the ReaderT design pattern and Aff, storing the game state in a mutable variable via a Ref.
βœ”οΈ ReadPrintFileContentsNode Reads a file's contents and prints it to the console.
βœ”οΈ RoutingHashLog This recipe demonstrates hash-based routing with purescript-routing. No web framework is used.
βœ”οΈ RoutingHashReactHooks This recipe shows how to use purescript-routing to do client-side hash-based routing in a React-based single-page application (SPA).
βœ”οΈ RoutingPushReactHooks This recipe shows how to use purescript-routing to do client-side push-state routing in a React-based single-page application (SPA).
βœ”οΈ RunCapabilityPatternNode A skeletal version of an application structuring pattern using purescript-run and free dsls.
βœ”οΈ (try) ShapesHalogenHooks Demonstrates rendering of SVG shapes.
βœ”οΈ (try) ShapesReactHooks Demonstrates rendering of SVG shapes.
βœ”οΈ (try) SignalRenderJs Signal demo that responds to user input and elapsed time.
βœ”οΈ (try) SignalSnakeJs A snake game built using Signal.
βœ”οΈ (try) SignalTrisJs A tetromino game built using Signal.
βœ”οΈ βœ”οΈ (try) SimpleASTParserLog This recipe shows how to parse and evaluate a math expression using parsers and a "precedence climbing" approach.
βœ”οΈ (try) TextFieldsHalogenHooks A Halogen port of the "User Interface - Text Fields" Elm Example.
βœ”οΈ (try) TextFieldsReactHooks A React port of the "User Interface - Text Fields" Elm Example.
βœ”οΈ (try - fixme) TicTacToeReactHooks A PureScript port of the official reactjs.org documentation's Tutorial: Intro to React example.
βœ”οΈ (try) TimeReactHooks A React port of the "User Interface - Time" Elm Example.
βœ”οΈ βœ”οΈ (try) ValueBasedJsonCodecLog This recipe shows how to use codec and codec-argonaut to write value-based bidirectional JSON codecs to encode and decode examples written in "meta-language."
βœ”οΈ (try) WindowPropertiesJs This recipe shows how to get and print various properties in the browser's window object.
βœ”οΈ WriteFileNode Writes a String to a text file using UTF-8 encoding.

More Repositories

1

purescript-jordans-reference

Learn PureScript with this "clone and play" repository
PureScript
546
star
2

learn-halogen

Learn purescript-halogen using a bottom-up apporach via this "clone-and-play" repository
PureScript
185
star
3

purescript-to-haskell

Helps a PureScript developer get more familiar with Haskell, so they can use Haskell as a web server
Haskell
22
star
4

purescript-veither

A Variant that functions like Either but is extensible
PureScript
18
star
5

purescript-interpolate

Enable string interpolation for PureScript
PureScript
16
star
6

purescript-json-codecs

A bidirectional or unidirectional value-based or runtime-configurable typeclass-based JSON codec library.
PureScript
15
star
7

purescript-halogen-hooks-extra

PureScript
11
star
8

pure-conf-talk

Notes and files for my talk for PureConf 2022
PureScript
10
star
9

purescript-node-execa

PureScript
9
star
10

purescript-tidy-codegen-lens

Generate lenses and prisms for your data types automatically.
PureScript
9
star
11

purescript-arrays-zipper

Zippers for arrays
PureScript
7
star
12

purescript-ecosystem-update

Some code that helps us update the PureScript ecosystem when a breaking changes PureScript release is made
PureScript
7
star
13

sudoku-solver

PureScript
5
star
14

local-typeclass-instances

PureScript
5
star
15

type-systems

4
star
16

purescript-typelevel-rows

Convenience transformations for rows
PureScript
4
star
17

purescript-tree-rose

Multi-way tree (Rose Tree) with Zippers
PureScript
4
star
18

purescript-core

PureScript
3
star
19

purescript-halogen-utils

Utility functions for PureScript Halogen
PureScript
2
star
20

purescript-language-purescript

Types and codecs for the PureScript programming language written in PureScript
PureScript
2
star
21

purescript-random-number-game

PureScript
2
star
22

purescript-module-graph

An attempt a visualizing the output of `purs graph` in the browser
PureScript
2
star
23

purescript-node-human-signals

A PureScript port of the `human-signals` JavaScript library
PureScript
2
star
24

purescript-vexceptt

A version of `ExceptT` that uses `Veither`, an extensible `Either`.
PureScript
2
star
25

purescript-types-and-programming-languages

PureScript port of the implementations for the book, Types and Programming Languages
2
star
26

jordanmartinez.github.io

HTML
1
star
27

purescript-tidy-codegen-quine

PureScript
1
star
28

fixPackagesDhallFiles

Quoting the 'assert' package with backticks
Dhall
1
star
29

purescript-generate-values

PureScript
1
star
30

purescript-typelevel-codec-json

Use typeclass-based JSON codecs as though they were value-based JSON codecs
PureScript
1
star
31

purescript-package-graph

PureScript
1
star
32

_dotfiles

Vim Script
1
star
33

spago-next-bug

Shows a few bugs in the spago next
PureScript
1
star
34

asciidoc-gradle-book-template

Provides a minimum Gradle Project template for writing a book via Asciidoc
1
star