Does Haskell or ML support code like the following?
Note that I get these inferences even though the variables were not instantiated, and the functions were not implemented.
>> a : p;
a : p
>> b : q;
b : q
>> c : p -> q -> r;
c : p -> q -> r
>> d = (c a);
d : q -> r
>> f : r -> s;
f : r -> s
>> e = lambda(x) (f(d x));
e : q -> s
Note that I get these inferences even though the variables were not instantiated, and the functions were not implemented.
(no subject)
Date: 2008-10-17 10:13 pm (UTC)signature STUFF = sig
type p
type q
type r
val a : p
val b : q
val c : p -> q -> r
val d : q -> r
val f : r -> s
end
functor Funct(X: STUFF) = struct
open X
val e : fn x => f(d x)
end
(no subject)
Date: 2008-10-17 10:14 pm (UTC)(no subject)
Date: 2008-10-17 10:29 pm (UTC)(no subject)
Date: 2008-10-17 10:47 pm (UTC)signature STUFF = sig
type p
type q
type r
type s
val a : p
val b : q
val c : p -> q -> r
val d : q -> r
val f : r -> s
end
functor Funct(X: STUFF) = struct
open X
val e = fn x => f(d x)
end;;
If you put that into the REPL loop you should get what you're looking for. Or you can put it, without the ;;, into "foo.sml" and then say use "foo.sml";; from inside the REPL loop. This is SML, not OCaml, by the way.
(no subject)
Date: 2008-10-17 10:50 pm (UTC)(no subject)
Date: 2008-10-17 11:02 pm (UTC)type p
type q
type r
type s
val a : p
val b : q
val c : p -> q -> r
val d : q -> r
val f : r -> s
end
module Funct(X: STUFF) = struct
include X
let e = fun x -> f(d x)
end;;
(no subject)
Date: 2008-10-18 10:03 am (UTC)if I now want to instantiate/implement some of these variables/functions, would I use the constructor STUFF, passing in p,q,r,etc? What if I only want to instantiate some of them?
(no subject)
Date: 2008-10-18 01:48 am (UTC)(no subject)
Date: 2008-10-18 08:33 pm (UTC)