[Ur] Ur/Web vs Haskell
Ron de Bruijn
rmbruijn at gmail.com
Thu Oct 13 05:58:51 EDT 2011
Hi,
Please compare the two following programs and their outputs:
Haskell:
data Some a = None
| Some a
f def x = case x of
(Some x) -> x
None -> def
ghci> f 2 (Some 1) => 1
Ur/Web:
fun myget default o =
case o of
| (Some x) => x
| _ => default
returns an error message showing all the types in the module, of which 99.9% is
completely unrelated, which approaches 100% as the size of the module grows to
infinity. It can even take a minute or so for large modules to print the dancing
error message.
Perhaps there is some exotic type at which this piece of text could _also_ be
interpreted, but without a type-annotation this should just work and use the
same derived type as in Haskell. I.e., as if the user had written:
fun myget [a] (default:a) (o:option a) : a = ...
If some user absolutely wants to have another type he/she can give an explicit
type, but in the common case of just defining a 'quick' function he/she should
absolutely not. I would also be interested in seeing an example of another type
which could be given to this definition.
I also believe that this translates to the fact that Ur definitions and modules
are typically much larger than their Haskell equivalents; the programming style
is completely different, because introducing a function in Haskell is cheap (no
type-annotations required) and introducing a function in Ur/Web is not.
--
Best regards,
Ron de Bruijn
More information about the Ur
mailing list