[comp.sys.transputer] functional language available.

cspw@quagga.ru.ac.za (Peter Wentworth) (12/26/90)

I have a small functional language, RUFL (The Rhodes University
Functional Language) which is yet another variation on the Miranda
theme.  The alpha release is now available.    

The implementation is via an intermediate SECD-like fixed machine
code (called FLFM code), which can either be compiled down to native
code for the target machine, or it can be interpreted. 

There are three versions currently available:  an IBM PC version,
a VAX VMS version, and a T800 transputer version running under Helios.

The native PC version generates *.obj files directly.  These must be
linked with the Turbo C v2.0, or Turbo C++ 1.0 libraries, so you'll
need to already have one of these products installed. 

The native T800 version generates transputer assembler code which
must be assembled and linked with the Helios C libraries.  

The native VAX version generates assembler mnemonics which must be
assembled via MACRO (together with the macro definitions), and linked
with the standard VAX libraries.   The linking is slow on this
implementation.

In addition to producing native code or assembler code, the compiler
can also generate the intermediate FLFM code directly.  An interpreter
which will execute this intermediate code is provided on all three
systems.

The compiler is a traditional command-line system which produces ouput
objects from input files.  (i.e. is not like the ML system which
allows you line-at-a-time compilation and interpretation.)


Performance  (Times in secs)
----------------------------

                    8Mz AT       20Mz T800     VAX 6000
                         (Native code versions)

8 Queens              61.7         37.8          19.8
Nfib 24 *              5.2          3.1           1.8
Nfibr 24 **          249.0         10.6           5.2
100 Primes             1.8          1.3           1.0

                    8Mz AT       20MZ T800     VAX 6000
                         (Interpreted versions)

8 Queens             430.0        278.7          88.9
Nfib 24 *             70.8         47.0          13.5
Nfibr 24 **          379.0         89.5          27.6
100 Primes            11.9          7.6           2.6

* On the AT version, nfib 24 is too big for our 15-bit integers, so
we compute Nfib 19 eight times, and Nfib 18 five times instead.
(This is how the nfib 24 tree expands.)

** No 80287 coprocessor available for the real numbers on the AT.

 
Ordering Info
-------------

My only distribution medium is 5-1/4" IBM floppy diskettes.  I hope
to get an anonymous FTP distribution point soon, but we cannot FTP from
or to our site yet.

The package consists of the compiler (executables only), the interpreter
(sources and executables) and a number of examples.

Two technical documents are provided:
  A 110 pg. introductory course to functional programming using RUFL,
  A  14 pg. document about the FLFM intermediate machine. 

The system is shareware, but if you want us to do the hard work of
packaging and posting document and diskettes, the $30 shareware
donation is required up front.  Cheques or money orders should be made
payable to Rhodes University.

PLEASE SAY WHICH VERSION YOU REQUIRE:
   PC 
   VAX
   HELIOS T800
 
Order from:
  The Secretary
  Department of Computer Science
  Rhodes University
  Grahamstown 6140
  South Africa.


E-Mail Contact info
-------------------
My internet address is
 
   cspw@quagga.ru.ac.za

If that does not work, we have a backup route via fidonet:
   
   cspw.quagga@f4.n494.z5.fidonet.org
 
 
APPENDIX:  Example code
-----------------------
The four programs described in the performance timings are
given here, mainly to give some idea of the syntax of RUFL.
One other example which uses type constructors is given too.

Type declarations are mandatory for all global level
functions.  Most lexical conventions (operator names,
indentation and offside rule, capitalized/lowercase
identifiers for Types/Dataconstructors/Function names,
strings, reals, ints) follow the Haskell conventions.  The
type system is Milner-type parametric polymorphism (i.e. no
Haskell 'derived' types, and no overloading except some
special built-in cases for + -, etc.)
 
---------------------------------------------------------------
-- Nfib.
import Library

dec nfib :: Int => Int
 
def nfib n = 1,                             if n < 2
           = 1 + nfib(n - 1) + nfib(n - 2), otherwise

def main =  writeInt (nfib 24)
--------------------------------------------------------------- 
-- Nfibr.
import Library  
dec nfib :: Real => Real
 
def nfib n = 1.0,                                 if n < 2.0
           = 1.0 + nfib(n - 1.0) + nfib(n - 2.0), otherwise

def main =  writeReal (nfib 24.0) 
---------------------------------------------------------------
-- Primes.
import Library

dec primes :: [Int]
dec sieve  :: [Int] => [Int]

def primes      = sieve [2 .. ]
def sieve (p:x) = p : sieve [ n | n <- x, n % p != 0]

def main = 
        writeInts (take 100 primes)
--------------------------------------------------------------- 
-- Queens.
import Library

type Board = [Int]

dec queens  :: Int => [Board]
dec safe    :: Int => Board => Int => Bool

-- Is q safe on b hdist cols away? 
def safe q []    hdist = True
    safe q (a:x) hdist = False,    if q == a
                       = False,    if q-hdist == a
                       = False,    if q+hdist == a
                       = safe q x (hdist + 1),  otherwise

def queens bdSize = queens1 bdSize
                     where
                        queens1 0 =  [[]]
                        queens1 n = [q:b | b <- queens1(n-1)
                                         | q <- [1..bdSize]
                                         , safe q b 1]

def main = 
     let q = (queens 8)
     in
       seq 
         writelnString "Searching for positions of queens  ..."
         forcemap writelnInts q
         writeString "Number of solutions "
         writeInt (length q)
---------------------------------------------------------------
-- Some binary tree examples.

import Library

data Tree alpha = Empty
                | Leaf alpha
                | Node (Tree alpha) alpha (Tree alpha)

dec sumtree :: Tree Int -> Int

def sumtree Empty        = 0
    sumtree (Leaf n)     = n
    sumtree (Node l v r) = sumtree l + v + sumtree r
 
dec flatten :: Tree alpha -> [alpha]

def flatten Empty        = []
    flatten (Leaf n)     = [n]
    flatten (Node l v r) = flatten l ++ [v] ++ flatten r
 
 



 
 
 
-- 
EP Wentworth - Dept. of Computer Science - Rhodes University - Grahamstown.
cspw@quagga.ru.ac.za  
  (If that fails, try cspw.quagga@f4.n494.z5.fidonet.org)