axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] Map


From: Antoine Hersen
Subject: Re: [Axiom-developer] Map
Date: Sun, 2 Apr 2006 03:40:03 -0700

Hello,

I am using Aldor since Friday and indeed the error message are way more helpful.
And the documentation a blessing.

I think most of my confusion come from the fact that all my functional
programing experience come from Ocaml.

If you are not familiar with Ocaml. It is also strongly typed but with
a much simpler abstract data type system. And so it is capable of
making sound inference on type with a constraint solver.

So yes I kinda expected it to get all the type right for me...
Especially since I did all my previous works in inputs files.

What confused me to is that there is some limited inferring.

But I have learned my lesson no type inference. And ")show SomeType"
is my best friend.

All my map trouble come from the fact that I tried to use map to change type

map( A -> B , List A ) -> List B
but the definition is always

map( R -> R, % ) -> %

Has an exercise I could create a new domain :

Map(A:Type, B:Type): with {
        map: (A->B , List A) -> List B ;
} == add {
        map( f:(A->B), la :List A):List B == {
                [ f i for i in la ] }
}

map( A->B, List A )$Map(A,B)

or maybe create a function

map(A:Type, B:Type, f:A->B, la: List A) : List B ==
     [f i for i in la] ;

Anyway sorry for the vague question.

And thanks you for orienting me to Aldor

Regards,
Antoine Hersen


On 4/1/06, Ralf Hemmecke <address@hidden> wrote:
> On 04/01/2006 09:15 PM, Antoine Hersen wrote:
> > Sorry,
> >
> > Here it is http://wiki.axiom-developer.org/SandBoxSpad
> >
> > If I try to use the map the compilation fail
> >
> > I am used to Ocaml who do a terrific job at inferring type( which are
> > more simple) and I have trouble figuring out where to add type
> > information.
>
> Actually, I don't understand you Antoine.
> [degree i for i in a]
> does the same job as your map stuff. And it works.
>
> Second, please start using Aldor. I don't understand why you insist on
> using SPAD. Take for example
>
> (i) +-> degree i
>
> You put this (anonymous) function without giving types. So you rely on
> what the compiler thinks is appropriate in your case.
>
> What can the compiler do if it sees
>
> map(f, a)
>
> where f is the (untyped) function from above.
> It figures out the type of a, that is clearly "List P".
> OK, it also sees that List(P) provides a function
> map: (P -> P, %) -> %
> Now the compiler must somehow try to fit your anonymous untyped function
> to the type P->P. Which is actually impossible, since there is no
> degree: P->P. The compiler must complain!!!
> The bad thing is only that the error message does not say much about the
> reason if you are (like me) unfamiliar with that output.
>
> Well, anyway, use Aldor and enjoy better error messages.
>
> Ralf
>
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]