Getting Started
If Anastasia has not been installed go to the
Download Page and follow the instructions there. Run Anastasia by typing
"./anastasia" in the Anastasia directory. Once Anastasia has finished loading up the user will be free to open up an
environment for any language which has a language script defined. At present there is a basic ML script and a Haskell script. Once a language script has been opened to use in an environment there should be a blank black screen with a
<> in the top left corner. A code fragment can then be added by clicking anywhere within these brackets.
Adding & Changing Code Fragments
Add a code fragment by clicking just after a
< or just before a
> and selecting
Add New Code Fragment from the drop down menu that appears. This will create a
Declaration. To change the
Declaration click on any part of the text and select
Change Code Fragment frin the drop down menu that appears. This will then give all the possible kinds of declarations for the current language script. The user will then continue in this manner to define their code. When the final option is chosen it will either be an entry shard or a selection shard.
Entry Shards
Entry shards will appear as green text giving the default values (for the selected language) of it's type.
Some example options are:
- Variable: will appear as newVar and can be changed to a variable name by typing the name in.
- Integer/Int: will appear as 0 can be changed to another number by typing it in.
- Character/Char: will appear as "a" and be changed to another character by typing it in.
- String: will appear as "string" and be changed to another string by typing it in.
Selection Shards
Selection shards will appear as light gray text with a gray background and the user will be able to select the correct option from a drop down menu by clicking on it.
Some example options are:
- Atomic Pattern: gives options Wildcard, Integer, Char, etc.
- Atomic Type: gives the base types of the language plus any user defined types eg. Integer, Char, NewType, etc.
- Operator: gives the operators for the language eg. +, -, *, /, ++, etc.
Variables
As variables get defined by the user they get added to the current static environment. They will appear as options in
Expressions as soon as they have been defined. These will include function names so they can be called from within other functions or even recursively.
A Step-by-Step Haskell Example
Here we will create a small Haskell program using Anastasia.
We will define the factorial function
fac :: Integer -> Integer
fac 0 = 1
fac (n+1) = (n+1)*(fac n)
- Start up Anastasia
Do this by typing "./anastasia" from within the Anastasia directory.
- Start a new environment using the Haskell language script - Haskell.pl
To do this you select New Environment from the "File" menu and then double click on "Haskell.pl".
- Add a Declaration.
Do this by clicking on <> in the top left corner and selecting Add New Code Fragment from the drop down menu that appears.
- Change the Declaration to a Function Declaration.
Do this by clicking on Declaration, selecting Change Code Structure and then Function Declaration from the drop down menu that appears.
- Change the Function Signature to a Signature.
Do this by clicking on the Function Signature, selecting Change Code Structure and then Signature from the drop down menu that appears.
- Change newVar to fac.
Do this by selecting the green text newVar and typing fac.
- Change the Type -> Type to Integer -> Integer.
Do this by clicking on each Type, selecting Change Code Structure and then Atomic Type from the drop down menu that appears. Then click on Atomic Type. This will be an Integer by default.
- Rename newVar to fac on the second line as above.
- Change Function Binding to Function Binding Sequence (=).
- Change Argument Binding to Argument Pattern Sequence.
- Change Pattern to Atomic Pattern.
- Change Atomic Pattern to Integer which will be 0 by default.
- Change Expression to Atomic Expression.
- Change Atomic Expression to Integer which will be 0 by default.
- Change 0 to 1.
Do this by selecting the green 0 and typing 1.
- Add the next line of the function definition.
Do this by clicking on the > and select Add New Code Fragment.
- Rename newVar to fac.
- Change Function Binding to Function Binding Sequence (=).
- Change Argument Binding to Argument Pattern Sequence.
- Change Pattern to Constructed Pattern (Infix).
- Change the first Pattern to n.
Do this by clicking on the Pattern, selecting Atomic Pattern and then Variable and renaming it to n.
- Change the second Pattern to 1.
Do this by clicking on the Pattern, selecting Atomic Pattern and then Integer and changing it to 1.
- Change the Expression to a Constructed Expression (Infix) and change the operator to a *.
- Change the first Expression to n+1 in much the same was as above.
- Change the second Expression to Function Expression.
- Change the first Expression to fac.
- Change the second Expression to n.
- And you're done!
Back to Documentation
People
The following people are assosciated with the Anastasia project: