Last active
December 18, 2015 08:29
-
-
Save mlhaufe/cd0b2b7d4e61f9a69f79 to your computer and use it in GitHub Desktop.
Primarily a brainstorming exercise to test out the feel of the language design thus far.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module | |
exports #Bool #False #True | |
def Bool | |
def False <| Bool | |
and False -> False | |
and True -> True | |
or False -> False | |
or True -> True | |
not -> True | |
def True <| Bool | |
and True -> True | |
and False -> False | |
or True -> True | |
or False -> True | |
not -> False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module-manifest | |
M1 -> </lapis/std/A> | |
M2 -> <http://example.com/src/B> | |
module-config | |
N1 -> M1 | |
N2 -> M2 T1:M1.Foo T2:M1.Bar | |
app-view | |
</> -> N1 | |
</Baz> -> N2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module :Int :Bool | |
exports Expr | |
data Expr :_ => Expr Int | |
I value: Int | |
Add | |
left: Expr Int | |
right: Expr Int | |
Mul | |
left: Expr Int | |
right: Expr Int | |
data Expr :_ => Expr Bool | |
B value: Bool | |
Eq | |
left: Expr Int | |
right: Expr Int | |
protocol Expr :a | |
eval -> a | |
trait I | |
eval -> $ value | |
trait B | |
eval -> $ value | |
trait Add | |
eval -> $ left eval + $ right eval | |
trait Mul | |
eval -> $ left eval * $ right eval | |
trait Eq | |
eval -> $ left eval = $ right eval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module | |
exports Expr | |
data Pair :a :b | |
Pair | |
fst: a | |
snd: b | |
data Expr :_ => Expr Int | |
Lit value: Int | |
Plus | |
e1: Expr Int | |
e2: Expr Int | |
data Expr :_ => Expr Bool | |
Equals | |
e1: Expr Int | |
e2: Expr Int | |
data Expr :a => Expr a | |
Cond | |
e1: Expr Bool | |
e2: Expr a | |
e3: Expr a | |
//FIXME | |
data Expr :a :b => Expr a | |
Fst e: Expr (Pair fst: a snd: b) | |
//FIXME | |
data Expr :a :b => Expr b | |
Snd e: Expr (Pair fst: a snd: b) | |
//FIXME | |
data Expr :a :b => Expr (Pair a: a b: b) | |
Tuple | |
e1: Expr a | |
e2: Expr b | |
protocol Expr :a | |
eval -> a | |
trait Lit | |
eval -> $ value | |
trait Plus | |
eval -> $ e1 eval + $ e2 eval | |
trait Cond | |
eval ; $ e1 eval = True -> e2 eval | |
eval ; $ e1 eval = False -> e3 eval | |
trait Equals | |
eval -> $ e1 eval = $ e2 eval | |
trait Tuple | |
eval -> Pair fst: $ e1 eval snd: $ e2 eval | |
trait Fst | |
eval -> $ e eval fst | |
trait Snd | |
eval -> $ e eval snd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module :Int :String | |
exports Int | |
trait Int | |
fizzBuzz ; 3 divides $ -> "Fizz" | |
; 5 divides $ -> "Buzz" | |
; -> `#{$}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module | |
exports Pair | |
data Pair :a :b | |
Pair left: a right: b | |
trait Pair | |
+ Pair :left :right -> Pair left: left + $ left | |
right: right + $ right |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module :String | |
exports String | |
trait String | |
isPalindrome -> $ reverse = self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module :Int | |
exports Point2 | |
data Point2 | |
Point2 x: Int y: Int | |
trait Point2 | |
+ Point2 :x :y -> Point2 x: x + $ x | |
y: y + $ y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- data introduced by an unfold | anamorphism | |
-- A Recursive Datatype is the Least Fixpoint of a Functor | |
data Tree a = Leaf a | Branch (Tree a) a (Tree a) | |
newtype Tree a = Tree {unNode :: Either a (Tree a, a, Tree a))} | |
data List a = Nil | Cons a (List a) | |
newtype List a = List {unCons :: Maybe (a, List a)} |
If a definition has no methods or properties, can it not be constructed?
"You can not instantiate a definition which does not define or inherit methods"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-use a manifest file separate from the config file