git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Examples and TODO
a10616fPhil Freeman
README.md+22
@@ -2,3 +2,25 @@ purescript
2==========
2==========
3
3
4A small strongly, statically typed compile-to-JS language with basic extensible records and type-safe blocks
4A small strongly, statically typed compile-to-JS language with basic extensible records and type-safe blocks
5+
6+## Current Features
7+
8+- Support for basic Javascript types
9+- Extensible records
10+- Type-safe blocks with for/while/assignment etc.
11+- Functions with multiple arguments
12+- Pattern matching, object patterns
13+
14+## TODO
15+
16+- Array indexing
17+- Type Synonyms
18+- Better code generation, fewer parens
19+- User defined operators
20+- Mutually recursive functions
21+- Modules
22+- FFI
23+- Top level pattern matching
24+- Pattern matching booleans
25+- Guards
26+- Type classes
examples/List.psnew file+24
@@ -0,0 +1,24 @@
1+data List a
2+ = Nil
3+ | Cons
4+ { head :: a
5+ ; tail :: List a
6+ ; {} }
7+
8+null = \l -> case l of
9+ { Nil -> true
10+ ; _ -> false
11+ }
12+
13+concat = \l1 -> \l2 -> case l1 of
14+ { Nil -> l2
15+ ; Cons x -> Cons(
16+ { head: x.head
17+ , tail: concat(x.tail)(l2)
18+ })
19+ }
20+
21+flatten = \xss -> case xss of
22+ { Nil -> Nil
23+ ; Cons cons -> concat(cons.head)(flatten(cons.tail))
24+ }
examples/Maybe.psnew file+10
@@ -0,0 +1,10 @@
1+data Maybe a = Nothing | Just a
2+
3+maybe = \b -> \f -> \m -> case m of
4+ { Nothing -> b
5+ ; Just a -> f(a)
6+ }
7+
8+fmap = \m -> \f -> maybe(Nothing)(\a -> Just(f(a)))(m)
9+
10+bind = \m -> \f -> maybe(Nothing)(f)(m)