%export bool_to_num bottom first fix
        || iff-then-else syntax support functions
        iff then else then_type else_type
        || end of iff-then-else syntax support functions
        proj1of1 proj1of2 proj2of2
        proj1of3 proj2of3 proj3of3 proj12of3 proj13of3 proj23of3
        unzip2

|| USEFUL EXTENSIONS TO THE STANDARD ENVIRONMENT: DEFINITION MODULE

|| bool_to_num converts True, False to 1, 0 respectively
bool_to_num :: bool -> num

|| bottom is the (polymorphic) least element of any type
bottom :: *

|| first n gives the first n elements (or as many as possible) of a list
first :: num -> [*] -> [*]

|| fix takes in a function and returns its least fixed-point.
fix :: (* -> *) -> *

|| iff-then-else syntax support functions
|| These allow the syntax
||
||  iff <bool> then <*> else <*>
||
|| which will be of type * and will have the expected value.
|| WARNING: because iff, then, else are not genuine keywords, more
||  brackets are needed than you might expect, eg,
||
||   iff 2+2=4 then 10*10 else 20*20
||
||  will need to be rendered as
||
||   iff (2+2=4) then (10*10) else (20*20).

abstype then_type, else_type
with

     || the keywords

     iff   :: bool -> then_type -> * -> else_type -> * -> *
     then  :: then_type
     else  :: else_type

     || printable representations of "then" and "else"

     showthen_type :: then_type -> [char]
     showelse_type :: else_type -> [char]

|| end of iff-then-else syntax support functions

|| projXYZofN gives positions (X,Y,Z) of an N-tuple
||  eg, proj13of3 (a,b,c) = (a,c)

proj1of1  :: * -> *

proj1of2  :: (*, **) -> *
proj2of2  :: (*, **) -> **

proj1of3  :: (*, **, ***) -> *
proj2of3  :: (*, **, ***) -> **
proj3of3  :: (*, **, ***) -> ***
proj12of3 :: (*, **, ***) -> (*,  **)
proj13of3 :: (*, **, ***) -> (*,  ***)
proj23of3 :: (*, **, ***) -> (**, ***)


|| unzip2 unzips a list of pairs into a pair of lists
unzip2 :: [(*,**)] -> ([*],[**])














|| MINIMALIST SYNTACTIC HOOKS TO IMPLEMENTATION MODULE
|| [ignore these if you're not interested in the implementation]

%include "stdenv.mod"

bool_to_num = rep_bool_to_num

bottom = rep_bottom

first = rep_first

fix = rep_fix

|| iff-then-else syntax support functions
iff           = rep_iff
then          = rep_then
else          = rep_else
then_type    == rep_then_type
else_type    == rep_else_type
showthen_type = rep_showthen_type
showelse_type = rep_showelse_type
|| end of iff-then-else syntax support functions

proj1of1  = rep_proj1of1
proj1of2  = rep_proj1of2
proj2of2  = rep_proj2of2
proj1of3  = rep_proj1of3
proj2of3  = rep_proj2of3
proj3of3  = rep_proj3of3
proj12of3 = rep_proj12of3
proj13of3 = rep_proj13of3
proj23of3 = rep_proj23of3

unzip2 = rep_unzip2
