On Thu, Sep 28, 2017 at 10:26 AM, Bill Page <[email protected]> wrote:
> On 27 September 2017 at 19:05, oldk1331 <[email protected]> wrote:
>> The point of 'wrap/unwrap' or something like that is to avoid to
>> specify type. Like you can use
>>
>> x := wrap y
>>
>> instead of
>>
>> x : Maybe A_VERY_LONG_TYPE := coerce y
>>
>
> That is very much against the spirit of the SPAD language which was
> designed to support complete source and target polymorphism of
> operators. I do not think it is desirable to avoid specify types -
> even when they are long, e.g. use macros to abbreviate if you must.
You can also write those long types when using 'wrap'. It's not
against type annotation. We should also have the ability of
type inference, which is impossible for 'coerce' (because there
are too many).
However your suggestion is against another FriCAS spirit:
the ability to avoid type in interpreter. You can simply right
'wrap 1', but 'coerce 1' has so many different meanings.
> If I were to accept your argument this would imply that we should try
> to reduce this sort of polymorphism in many other existing uses of
> coerce/retract and in the case of other similar operators.
It does not hurt to have synonym, I support to have both 'coerce'
and 'wrap'.
>> And you can use 'coerce' this way, but I prefer 'wrap', because
>> usually there are many 'coerce' for a type, but there's only one 'wrap'.
>>
>
> I do not like the idea that there is only one 'wrap'.
I'm not saying "only wrap, no coerce", I'm saying 'wrap' has only
one meaning, that's "create a Maybe".
>> As for 'retract', because 'retractIfCan' should return a Maybe,
>> that makes Maybe more fundamental than RetractableTo.
>
> ?? RetractableTo is a category constructor, Maybe is a domain. Maybe
> is not more fundamental than RetractableTo. I do not see any problem
> that in the case of Maybe retractIfCan would become an identity.
If Maybe R has RetractableTo R, I find this signature a little funny:
retractIfCan : Maybe R -> Maybe R
But it won't hurt to have RetractableTo/retract, but follow the
same reasoning above, I (and others) should prefer 'unwrap'
over 'retract'.
>> And for the same reason, one can use 'unwrap' to avoid to
>> specify type.
>>
>> If you don't like the name of 'wrap/unwrap', there has to be
>> replacement other than 'coerce/retract', so what do you suggest?
>> (Like Haskell's 'just/fromJust'?)
>>
>
> I like the Axiom/FriCAS convention of using polymorphism to emphasize
> the generic algebraic properties of operators. So I do not like to
> replace coerce/retract with some other names in specific cases. And
> although they are not obviously dual, changing coerce/retract to some
> other pair of names throughout FriCAS does not seem desirable either.
>
> Bill.
OK, let me persuade you in this way, Maybe is a Monad, and so is List.
Do you wish to have these signature ONLY for List
(and every possible Monad):
coerce : S -> List S
retract : List S -> S
For List, the signature 'S -> List S' is named 'list', and
the signature 'List S -> S' is named 'first'.
--
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.