On 2/24/21 8:45 PM, Waldek Hebisch wrote:
On Wed, Feb 24, 2021 at 06:12:45PM +0800, Qian Yun wrote:
On 2/24/21 2:00 AM, Waldek Hebisch wrote:
On Tue, Feb 23, 2021 at 10:03:25AM +0800, Qian Yun wrote:
I would like FriCAS to move away from "failed" and choose Haskell style
"Maybe" instead. This topic has been discussed before, I wonder if
Waldek's opinion has changed.
Up to now I saw nothing to change my opinion. To clarify, automatic
"lifting" of operations for T to say Maybe(T) would be useful.
Why would that be useful? I think explicit type conversion is
better than implicit/automatic type conversion.
It is really about automatically generating boilerplate code.
If you do not want what Haskell offers and prefer to write
code by hand, then I do not understand why you want Maybe.
I'm sorry, what boilerplate code are we talking about?
Do our current "failed" approach have boilerplate code?
We can perfectly use "Maybe" to replace "failed" with
almost zero boilerplate code. (Although there are
functional style to use "Maybe", instead of current
imperative style usage of "failed".)
But up to now I do not see workable proposal how to implement
such lifting and what exact rules should be. Without viable
strategy for implementing extra functionality change to
Maybe from my point of view looks pointless.
To put is differenly, I view compiler, language and coding idioms
as a whole. Clearly many language constructs need compiler
support. Coding idioms depend on language and compiler.
New coding idiom my be quite useful without new support.
But IMO usefulness of Maybe depends very much on features
of Haskell and Haskell compiler. While it may be
possible to have useful effect is quite different way,
mere change of notation does not look useful.
I think in Haskell, "Maybe" is purely implemented as library
and requires zero compiler support.
I admit that my understandin of Maybe is rather shallow,
so please correct me if I am wrong. However I think:
- Maybe is implementd by library
- Maybe depends on language/compiler support is sense that
similar code in other language would _not_ work, and
without optimizations in current Haskell compiler
Maybe would significanly slow down programs
I'm almost sure that "Maybe" doesn't need special Haskell
compiler treatment, a user implemented "Maybe" can achieve
similar performance. Because "Maybe" is such a simple
structure, the compiler can optimize it right away, no
need to special treat it at all.
On the other hand, in FriCAS compiler, "failed" is everywhere.
So I believe using "Maybe" to replace "failed" would be an
improvement, not only aesthetically, but also practically.
- Qian
This is similar to fact that many Spad codes depend on
parametrized types, without such types code can not
be translated in simple way.
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/35d9f77d-a338-c496-629f-fd3ba423ec13%40gmail.com.