Skip to content

Instantly share code, notes, and snippets.

@davidchase
Last active January 6, 2020 20:48
Show Gist options
  • Select an option

  • Save davidchase/4b7e0e2f1159616979919dd1dd97c876 to your computer and use it in GitHub Desktop.

Select an option

Save davidchase/4b7e0e2f1159616979919dd1dd97c876 to your computer and use it in GitHub Desktop.

Revisions

  1. davidchase revised this gist Jan 6, 2020. No changes.
  2. davidchase revised this gist Jan 6, 2020. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions Main.purs
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,24 @@ import Prelude

    import Control.Monad.Eff (Eff)
    import Data.Foldable (fold)
    import TryPureScript (DOM, h1, h2, p, text, list, indent, link, render, code)
    import TryPureScript (DOM, p, render, text)

    data Maybe a = Just a | Nothing

    map :: forall a b. (a -> b) -> Maybe a -> Maybe b
    map f n =
    case n of
    Just n -> Just (f n)
    Nothing -> Nothing


    toString x =
    case x of
    Just x -> "Just(" <> show x <> ")"
    Nothing -> "Nothing"

    main :: Eff (dom :: DOM) Unit
    main =
    render $ fold
    [ h1 (text "Try PureScript!")
    , p (text "Try out the examples below, or create your own!")]
    [ p (text $ toString $ Just 1),
    p (text $ toString $ map(\x -> x * x) $ Just 10)]
  3. davidchase created this gist Jan 6, 2020.
    13 changes: 13 additions & 0 deletions Main.purs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    module Main where

    import Prelude

    import Control.Monad.Eff (Eff)
    import Data.Foldable (fold)
    import TryPureScript (DOM, h1, h2, p, text, list, indent, link, render, code)

    main :: Eff (dom :: DOM) Unit
    main =
    render $ fold
    [ h1 (text "Try PureScript!")
    , p (text "Try out the examples below, or create your own!")]