Note as to the philosophy of the Shen type system

81 views
Skip to first unread message

Antti Ylikoski

unread,
Aug 13, 2017, 8:40:34 AM8/13/17
to Shen

I have, a hopefully constructive, note as to the type system
philosophy of Shen.

In a Shen program with the (tc +) on, global variables need to be
declared as the below example:

--------------------------------------------------

\\ Here we set the # of towns as a parameter, for obvious reasons
\\

(datatype towns

________________________
(value *TOWNS*) : number;

)

--------------------------------------------------

But, on the contrary, so to speak, local variables in a (let ...)
expression have no type information attached.

What does this mean as for the philosophy of the Shen type system?

yours, Dr AJY
Finland, the EU


Bruno Deferrari

unread,
Aug 13, 2017, 10:06:27 AM8/13/17
to qil...@googlegroups.com
On Sun, Aug 13, 2017 at 9:19 AM, Antti Ylikoski <antti.y...@gmail.com> wrote:

I have, a hopefully constructive, note as to the type system
philosophy of Shen.

In a Shen program with the (tc +) on, global variables need to be
declared as the below example:

--------------------------------------------------

\\ Here we set the # of towns as a parameter, for obvious reasons
\\

(datatype towns

________________________
(value *TOWNS*) : number;

)

--------------------------------------------------

But, on the contrary, so to speak, local variables in a (let ...)
expression have no type information attached.


They do have information attached (as long as they are in a typed context), you just don't have to do it explicitly because there is enough information in the context for Shen to infer their type automatically. If they didn't have type information attached the typechecker wouldn't be able to validate expressions that use those variables.

When compiling from Shen to Klambda code, if `(optimise +)` is enabled, the compiler will annotate variables with their inferred type so that the underlying platform can take advantage of it (but none do so far afaik):

(0-) (optimise +)
true

(1-) (tc +)
true

(2+) (define test { number --> number --> number } X Y -> (let Z (+ X Y) (* Z Z)))
test : (number --> (number --> number))

(3+) (ps test)
[defun test [V1364 V1365] [let Z [+ [type V1364 number] [type V1365 number]] [* [type Z number] [type Z number]]]] : (list unit)

 You can use those annotations themselves if you feel like doing so:

(4+) (type 1 string)
type error


What does this mean as for the philosophy of the Shen type system?

yours, Dr AJY
Finland, the EU


--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+unsubscribe@googlegroups.com.
To post to this group, send email to qil...@googlegroups.com.
Visit this group at https://groups.google.com/group/qilang.
For more options, visit https://groups.google.com/d/optout.



--
BD
Reply all
Reply to author
Forward
0 new messages