[REBOL] Re: Updates to hof script
From: jan::skibinski::sympatico::ca at: 16-Nov-2002 7:26
Hi Gabriele,
> I think the problem here is with the notation. Most people is not
> familiar with it, and it is not intuitive enough to be able to
> guess what it means without someone telling you.
>
> >> Mapping two series via binary function:
> >> ((a -+ b -+ c) -+ [a] -+ [b] -+ [c])
>
> Would a notation such as:
>
> ((a b -> c) [a] [b] -> [c])
>
> be more easy to understand by a casual reader?
>
I hope you don't mean: using -> instead of the -+.
That was the intention to start with but Rebol would
not let me use it. So the latter is just a poor imitation
of the former.
This cosmetic change aside, there is a problem
with your suggestion. More complex types, which
I hope to avoid at least at this stage, need
so-called type constructors, such as 'Ket, as in:
Scalar -> Ket a -> Ket a
Abusing the definition: the type constructor is
sort of a container with a generic type 'a inside.
There could be therefore:
Ket integer, Ket logic or even Ket (Ket tuple)
Some other type constructors would need more
than one type variables, such as
Tree a b
To be frank, when representing series I should
have used such notation perhaps to be more
specific about kind of series I have in mind,
such as:
Block a, Paren a, etc.
Instead, I simplified everything to [a]. Not
very strict, but at least showing the structure:
[a] for vectors, [[a]] for vectors of vectors, etc.
So we need some kind of separators, that would
tell us where the types start and stop.
Parens will not do, because they are needed
for separating embedded functions.
Generally accepted separator is ->, because
it shows the direction "from to", as in
length? :: [a] -> integer
which reads:
'Length? has a type from a series 'a to integer.
You feed it a series of any generic type
and it responds with an integer.
Whenever you see an arrow, this tells you that
you deal with a function. If there is no arrow
this mean just a simple data.
A function can be completely unapplied,
partially applied and completely applied, as in:
:+
:+ 2
:+ 2 3
The corresponding types would be
:+ :: integer -> integer -> integer
"+ has type from integer to integer to integer"
:+ 2 :: integer -> integer
"+ 2 is a function that has type from integer to integer"
:+ 2 3 :: integer
"+ 2 3 has type integer"
During this process you just remove one type
and one arrow at each step, whenever you add one more
argument.
Oh boy, I should go back to bed for another hour or so.
Did not have much sleep last night.
Best wishes,
Jan