Search code examples
shen

Shen tutorial example for typed function does not compile


I just discovered the Shen language and so I installed it under my debian linux as an SBCL build and started to work through the Shen in 15 minutes tutorial.

I made it up to the point, where you turn on type checking, using

Shen, copyright (C) 2010-2015 Mark Tarver
www.shenlanguage.org, Shen 22.2
running under Common Lisp, implementation: SBCL
port 3.0.3 ported by Mark Tarver, Robert Koeninger and Bruno Deferrari

(tc +)
(define total
  (list number) --> number
  [] -> 0
  [X | Y] -> (+ X (total Y)))

Entering the above sequence in the repl or storing it into a .shen file and then (load "in15min.shen") yields the unexpected:

[list number] is not a legitimate constructor

and trying to evaluate it anyway, I get a type error as output.

So here my questions:

  • Is the tutorial outdated and the syntax has changed?
  • Or do I do something wrong?

Solution

  • The rendering from the style sheet has missed {}s.

        (define total
        {(list number) --> number}
        [] -> 0
        [X | Y] -> (+ X (total Y)))
    

    is right.

    Mark