Hi Jakob,

The simple answer is that -> is for functions that can be translated to the database and ~> is for functions that cannot (including user-defined recursive functions - a select few built-in recursive functions such as map can be translated to the database).

In fact, things are a bit more complicated than that, as both arrows have hidden polymorphic effect variables.

Links has an effect system based on row types. Any arrow can be annotated with an arbitrary row of effects, though currently only two effects have any meaning: the 'wild' effect indicates code that *cannot* be translated to SQL and the 'hear:A' effect indicates code that can receive messages of type A.

  (A) {E}-> B denotes the type of functions from A to B with effects E

Syntactic sugar:

       (A) -e-> B == (A) { |e }-> B
         (A) -> B == (A) -e-> B,  where e is fresh
                (i.e. it appears nowhere else in the type)
      (A) {E}~> B == (A) {wild; E}-> B
       (A) ~e~> B == (A) {wild | e}-> B
         (A) ~> B == (A) ~e~> B,  where e is fresh
  (A) {:C; E}~> B == (A) {hear:A; E}~> B

For first-order functions you can usually get away with -> or ~>. For higher-order functions you often need -e-> or ~e~>. For instance, map has type:

  ((a) -e-> b, [a]) -e-> [b]

as the effects of mapping a function f over a list xs must be the same as the effects of f.

Sam

On 07/11/11 09:50, Jakob Praher wrote:
[..]
BTW: When should the arrow ~>  be used over ->  ? Both can have
effects, so I am not sure.  (From the visual representation I would
say one is maps to and another is leads to ?)

Cheers, Jakob
_______________________________________________
links-users mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/links-users

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Reply via email to