axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] Unions in Spad


From: Stephen Wilson
Subject: Re: [Axiom-developer] Unions in Spad
Date: 13 Jul 2007 03:12:01 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Hi Ralf,

This is late in the night for me, so please forgive the terse
response.


Ralf Hemmecke <address@hidden> writes:

> =--- union-test.spad ----
> > )abbrev domain BAR Bar
> > Bar() : Exp == Impl where
> >    Exp == with
> >      inj : Integer -> %
> >      inj : String -> %
> >      prj : % -> Integer
> >    Impl == add
> >      Rep := Union(tag1: Integer, tag1: String)
> >      inj (n : Integer) : % == [n]
> >      inj (s : String) : % == [s]
> >      prj p == (p::Rep).tag1
> 
> Stephen, have you ever thought about the difference between Rep and %?

Yes. 

> The type of [n] would be Rep, since there is no function
> 
>    bracket: Integer -> %

Perhaps you are thinking in terms of Aldor?  In Spad, we have:

   1) -> )sh Union(tag1: Integer, tag1: String)
    Union(tag1: Integer,tag1: String) is a domain constructor.
   ------------------------------- Operations --------------------------------

    ?=? : (%,%) -> Boolean                ?case? : (%,tag1) -> Boolean
    ?case? : (%,tag1) -> Boolean          coerce : % -> OutputForm
    construct : Integer -> %              construct : String -> %
    ?.? : (%,tag1) -> Integer             ?.? : (%,tag1) -> String

Here, `bracket' is known as `construct', and as you can see, there are
two such operations. 

> 
> so if you write
> 
>    inj (n : Integer) : % == [n]
> 
> as above, that should be a type error.

On the contrary, it is a call to:
   
    construct : Integer -> %

which is well typed.


Take care,
Steve





reply via email to

[Prev in Thread] Current Thread [Next in Thread]