Browse thread
[Caml-list] Is arrow programming impossible in ocaml?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@o...> |
| Subject: | Re: [Caml-list] Is arrow programming impossible in ocaml? |
On Tue, 2003-10-14 at 09:59, Nick Name wrote:
> Hi all, I am trying to work on a project where I need ocaml efficiency
> type ('a,'b) t = 'a -> 'b
>
> let rec arr f = f
>
> let a = arr (fun x -> x)
> -
>
> and "a" is typed like '_a -> '_a , where I would like it to be typed 'a
> -> 'a.
>
> Does anyone think I have other possibilities in writing that kind of
> higher-order combinator based code, or is it impossible?
It works fine with an annotation:
# type ('a,'b) t = 'a -> 'b
let rec arr f = f
let a = arr (fun x -> x)
;;
type ('a, 'b) t = 'a -> 'b
val arr : 'a -> 'a = <fun>
val a : '_a -> '_a = <fun>
# let a:('a,'a) t = (fun x -> x)
;;
val a : ('a, 'a) t = <fun>
# a 1;;
- : int = 1
# a 1.1;;
- : float = 1.1
#
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners