Git Product home page Git Product logo

fp-intro-to-purescript's Introduction

FP-intro

Purpose

The purpose of this repository is to present an introduction to functional programming by way of PureScript. PureScript is a language focused on providing features normally associated with Haskell offshoots, but in the context of JavaScript.

As such, it's built on a foundation of pure functional programming that is very suitable for teaching and expressing abstraction via functions and data structures.

Syntax overview and comparison to TypeScript

There is an overview of some differences and similarities between PureScript and TypeScript here.

Setup

Run the following in order to set the project up:

yarn
yarn spago build

If you are running VSCode, add the following options in your preferences, either for the workspace or your general install (as they are generally useful):

"purescript.addSpagoSources": true,
"purescript.addNpmPath": true,
"purescript.buildCommand": "spago build --no-install --purs-args '--json-errors'",
"purescript.editorMode": true,

Layout

Each module is structured more or less as a series of functions to implement.

Testing exercises

Running yarn test will run the tests for the project and running yarn test:watch will make sure that the tests are re-run when files change.

If you want to run only the tests for a certain file, run yarn test -- -a '-t simple' where "simple" can also be "maybe", "list" or "recursion" as the tests are split up into the modules that they cover.

If you want to run only the tests for a certain file in watch mode, run yarn test:watch -- -a '-t simple'.

Exercise order

While it's possible to open any file in the repository and start working, the recommended order is as follows:

  1. Simple.purs - This introduces the language of PureScript by way of simple functions that you may recognize from other languages.
  2. Bool.purs - Introduces the concept of pattern matching by way of a series of functions operating on boolean values to produce new boolean values.
  3. Maybe.purs - Introduces the idea of a data type that either contains a value of some type or contains nothing. This is a type-safe alternative to null.
  4. Recursion.purs - Introduces non-list based recursion as a concept, emphasizing the idea slicing up work into discrete units.
  5. List.purs - Introduces functions relating to linked lists and how to work with them in a functional context.

fp-intro-to-purescript's People

Contributors

dependabot[bot] avatar gonzooo avatar

Watchers

 avatar  avatar  avatar

Forkers

bbogdanov

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.