Skip to content

Instantly share code, notes, and snippets.

@davidchase
Last active January 6, 2020 20:48
Show Gist options
  • Save davidchase/4b7e0e2f1159616979919dd1dd97c876 to your computer and use it in GitHub Desktop.
Save davidchase/4b7e0e2f1159616979919dd1dd97c876 to your computer and use it in GitHub Desktop.
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Data.Foldable (fold)
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
[ p (text $ toString $ Just 1),
p (text $ toString $ map(\x -> x * x) $ Just 10)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment