Skip to content

Instantly share code, notes, and snippets.

@maddie927
Last active January 4, 2020 06:40

Revisions

  1. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion purescript.md
    Original file line number Diff line number Diff line change
    @@ -133,7 +133,7 @@ mirror a = Tuple a (reverse a)
    * [Tic-Tac-Toe -- Part 1](https://kritzcreek.github.io/example/2015/10/03/tic-tac-toe-with-purescript/)
    * [Tic-Tac-Toe -- Part 2](https://kritzcreek.github.io/tutorial/2015/10/07/playing-tic-tac-toe-with-purescript-signal/)

    [Main.purs](https://gist.github.com/spicydonuts/202fc7a9fe456b2e069e)
    [Completed Main.purs](https://gist.github.com/spicydonuts/202fc7a9fe456b2e069e) (don't cheat!)

    ## More stuff

  2. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -133,6 +133,8 @@ mirror a = Tuple a (reverse a)
    * [Tic-Tac-Toe -- Part 1](https://kritzcreek.github.io/example/2015/10/03/tic-tac-toe-with-purescript/)
    * [Tic-Tac-Toe -- Part 2](https://kritzcreek.github.io/tutorial/2015/10/07/playing-tic-tac-toe-with-purescript-signal/)

    [Main.purs](https://gist.github.com/spicydonuts/202fc7a9fe456b2e069e)

    ## More stuff

    * [PureScript by Example](https://leanpub.com/purescript/read) (ebook by Phil Freeman)
  3. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion purescript.md
    Original file line number Diff line number Diff line change
    @@ -144,5 +144,4 @@ mirror a = Tuple a (reverse a)
    * [PureScript Wiki - Learn](http://www.purescript.org/learn/)
    * [PureScript subreddit](https://www.reddit.com/r/purescript)
    * [QuickCheck your JavaScript!](http://www.purescript.org/learn/quickcheck/)

    * [Haskell Programming](http://haskellbook.com/) -- great intro to FP, Haskell, and all this 'type' stuff
  4. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -86,6 +86,28 @@ silence :: Maybe String
    silence = Nothing
    ```

    ```purescript
    type User = { name :: String
    , email :: String
    }
    type Userish a = { name :: String
    , email :: String
    | a
    }
    ```

    ```purescript
    import Prelude
    import Control.Monad.Eff
    import Control.Monad.Eff.Console
    sayHi :: forall eff. Eff (console :: CONSOLE | eff) Unit
    sayHi = log "hello world."
    main = sayHi
    ```

    ```purescript
    data Direction
    = North
    @@ -122,3 +144,5 @@ mirror a = Tuple a (reverse a)
    * [PureScript Wiki - Learn](http://www.purescript.org/learn/)
    * [PureScript subreddit](https://www.reddit.com/r/purescript)
    * [QuickCheck your JavaScript!](http://www.purescript.org/learn/quickcheck/)

    * [Haskell Programming](http://haskellbook.com/) -- great intro to FP, Haskell, and all this 'type' stuff
  5. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 41 additions and 6 deletions.
    47 changes: 41 additions & 6 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,10 @@

    ###### What is it?

    * compiles to js
    * haskell-inspired type system (with some improvements!)
    * no runtime (unlike elm, ghcjs, etc)
    * focus on _readable_ and _debuggable_ js
    * Compiles to JavaScript
    * Haskell-inspired type system (with some improvements!)
    * No runtime (unlike Elm, GHCJS, etc)
    * A focus on _readable_ and _debuggable_ JavaScript


    ## Installing
    @@ -15,19 +15,37 @@
    npm i -g purescript pulp
    ```

    ###### PureScript:
    ###### PureScript
    - psc
    - psci
    - ...

    ###### Pulp:
    ###### Pulp
    - `pulp init`
    - `pulp build`
    - `pulp test`
    - `pulp docs`
    - `pulp server`


    ## Editor Support

    Atom via
    [psc-ide](https://github.com/kRITZCREEK/psc-ide),
    [ide-purescript](https://atom.io/packages/ide-purescript), and
    [language-purescript](https://atom.io/packages/language-purescript)
    ```
    git clone https://github.com/kRITZCREEK/psc-ide.git
    cd psc-ide
    stack install
    ```
    ```
    apm install ide-purescript purescript-language
    ```

    Vim and Emacs plugins too!


    ## Let's compile some code!

    ```purescript
    @@ -87,3 +105,20 @@ instance reversibleDirection :: Reversible Direction where
    mirror :: forall a. (Reversible a) => a -> Tuple a a
    mirror a = Tuple a (reverse a)
    ```

    ## Project!

    * [Tic-Tac-Toe -- Part 1](https://kritzcreek.github.io/example/2015/10/03/tic-tac-toe-with-purescript/)
    * [Tic-Tac-Toe -- Part 2](https://kritzcreek.github.io/tutorial/2015/10/07/playing-tic-tac-toe-with-purescript-signal/)

    ## More stuff

    * [PureScript by Example](https://leanpub.com/purescript/read) (ebook by Phil Freeman)
    * [IRC Channel](http://webchat.freenode.net/?channels=purescript)
    * [Pursuit](http://pursuit.purescript.org/) -- "google (hoogle) for PureScript types and libraries"
    * [Recommended libraries](https://github.com/purescript/purescript/wiki/Recommended-Libraries)
    * [Halogen and routing in PureScript](http://www.parsonsmatt.org/programming/2015/10/22/purescript_router.html)
    * [4 part Elm vs PureScript comparison](http://www.parsonsmatt.org/programming/2015/10/03/elm_vs_purescript.html) (this eventually turns into "using the Elm Architecture in PureScript")
    * [PureScript Wiki - Learn](http://www.purescript.org/learn/)
    * [PureScript subreddit](https://www.reddit.com/r/purescript)
    * [QuickCheck your JavaScript!](http://www.purescript.org/learn/quickcheck/)
  6. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # PureScript
    # [PureScript](http://www.purescript.org/)


    ###### What is it?

    * compiles to js
    * advanced, haskell-inspired type system ()
    * haskell-inspired type system (with some improvements!)
    * no runtime (unlike elm, ghcjs, etc)
    * focus on _readable_ and _debuggable_ js

  7. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    # PureScript


    What is it?
    ###### What is it?

    * compile to js
    * compiles to js
    * advanced, haskell-inspired type system ()
    * no runtime (unlike elm, ghcjs, etc)
    * focus on _readable_ and _debuggable_ js
  8. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion purescript.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # PureScript


    ## What is it?
    What is it?

    * compile to js
    * advanced, haskell-inspired type system ()
  9. @spicydonuts spicydonuts revised this gist Nov 19, 2015. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,34 @@
    # purescript
    # PureScript


    ## what is it?
    ## What is it?

    * compile to js
    * advanced, haskell-inspired type system ()
    * no runtime (unlike elm, ghcjs, etc)
    * focus on _readable_ and _debuggable_ js


    ## installing
    ## Installing

    ```shell
    npm i -g purescript pulp
    ```

    ###### purescript:
    ###### PureScript:
    - psc
    - psci
    - ...

    ###### pulp:
    ###### Pulp:
    - `pulp init`
    - `pulp build`
    - `pulp test`
    - `pulp docs`
    - `pulp server`


    ## let's compile some code!
    ## Let's compile some code!

    ```purescript
    x :: Number
  10. @spicydonuts spicydonuts created this gist Nov 19, 2015.
    89 changes: 89 additions & 0 deletions purescript.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    # purescript


    ## what is it?

    * compile to js
    * advanced, haskell-inspired type system ()
    * no runtime (unlike elm, ghcjs, etc)
    * focus on _readable_ and _debuggable_ js


    ## installing

    ```shell
    npm i -g purescript pulp
    ```

    ###### purescript:
    - psc
    - psci
    - ...

    ###### pulp:
    - `pulp init`
    - `pulp build`
    - `pulp test`
    - `pulp docs`
    - `pulp server`


    ## let's compile some code!

    ```purescript
    x :: Number
    x = 5.0
    ```

    ```purescript
    y :: Int
    y = 5
    ```

    ```purescript
    import Prelude ((+))
    add :: Number -> Number -> Number
    add x y = x + y
    ```

    ```purescript
    import Prelude ((+))
    add :: Int -> Int -> Int
    add x y = x + y
    ```

    ```purescript
    data Maybe a = Nothing | Maybe a
    ```

    ```purescript
    data Maybe a = Nothing | Maybe a
    greeting :: Maybe String
    greeting = Just "hello."
    silence :: Maybe String
    silence = Nothing
    ```

    ```purescript
    data Direction
    = North
    | South
    | East
    | West
    class Reversible a where
    reverse :: a -> a
    instance reversibleDirection :: Reversible Direction where
    reverse North = South
    reverse South = North
    reverse East = West
    reverse West = East
    mirror :: forall a. (Reversible a) => a -> Tuple a a
    mirror a = Tuple a (reverse a)
    ```