Skip to content

Instantly share code, notes, and snippets.

@mlhaufe
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlhaufe/2343805a222cb7edde86 to your computer and use it in GitHub Desktop.
Save mlhaufe/2343805a222cb7edde86 to your computer and use it in GitHub Desktop.
Lapis Design Notes
module
exports Bool
protocol Bool
False
True
and Bool => Bool
or Bool => Bool
not => Bool
def False
and _ => False
or b => b
not => True
def True
and b => b
or _ => True
not => False
// This is used to resolve ambiguities when multiple module share a required
// protocol it can also be used to specify when one module's implementation is
// preferred over another's. An example would be if you want to override/specify
// a patched implementation of a method for one module, but still use the older
// implementation for another which might rely on the broken behavior.
// With this feature, one can still use the same method name in both modules
// while maintaining the clarity of the original naming convention
config
ModuleName2.ExportsName => ModuleName1::RequiresName
ModuleName4.ExportsName => ModuleName3::RequiresName
...
// <http://research.microsoft.com/en-us/um/people/akenn/generics/gadtoop.pdf>
module
exports Expr
requires Int Bool
protocol Bool
... //TODO: what is the minimum needed here?
protocol Int
... //TODO:what is the minimum needed here?
protocol Pair @a @b
Pair fst: @a snd: @b => Pair a: @a b: @b
= Pair fst: @a snd: @b => Bool
def Pair @fst @snd
= Pair :fst :snd => (@fst = fst) & (@snd = snd)
protocol Expr @a
I val: Int => Expr a: Int
B val: Bool => Expr a: Bool
Add left: (Expr a: Int) right: (Expr a: Int) => Expr a: Int
Mul left: (Expr a: Int) right: (Expr a: Int) => Expr a: Int
Eq left: (Expr a: Int) right: (Expr a: Int) => Expr a: Bool
Cond pred: (Expr a: Bool) ifTrue: (Expr a: @a) ifFalse: (Expr a: @a) => Expr a: @a
// Where should @b come from? It is only used here... This will infect the result type of the other constructors
Tuple left: (Expr a: @a) e2: (Expr a: @b) => Exp a: (Pair a: @a b: @b)
eval => @a
def I @val
eval => @val
def B @val
eval => @val
def Add @left @right
eval => @left + @right
def Mul @left @right
eval => @left + @right
def Eq @left @right
eval => @left = @right
def Cond @pred @ifTrue @ifFalse
eval => @pred ifTrue: @ifTrue ifFalse: @ifFalse
def Tuple @left @right
eval => Pair fst: @left snd: @right
// A set of name:location pairs representing the location of modules to use in the
// application.
// - Each name must be unique
// - Each location must be unique
// - locations can only be of the form: <std:version:name> -or- absolute paths of the form: </folder1/folder2/lpsName.lps>
manifest
String: <std:0.0.1:string>
ModuleName2: </foo.lps>
ModuleName3: </bar/quux.lps>
...
module
exports Nat
protocol Nat
<[1-9][0-9]*>
+ Nat => Nat
def Nat
+ <[1-9][0-9]*> => ...
def <[1-9][0-9]*>
+ <[1-9][0-9]*> => ...
//Note: (Foo) != ( Foo )
@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

manifest.lpm

remove the restriction on duplicate paths
figure out what should happen when the same module is referred to twice. This may not be a problem

@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

Pattern Constructors?

"foo" ++ "12345"

def String
++ <[0-9][0-9]+> => ...

would need to restrict to uppercase prefix or digits...

what would protocol declaration look like?

named matches in argument patterns looks like?

@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

What is the entry point for the application?

What event is fired?

how is it triggered?

@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

In TAPL 140-141 a Data issue is described.

Compare the similarities between data labels + types with context labels & types

@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

TAPL CH 15

Pattern matching on constructor subtypes?

how would methods be found statically?

@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

identifiers should not be strings, but Symbols ala JavaScript/Scheme/Ruby

https://hacks.mozilla.org/2015/06/es6-in-depth-symbols/

@mlhaufe
Copy link
Author

mlhaufe commented Jun 15, 2015

If statements vs. Either Types vs. Method overloading...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment