/sham1

Attempt 1 at Scheme, Haskell, and ML

Primary LanguageSchemeMIT LicenseMIT

SCHEME, HASKELL, AND ML (SHAM)

Date: May 1, 2009

INSTALLATION

Name the root directory 'sham' and move it to the DrScheme collects directory.

Haskell source files must have the following as their first line:

#reader (lib "Reader.ss" "sham" "haskell")

QUICK START

See modules/Haskell/CompilationTest1.hs for examples of the supported Haskell grammar.

HASKELL

-Grammar Overview-

SHAM Haskell provides a subset of the Haskell 98 grammar, extended with import type declarations.

The following notable grammar is not supported:

* Layout - Braces and semicolons must be used where appropriate.

* Pattern matching - Only variable patterns are supported.

* Infix application - Binary functions must be applied in prefix position.  For example, (:) x y instead of x : y.

* Case expressions - Case expressions are useless without pattern matching.

* Anonymous data constructor fields - Fields must be named since pattern matching is not supported.  For example, data Tree = Branch { left, right :: Tree } | Leaf { leaf :: Int }.

Many other grammar features are also not supported, but too numerous to enumerate here.  Stick to the "basics," look at example code, or check the parser definition in Parsing.ss to be sure you use only supported correct grammar.

-Extensions-

The Bool type is built in and satisfies the declaration data Bool = True | False.

Since pattern matching is not supported, special predicates are generated for every data constructor C of type T of the form isC :: T -> Bool.  For example, for the type Bool, the predicates isTrue :: Bool -> Bool and isFalse :: Bool -> Bool are generated.

The import type declaration syntax is:

import haskell MyModule (mydecl :: [a], ...)

Module importation is not yet fully implemented, and is not expected to work.  Haskell types are used to describe all data exchanged between interoperating modules.