Skip to content

Commit

Permalink
update README and add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdagos committed Sep 10, 2016
1 parent 2659674 commit fe19ade
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ README

## Introduction

It's a programming language! A minimalist programming language.

I wrote (most) this during the ZuriHac 2016 weekend, and **it's still a work in
progress.**
It's a programming language! A minimalist (functional) programming language.

## First steps

Expand Down Expand Up @@ -61,6 +58,27 @@ def main [] = {
}
```

### Functional

The language is functional, so you can treat functions as
[first class citizens](https://en.wikipedia.org/wiki/First-class_function).

```
def flip [f, x, y] = f $ y x
// Prints out 0.5
def main [] = {
val flipDiv = flip $ (/); // flip the order of the division
puts-ln $ (flipDiv $ 8 4); // 4 / 8 = 0.5
}
```

This is the `flip` function
[found in Haskell (for example)](http://hackage.haskell.org/package/base-4.9.0.0/docs/Prelude.html#v:flip).

You can read more about `flip`
[here](http://learnyouahaskell.com/higher-order-functions).

### Automatic currying

The language supports automatic currying:
Expand Down
15 changes: 15 additions & 0 deletions test/examples/flip.bl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
output: "0.5\n-4\n"
---

module Main where

def flip [f, x, y] = f $ y x

def main [] = {
val flipDiv = flip $ (/);
val flipMin = flip $ (-);

puts-ln $ (flipDiv $ 8 4); // 4 / 8 = 0.5
puts-ln $ (flipMin $ 8 4); // 4 - 8 = -4
}
11 changes: 11 additions & 0 deletions test/parser_tests/flip.bl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Main where

def flip [f, x, y] = f $ y x

def main [] = {
val flipDiv = flip $ (/);
val flipMin = flip $ (-);

puts-ln $ (flipDiv $ 8 4); // 4 / 8 = 0.5
puts-ln $ (flipMin $ 8 4); // 4 - 8 = -4
}

0 comments on commit fe19ade

Please sign in to comment.