Eastwest‎ > ‎

Tutorial


Introduction


Eastwest is a highly experimental structurally edited programming language. It's goal is to show that editing large pieces of source code can be done quickly, efficiently and easily. The only interface to Eastwest is through its structure editor, so presenting source code snippets is, unfortunately, not possible. Fortunately, it can be done with videos. This tutorial is composed of a series of videos which can be imitated. After watching and imitating all the videos the user will have a grasp of everything you can do with Eastwest.


Basic uses

Hello World

In this example you will see how to:
  • include a module
  • add a function
  • specify a function's return type
  • name a function
  • call another function
  • compile a module


Naming functions

In this video you will learn the finer point of naming functions in eastwest and you will learn about the floatArithmetic module. In Eastwest, function names are very flexible. The functions

  • x plus y
  • the sum of x and y
  • x increased by y
are all valid function names.
In this video you will see how to:
  • add arguments to a function
  • how to specify an argument's type
  • how to specify an argument's name


Simple Datatype

In this video you will learn how to:
  • add a simple datatype
  • name your datatype
  • add a constructor
  • name your constructor
Notice how constructor naming is very flexible. In this case, the constructor names are infix.

http://www.youtube.com/watch?v=LAccfmDqH8I



Polymorphic Datatype

In this video you will learn how to define a polymorphic list.

http://www.youtube.com/watch?v=A5E96AF0lk4


User input

The easiest way to get input from a user is to use the prompt keyword. prompt simply prompts the user for a value for the type which is infered. In this tutorial you will learn:
  • how to define a calculator datatype
  • how to define a function which takes an element of type calculator and returns a float
  • how to prompt the user for an element of type calculator
http://www.youtube.com/watch?v=JTlRpE7Y_X4


Saving, loading and clearing

In this video you will learn how to save, clear and open a module. There is no "save as" feature in Eastwest. Instead you must first rename a module then save it.

http://www.youtube.com/watch?v=nWMJ_dRlMh8


Patterns

In this tutorial you will learn how to do some basic pattern matching. We will continue with the calculator example with the aim of writing a function which evaluates a calculator.

http://www.youtube.com/watch?v=L1g7qUXdEIw

Let


In this tutorial you will learn how to use let. Let simply lets you define a function or value locally.

http://www.youtube.com/watch?v=Tt_Uik-Creo

Keybindings

These are the keybindings in Eastwest:

 F1-F12    Select a suggestion
 Delete     Delete a node or its contents
 shift-up move a declaration up
 shift-down move a declaration down
 ctrl-l
 insert a let
 ctrl-p insert a prompt
 ctrl-c copy
 ctrl-v paste
 left move to parent
 right move to leftmost child
 up move to left child
 down move to right child
 insert select/unselect menu
 escape hide/show suggestions

Using these key bindings we can usually completely avoid using the mouse.

Putting it all together: a calculator

We will build a calculator from scratch, thus recapitulating the "simple datatype","patterns", "user input" and "let" tutorials. In this tutorial we will avoid using the mouse by only using the key bindings.

http://www.youtube.com/watch?v=SSZBc2ohR2o

A note on types and errors


The type of an expression is always displayed on the top of the screen. The only way to encounter a type error is when you change the type of a function or constructor. When this happens, the expression is highlighted in red. Selecting the expression will display the type error. Another error often encountered is when a function or type is not found because it was since deleted. In that case, the offending expression is once again highlighted.


Changing fonts

Eastwest does not differentiate between different character sets however you the default font only supports latin characters. To change this set the environment variable OSET_FONT_LOCATION to the font you wish to use. Here is a video which demonstrates changing the font to view a program written in japanese:

http://www.youtube.com/watch?v=vwgvVpCRecE

More advanced uses


Token types, part 1

In this tutorial you will learn how to deal with languages that contain contain identifiers. The language will be a form which will contain a name and an email address.

http://www.youtube.com/watch?v=wpdlySeUUvk

Token types, part 2

In this tutorial you will learn a more advanced use of token types: to be able to handle scoped variables. In this case, we will focus on lambda calculus

http://www.youtube.com/watch?v=3KvHfoN7Ty8

Generalized Algebraic Datatypes

In this tutorial you will be introduced to generalized algebraic datatypes by writing a small simply typed language.

http://www.youtube.com/watch?v=hOiI2oJZKgE


Lambda calculus with type inference

Token types combined with generalized algebraic datatypes can achieve some surprisingly powerful and safe languages, as seen in this tutorial.

http://www.youtube.com/watch?v=eF9cLyWAnpg

Formatting


It is possible to change the indentation and the newline placement in Eastwest. In this video you will see how to remove the default newline placement and the indentation of the plus operator. Furthermore, you will see an example of using copy/paste to reduce some repetitive work.

http://www.youtube.com/watch?v=n-jEnsrMGPE