https://github.com/willfaught/sham2
Attempt 2 at Scheme, Haskell, and ML
https://github.com/willfaught/sham2
haskell ml scheme
Last synced: about 1 year ago
JSON representation
Attempt 2 at Scheme, Haskell, and ML
- Host: GitHub
- URL: https://github.com/willfaught/sham2
- Owner: willfaught
- License: mit
- Created: 2009-08-16T08:36:38.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T02:23:26.000Z (about 2 years ago)
- Last Synced: 2025-05-03T04:45:24.978Z (about 1 year ago)
- Topics: haskell, ml, scheme
- Language: Haskell
- Homepage:
- Size: 93.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
SCHEME, HASKELL, AND ML
1 SYNTAX
1.1 NOTATION
Pattern choice: pattern1 | pattern2.
Zero or more repetitions of a pattern: {pattern}.
Pattern sequence: pattern1 pattern2.
Pattern sequences are delimited by one or more whitespaces.
Literals are surrounding by single quotes, or double quotes where needed.
Letter, digit, and string non-terminals assume a straightforward definition.
1.2 PARENTHESES
Outermost expressions and types may not be contained in parentheses. Natural numbers and variables are not contained in parentheses. Natural number, lump, and variable types are not contained in parentheses. All other expressions and types must be contained in parentheses for unambiguity.
1.3 HASKELL AND ML TYPES
Haskell and ML types--static types--are defined as the stype non-terminal in the grammar below.
stype = forall | fun | label | lump | nat | tyvar
forall = 'A' var '.' stype
var = letter { letter | digit } { "'" }
fun = stype '->' stype
label = stype '^' num
num = digit { digit }
lump = 'L'
nat = 'N'
tyvar = var
1.4 HASKELL
Haskell expressions are defined as the hexp non-terminal in the grammar below. The mexp and sexp non-terminals are defined elsewhere.
hexp = hadd | hfix | hfunabs | hfunapp | hif0 | hm | hnum | hs | hsub | htyabs | htyapp | hvar | hwrong
hadd = '+' hexp hexp
hfix = 'fix' hexp
hfunabs = '\' var ':' stype '.' hexp
hfunapp = hexp hexp
hif0 = 'if0' hexp hexp hexp
hm = 'HM' stype mexp
hnum = num
hs = 'HS' stype sexp
hsub = '-' hexp hexp
htyabs = '\\' var '.' hexp
htyapp = hexp '{' stype '}'
hvar = var
hwrong = 'wrong' stype string
1.5 ML
ML expressions are defined as the mexp non-terminal in the grammar below. The hexp and sexp non-terminals are defined elsewhere.
mexp = madd | mfix | mfunabs | mfunapp | mh | mif0 | mnum | ms | msub | mtyabs | mtyapp | mvar | mwrong
madd = '+' mexp mexp
mfix = 'fix' mexp
mfunabs = '\' var ':' stype '.' mexp
mfunapp = mexp mexp
mh = 'MH' stype hexp
mif0 = 'if0' mexp mexp mexp
mnum = num
ms = 'MS' stype sexp
msub = '-' mexp mexp
mtyabs = '\\' var '.' mexp
mtyapp = mexp '{' stype '}'
mvar = var
mwrong = 'wrong' stype string
1.6 SCHEME
Scheme expressions are defined as the mexp non-terminal in the grammar below. The hexp and mexp non-terminals are defined elsewhere.
sexp = sadd | sfunabs | sfunapp | sh | sif0 | sm | snum | ssub | svar | swrong
sadd = '+' sexp sexp
sfunabs = '\' var '.' sexp
sfunapp = sexp sexp
sh = 'SH' stype hexp
sif0 = 'if0' sexp sexp sexp
sm = 'SM' stype mexp
snum = num
ssub = '-' sexp sexp
svar = var
swrong = 'wrong' string
2 REDUCTION
Execute the sham program to reduce expressions.
2.1 ARGUMENTS
The single argument specifies the language of the outermost expression. Valid values are 'haskell', 'ml', and 'scheme' (case sensitive).
2.2 INPUT/OUTPUT
The reduction program reads from standard input and writes to standard output. Use the echo command to create expression files in the command line, or use cat to read expressions from files. Use command line pipes to connect standard output from echo and cat to standard input of the reduction program.
2.3 ERRORS
Parsing, type checking, and reduction errors are printed to standard error. Currently, the error code is always zero. Currently, there is no help or version command line option.
3 CORRECTNESS
Comprehensive tests are in the works, but incomplete. Currently, correctness is not guaranteed.
4 COMPILATION
Install Macports 1.8.2 and the developer tools on Mac OS X 10.6.2. Install the ports ghc 6.10.4 and hs-mtl 1.1.0.2 using Macports. Execute make in the project directory. Haskell modules can be interpreted using ghci (part of the ghc port).