Q: the Shen type system, and (put ...) and (get ...)

110 views
Skip to first unread message

Antti Ylikoski

unread,
Dec 20, 2016, 3:38:37 PM12/20/16
to Shen

There is one feature about Shen which is not clear to me.

After one switches the type checker (tc +) on, the property setting
and getting functions (put ...) and (get ...) generate a type error.

Below is a sample run.

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

antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/ShenANN $ ./Shen

Shen, copyright (C) 2010-2015 Mark Tarver
running under Common Lisp, implementation: CLisp
port 1.9 ported by Mark Tarver


(0-) (put andy surname "Ylikoski")
"Ylikoski"

(1-) (put andy education dr)
dr

(2-) (put andy age 56)
56

(3-) (get andy age)
56

(4-) (tc +)
true

(5+) (put antti surname "Ylikoski")
type error


(6+) (put antti education dr)
type error


(7+) (put antti age 56)
type error


(8+) (tc -)
false : boolean

(9-) (QUIT)
antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/ShenANN $

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

What might be happening?

yours, A. J. Y.
Helsinki, Finland, the E.U.


Mark Thom

unread,
Dec 20, 2016, 4:33:12 PM12/20/16
to Shen
It's because there are no default rules for property lists.

You can add your own easily enough, as I do in this blog entry:

http://mthom.github.io/blog/2016/10/10/poor-man-s-dynamic-dispatch-with-types-in-shen/

Antti Ylikoski

unread,
Dec 20, 2016, 9:48:15 PM12/20/16
to Shen

Thank you very much, but I'm not expert enough to make this one
actually work.

Could someone more knowledgeable help?

I tried the below mentioned one:

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

\\ AJY 2016-12-21


(datatype property-types


______________________________
put: (unit --> unit --> unit --> unit);


______________________________
get: (unit --> unit --> unit);

)

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

It will load, but it does not work:

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

antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/types $ ./Shen

Shen, copyright (C) 2010-2015 Mark Tarver
running under Common Lisp, implementation: CLisp
port 1.9 ported by Mark Tarver


(0-) (tc +)
true

(1+) (load "prop.shen")

type#property-types : symbol
run time: 0.06799999997019768 secs

typechecked in 30 inferences
loaded : symbol

(2+) (put antti education dr)
type error


(3+) (get antti education)
type error


(4+) (tc -)
false : boolean

(5-) (QUIT)
antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/types $ 

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

Some wise help would be very much appreciated.

yours, A. J. Y.
E.U.

Mark Tarver

unread,
Dec 22, 2016, 9:26:34 AM12/22/16
to Shen
Your axioms require antti, education etc. to be of type unit.

Mark

Antti Ylikoski

unread,
Dec 22, 2016, 2:09:25 PM12/22/16
to Shen

Yes; But I understood that the type "unit" indicates that there is
there no type information attached to the objects.

IOW, I attempted to make a LISP-style typeless put/get arrangement.

I also tried the below:

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


\\ AJY 2016-12-21


(datatype property-types


______________________________
put: (symbol --> symbol --> symbol --> symbol);


______________________________
get: (symbol --> symbol --> symbol);

)

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

but I still will get the type error:

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

antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/types $ ./Shen

Shen, copyright (C) 2010-2015 Mark Tarver
running under Common Lisp, implementation: CLisp
port 1.9 ported by Mark Tarver


(0-) (tc +)
true

(1+) (load "prop2.shen")

type#property-types : symbol
run time: 0.06799999997019768 secs

typechecked in 30 inferences
loaded : symbol

(2+) (put antti age middle)
type error


(3+) (get antti age)
type error


(4+) (tc -)
false : boolean

(5-) (QUIT)
antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/types $

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

yours, AJY

Mark Tarver

unread,
Dec 22, 2016, 2:29:53 PM12/22/16
to qil...@googlegroups.com
Afraid not!

Mark

--
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.

Antti Ylikoski

unread,
Dec 23, 2016, 7:29:43 AM12/23/16
to Shen
Mark:

Could you be more specific about that statement?

I mean that if I repeatedly will get errors, which you cannot reproduce, then it is fairly certain that my hardware/software platform is flawed.

I feel that we can be certain that Shen is OK.  But I have previously been suspecting the GNU/Linux/CLisp platform.

yours, AJY
The E.U.
Afraid not!

Mark

To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.

Bruno Deferrari

unread,
Dec 23, 2016, 8:06:37 AM12/23/16
to qil...@googlegroups.com
On Fri, Dec 23, 2016 at 2:08 AM, Antti Ylikoski
<antti.y...@gmail.com> wrote:
> Mark:
>
> Could you be more specific about that statement?
>
> I mean that if I repeatedly will get errors, which you cannot reproduce,
> then it is fairly certain that my hardware/software platform is flawed.
>
> I feel that we can be certain that Shen is OK. But I have previously been
> suspecting the GNU/Linux/CLisp platform.
>
> yours, AJY
> The E.U.
>

Your Shen install is fine, it is just that the way you are trying to
type put/get (which only take the number of arguments you are using
because of macros) will not work. Try this:

(datatype property-type-symbols
Value : symbol;
__________________
(put Var Prop Value) : symbol;

__________________
(get Var Prop) : symbol;)

You can enable 'spy' mode to see what the type checking is doing with
(spy +) before executing the type expression to be typechecked, try
before executing a get or put expression after having used your type
definition and hit enter until it fails and you will see why your
version doesn't work (see what "put : (symbol --> symbol --> symbol
--> symbol)" is trying to be unified with).
--
BD

Antti Ylikoski

unread,
Dec 23, 2016, 12:33:38 PM12/23/16
to Shen

I solved the problem, with some meditations.

The below mentioned works:

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

\\
\\ AJY and Bruno Deferrari 2016-12-23
\\
\\ After Dr Tarver's solution to an earlier problem


(datatype unit
 _________
A : (mode unit -);)


(datatype properties

  Var: unit;
  Prop: unit;
  Value: unit;

__________________
  (put Var Prop Value) : unit;

  __________________
  (get Var Prop) : unit;

)

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

Below is a sample run:

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

antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/types $ srrepl
Loading.... Completed in 7.65 seconds.

Shen, copyright (C) 2010-2015 Mark Tarver
running under Ruby, implementation: ruby 2.3.1
port 0.15.1 ported by Greg Spurrier


(0-) (tc +)
true

(1+) (load "props.shen")

type#unit : symbol
type#properties : symbol
run time: 0.423755407333374 secs

typechecked in 42 inferences
loaded : symbol

(2+) (put antti surname "Ylikoski")
"Ylikoski" : unit

(3+) (put antti country finland)
finland : unit

(4+) (put antti age 56)
56 : unit

(5+) (get antti age)
56 : unit

(6+) (get antti surname)
"Ylikoski" : unit

(7+) (get antti country)
finland : unit

(8+) (quit)
antti@antti-HP-Compaq-dc7100-SFF-PE271ET ~/types $

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

I recall one British individual over the Internet IRC who said to me,

"Bad workman, blames his tools".

Once again we can see that Shen is reliable, and it is OK.

yours, AJY
E.U.

PS.  This only is a temporary solution; Mark once said something to
the effect that disabling the type checking like this is like an atom
bomb.  I shall devise something more clever for this problem.

Mark Tarver

unread,
Dec 25, 2016, 6:44:54 AM12/25/16
to Shen
You can actually reduce this to

(datatype properties

  ____________________________
  (put Var Prop Value) : unit;

  ______________________
  (get Var Prop) : unit;)

which is shorter and equivalent since you say that everything is a unit.  However this allows you to write

(put a b (+ 3 c)) 

This might be better.

(datatype properties

  ____________________________
  put : (A --> B --> C --> C);

  _________________________
  get : (A --> B --> unit);)

bw

Mark

Mark Tarver

unread,
Dec 25, 2016, 6:53:31 AM12/25/16
to Shen
Sorry - forgot put and get are macro driven - try.

(datatype properties

  X : A; Y : B; Z : C;
  ____________________________
  (put X Y Z (value *property-vector*)) : C;

  X : A; Y : B;
  _____________
  (get X Y (value *property-vector*)) : unit;)

Mark
  
  
Mark

Mark Tarver

unread,
Dec 25, 2016, 7:57:43 AM12/25/16
to Shen
BTW follow Bruno's advice - (spy +) is the best way to view the cogitations of the Shen type checker.

Mark
Reply all
Reply to author
Forward
0 new messages