Build status | Result |
---|---|
Travis CI | |
Circle CI | |
Code coverage |
Pineapple is a language that focus on maintainability.
Read more at Pineapple Documentation.
Definition for Pineapple language and its compiler
Home Page: https://wongjiahau.github.io/Pineapple/
License: Other
Build status | Result |
---|---|
Travis CI | |
Circle CI | |
Code coverage |
Pineapple is a language that focus on maintainability.
Read more at Pineapple Documentation.
This issue is just for keeping track paper that are read previously.
Aspect-oriented programming in FP https://www.cs.ox.ac.uk/files/2282/wgp14-wang.pdf
AOP Review https://core.ac.uk/download/pdf/25872533.pdf
Algebraic effects https://www.microsoft.com/en-us/research/wp-content/uploads/2016/08/algeff-tr-2016-v2.pdf (50% only)
Algebraic effects tutorial http://www.eff-lang.org/handlers-tutorial.pdf
Midori's Error Model http://joeduffyblog.com/2016/02/07/the-error-model/#ambitions-and-learnings
Spec# Tutorial (Design by contract) http://www.it.uu.se/edu/course/homepage/progteori/ht13/specsharptut.pdf
How Should Compilers Explain Problems to Developers?
http://static.barik.net/barik/publications/fse2018/barik_fse18.pdf
Monads for functional programming
https://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf
In the Object specification, do you really need the equal signs or prefixing every property with a .
?
Example without:
// Pineapple
myFruit
name "Mango"
isTasty true
sibling
name "Durian"
isTasty false
amount 10 + 5
def group :comparable
def this:T < that:T -> :boolean
if :T is :comparable
def this:T == that:T -> :boolean
if :T is :comparable
def this:T > that:T -> :boolean
where :T is :comparable
return this < that .Not.And(this == that .Not)
def this:T != that:T -> :boolean
where :T is :comparable
return this == that .Not
def this:T >= that:T -> :boolean
where :T is :comparable
return this > that .Or (this == that)
def this:T <= that:T -> :boolean
where :T is :comparable
return this < that .Or (this == that)
def group :T:binaryTree
where :T is :comparable
def thing :T:node
.value :T
.left :T:binaryTree
.right :T:binaryTree
def :T:node is :T:binaryTree
def thing :emptyNode
def :emptyNode is :binaryTree
def this:T:X.Insert child:T -> :T:binaryTree
if :X is :binaryTree
def this:T:node.Insert child:T -> :T:binaryTree
if this.value == child
return this
if this.value < child
return this with
.left = this.left.Insert child
if this.value > child
return this with
.right = this.right.Insert child
def this:emptyNode.Insert child:T -> :T:binaryTree
return :T:node
.value = child
.left = :emptyNode
.right = :emptyNode
def this:T:list.ToTree -> :T:binaryTree
return this.Foldr (_.Insert __) From :emptyNode
def this:T:X.ToList -> :T:list
if :X is :binaryTree
def this:emptyNode.ToList -> :T:list
return []
def this:T:node.ToList -> :T:list
return this.left.ToList
++ [this.value]
++ this.right.ToList
def this:T:X.Contains child:T -> :boolean
if :X is :binaryTree
def this:emptyNode.Contains child:T -> :boolean
return #false
def this:T:node.Contains child:T -> :boolean
if this.value == child
return #true
if this.value < child
return this.left.Contains child
if this.value > child
return this.right.Contains child
def this:T:X.Minimum -> :T
if :X is :binaryTree
def this:emptyNode.Minimum -> :T
throw
def this:T:X.IsEmpty -> :boolean
if :X is :binaryTree
def this:emptyNode.IsEmpty -> #true
def this:T:node.IsEmpty -> #false
def this:T:node.Minimum -> :T
if this.left.IsEmpty
return this.value
else
return this.left.Minimum
def this:T:X.Maximum -> :T
if :X is :binaryTree
def this:emptyNode.Maximum -> :T
throw
def this:T:node.Maximum -> :T
if this.right.IsEmpty
return this.value
else
return this.right.Maximum
def this:T:binaryTree.InOrder -> this.ToList
def this:T:X.PreOrder -> :T:list
if :X is :binaryTree
def this:emptyNode.PreOrder -> :T:list
return []
def this:T:node.PreOrder -> :T:list
return [this.value]
++ this.left.PreOrder
++ this.right.PreOrder
def this:T:X.PostOrder -> :T:list
if :X is :binaryTree
def this:emptyNode.PostOrder -> :T:list
return []
def this:T:node.PostOrder -> :T:list
return this.left.PostOrder
++ this.right.PostOrder
++ [this.value]
// compile time design by contract (not run time error!)
def this:table{:TKey to :TValue} .get that:TKey -> :TValue
ensure this.hasKeyOf(that)
// logic
// when using the function above
let contact = :table{:string to :number}
"wong" 123
"lee" 456
"john" 789
contact.get "wong"
/* Compile error, you need to make sure the following is/are satisfied before you can call the `.get` function:
ensure contact.hasKeyOf("wong")
To satisfy the constraint above, you have two ways:
1) Use an `if` statement to check the constraint
For example,
if contact.hasKeyOf("Wong")
contact.get "wong" // No compile error
else
// do something
2) Declare a similar `ensure` statement straight below the function signature
For example,
def this:number .divide that:number -> :number
ensure that.isNotZero
return this .unsafeDivide that
def this:number .anotherDivide that:number -> :number
ensure that.isNotZero
return this.divide that // no compile error, because we already ensured that.isNotZero
## Specification
### The structure of ensure statement
EnsureStatement
= `ensure` SingleBooleanFunctionCall
SingleBooleanFunctionCall
= Variable FunctionName
| Variable FunctionName Variable
| Variable FunctionName Variable SubFunctionName Variable
Note that expression is not allowed inside SingleBooleanFunctionCall
For example, the following is invalid:
ensure this.length == that.length // invalid, function parameter cannot be expression
While the following is valid:
ensure this.hasEqualLengthWith(that)
*/
Below is the format for array of object.
let myFruits =
.1 = .name = "Pineapple"
.price = 13
.2 = .name = "Durian"
.price = 15
.3 = .name = "Rambutan"
.price = 19
def Expression
def Constant
:value Integer
def Constant is Expression
def Addition
:left Expression
:right Expression
def Addition is Expression
def (this T).print -> String
if T is Expression
def (this Constant).print -> String
return this:value.toString
def (this Addition).print -> String
return "$(this:left.print) + $(this:right.print)"
// if we want to add evaluate function on Expression
def (this T).evaluate -> Integer
if T is Expression
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.