Skip to content

Instantly share code, notes, and snippets.

@wongjiahau
Last active December 5, 2018 01:34
Show Gist options
  • Save wongjiahau/d93b6d8d8d6bf5e1c20f947831795268 to your computer and use it in GitHub Desktop.
Save wongjiahau/d93b6d8d8d6bf5e1c20f947831795268 to your computer and use it in GitHub Desktop.
Pineapple idea
replace with : (String , String , String) -> String
x replace y with z =
'a List :> nil
'a List :> 'a head ; 'a
x = 1 head ; 1 ; 2 ; 3 ; 4
length : 'a List -> Int
(xs , x) length = xs length + 1
nil length = 0
data Bool :> true
data Bool :> false
and : Bool -> Bool -> Bool
true and true = true
true and false = false
false and true = false
false and false = false
data 'a Tree :> leaf
data 'a Tree :> 'a node {left: 'a Tree , right: 'a Tree}
min : 'a Tree -> 'a Maybe
leaf min = nothing
value node {left, right} =
left == leaf if {true = nothing, false = left min}
'Hello world'
.reverse
.splitBy ' '
.replace 'ow' with 'yo'
reverse :: a List -> a List
x.reverse = #bla bla#
x.splitBy y = #bla bla#
data Person name:String age:Integer
x = Person.name "Wong" age 99
data Maybe a = Just a | Nothing
group 't Maybe
data 't Just value:'t
data Nothing
't Maybe :> 't Just
't Maybe :> Nothing
Comparable A has
A > A -> Bool
Comparable A has
A == A -> Bool
People
name String
age Integer
Comparable People has
x == y = (x name == y name) and (x age == y age)
x > y = x name > y name
x, square : Number -> Number = x * x
this, replace x with y : String String String -> String =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment