function type signature notation

machine readable function type signature syntax



expressions separated by ->

input -> output

multiple arguments

expressions separated by a single space:

a b c -> d

alternative data-types

expressions separated by a slash: /

a b/c/d -> e
a port/string/integer -> e

alternative names

expressions separated by a colon: :

a b:c:d -> e

data-types always come first. data-type:helpful-alternative-name:another-alternative-name

a port:input-port:source -> e

optional arguments

enclosed in square brackets: []

a [b c] -> d


none or many consecutive occurences of an expression. expression followed by a space character and three dots: ...

a b ... c ... -> d

function-name specification

identifier followed by a space character and two colons: ::

name :: a b -> c

procedures, dictionaries

a function signature enclosed with curly brackets: { }

unlimited nesting

{a ->}
procedure:{a ... -> list:b}
hashtable:{key -> value}

lists, vectors, pairs, and more

using scheme read syntax

  • example list: (a (b c))
  • example vector: #(a #(b c))
  • example using both: (integer #(char ...))

multiline signatures

two colons followed by a newline, optionally followed by one or multiple input expressions per line separated by newlines, a line with only a ->, optionally followed by output expression separated by newlines, ending with end-of-string or two successive newline characters


line outside of signature


list any [symbol:exclusive/inclusive] -> (list:left list:right)
procedure:{any -> boolean} procedure:{list:matched-elements -> list:replacements} list:source -> list
procedure:{alist:header procedure:fold-lines:{string:line any:result procedure:next:{any:result -> any} -> any} result -> any}
procedure:{header port result ->} any port [string]


sph-lib includes a reader and writer