%export rep_bool_to_num rep_bottom rep_first rep_fix
        || iff-then-else syntax support functions
        rep_iff rep_then rep_else rep_then_type rep_else_type
         rep_showthen_type rep_showelse_type
        || end of iff-then-else syntax support functions
        rep_proj1of1 rep_proj1of2 rep_proj2of2
        rep_proj1of3 rep_proj2of3 rep_proj3of3
        rep_proj12of3 rep_proj13of3 rep_proj23of3
        rep_unzip2

|| USEFUL EXTENSIONS TO THE STANDARD ENVIRONMENT: IMPLEMENTATION MODULE
|| For user-level descriptions of functions, see definition module.

rep_bool_to_num :: bool -> num
  rep_bool_to_num True  = 1
  rep_bool_to_num False = 0

rep_bottom :: *
  rep_bottom = rep_bottom

rep_first :: num -> [*] -> [*]
  rep_first = take

rep_fix :: (* -> *) -> *
  rep_fix f = f (rep_fix f)

|| iff-then-else syntax support functions

rep_then_type ::= THEN
rep_else_type ::= ELSE

rep_iff :: bool -> rep_then_type -> * -> rep_else_type -> * -> *
  rep_iff True  THEN x ELSE y = x
  rep_iff False THEN x ELSE y = y

rep_then :: rep_then_type
  rep_then = THEN

rep_else :: rep_else_type
  rep_else = ELSE

rep_showthen_type :: rep_then_type -> [char]
  rep_showthen_type THEN = "then (used in \"iff..then..else..\")"

rep_showelse_type :: rep_else_type -> [char]
  rep_showelse_type ELSE = "else (used in \"iff..then..else..\")"

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

rep_proj1of1 :: * -> *
  rep_proj1of1 = id

rep_proj1of2 :: (*, **) -> *
  rep_proj1of2 (a, b) = a

rep_proj2of2 :: (*, **) -> **
  rep_proj2of2 (a, b) = b

rep_proj1of3 :: (*, **, ***) -> *
  rep_proj1of3 (a, b, c) = a

rep_proj2of3 :: (*, **, ***) -> **
  rep_proj2of3 (a, b, c) = b

rep_proj3of3 :: (*, **, ***) -> ***
  rep_proj3of3 (a, b, c) = c

rep_proj12of3 :: (*, **, ***) -> (*, **)
  rep_proj12of3 (a, b, c) = (a, b)

rep_proj13of3 :: (*, **, ***) -> (*, ***)
  rep_proj13of3 (a, b, c) = (a, c)

rep_proj23of3 :: (*, **, ***) -> (**, ***)
  rep_proj23of3 (a, b, c) = (b, c)


rep_unzip2 :: [(*,**)] -> ([*],[**])
  rep_unzip2 [] = ([],[])
  rep_unzip2 ((a,b):rest) = (a:rest1, b:rest2)
                            where
                            (rest1, rest2) = rep_unzip2 rest
