Skip to content

Instantly share code, notes, and snippets.

@ppopoff
Created December 8, 2016 19:50
Show Gist options
  • Save ppopoff/5b1284639feab77c48cc89fae617d018 to your computer and use it in GitHub Desktop.
Save ppopoff/5b1284639feab77c48cc89fae617d018 to your computer and use it in GitHub Desktop.
mink syntax 0-draft
use java.util.Arrays.fromList
use some.bullshit.you.can.not.imagine
// constants
three = 3
someText = "Text"
someOtherText: String = "Some other text"
// functions
// all functions in module are private by default
// module may have two types of functions:
// public and private
// to make function public add + to it
+ sqr = x: Int -> x * x
+ cube: Double -> Double =
x -> x * x * x
// private function
// when function has multiple parameters
// well they are curried by default, like in haskell
linear: Double -> Double -> Double -> Double =
k, x, b -> k * x + b
// type will be infered automatically
// record's parameters are PUBLIC by default
aRecord: Record[name:String, age:Int] = { name = "Jane", age = 22 }
aTulple: Record[String, Int] = { "Me", 24 }
// guess what type is... Hmmm it will be trnslated like this
// aTuple: Record[_1: String, _2: Int] = { _1: String, _2: Int }
// guess what `class` is you think it's a keyword. You're wrong...
// actually it is annotation for record structure
// there are no inheretance for classes. Live with it
class Dog = {
// class parameters are private by default
tag: String = "Rex"
age: Int = 13
+ wow: String -> Unit =
text -> writeLn(text)
}
// well think of them as you think about java interfaces...
// they are different
// all members of type class are... PUBLIC by default
type class Eq [T] = {
// overloaded operator
(==): T -> T -> Logical
}
// type aliasing why not
// String can be threated as username
Username = String
// ADT's (Enumerations) You have it
TrafficLight = Red, Yellow, Green, `N/a`
// A singleton object or atom? You have it
// Atom: Atom the only object of it's kind
// data is annotation and it's not mandatory :)
data Atom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment