FISH READY REFERENCE
Types

Concrete Syntax

Constants

Mathematical Functions

standard_prelude.fsh

Shell Actions

Modifications

Known Bugs

Benchmarks

Types

FISh is a strongly typed language. The compiler will (attempt to) assign a type to every program phrase. Knowledge of the FISh type system will help you to organise your programs, and understand type error messages as they arise.

FISh data types t represent storeable values. They split into array types and shape types. The array types a are generated by datum types d

d ::= int | float | bool | char | ...

and array type variables X, and closed under the formation of array types

a ::= X | d | [a]

Each datum type has an analogous static datum type

~d ::= size | cost | fact | mark | ...

whose values are to be computed during compilation (cost was formerly known as stat float). The given names reflect some of their properties or use, but they can be used for any static computaiton. Sizes are used to represent array lengths. Costs will be used for static cost analysis. Facts are booleans whose value never changes. Marks are fixed characters (one's mark, or signature, never changes). Shape types are either static datum types or are shapes of array types, obtained by pre-pending a # to an array type.

s ::= ~d | #a

Take care not to confuse ~int = size with #int. The latter is the type of shapes of integers, of which there is only one correct value, which can be thought of as the memory requirements for storing one integer. Meaningful program fragments have associated phrase types th (the usual symbol is theta, but we are sticking to ascii characters here). Their structure is given by

th ::= V | #V | exp t | var a | comm | th -> th

V is a phrase type variable, whose shape is #V. Each data type t has a corresponding type exp t of expressions. Array data types (unlike shape types) are assignable, and so have a type var a to represent the variable being assigned to. comm is the type of commands. Functions are represented by function types th1 -> th2. Note that procedures (and higher-order procedures) can be expressed using function types.

We often write t instead of exp t when it is clear that a phrase type is required.

Each phrase type has an asociated shape. See the paper for details.

FISh supports Hindley-Milner style polymorphism with respect to both array and phrase variables. That is, type schemes are obtained by quantifying types by either array or phrase type variables.



Page Last Updated: Friday, 07-Aug-1998 21:33:18 EST


Main | Announcement | Latest Paper | Distribution | Tutorial
Ready Reference | Benchmarks | Designer

Please feel free to send any comments.

Copyright Barry Jay © 1998