On 09/25/2017 07:45 PM, Waldek Hebisch wrote:
> - there are things like Union("OK", "failed", "all_bad") in the
>   codebase.  Of course those unions can not be replaced by Maybe.

You union looks pretty much like Aldor's Enumeration type and as long as
there is no XXX type with additional tags, your above union is not a use
case for Maybe.

>   But most current uses of Union(XXX, "failed") potentially may
>   need expansion to more cases.  With unions such expansion is
>   quite easy, with Maybe it is more work
> - how well Maybe works with compiler.  Spad compiler has
>   special knowledge about unions.  ATM it has no such knowledge
>   about Maybe.  It would be nice if Maybe worked well without
>   any hardcoded treatment from compiler, but I expect that
>   better code will require some compiler tweaks.
> - Unions are part of exported interfaces.  A lot of user code
>   would need to adapt...

As far as I understood from the discussion up to now, then Maybe can be
realized by the representation of the respective type and "failed" is
represented by a new (unique) LISP symbol.

Waldek, your use cases above actually speak about the union of a type T
with a finite number of additional tags. If Maybe can be realised by the
representation of T together with one additional GENSYM, why wouldn't
that idea work in the same way as you suggested for the Maybe domain?

Sorry, I don't know how the compiler internals work, but I get the
impression, that the compiler could treat Union(T, "failed") in exactly
the way that you suggested for Maybe. Similarly, Union(T, "tag1",
"tag2") generates code so that for t: T, the coercion (embedding)
u := t::Union(T, "tag1", "tag2") is basically a no-op and just tells the
compiler that u has a different type than t, but u uses the same storage
as t.

Is this possible? If yes, then all of your above concerns would be
solved and we wouldn't need Maybe at all.

Ralf


-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to