ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.00.1 http://bit.ly/UHeZyT | http://www.ocaml-lang.org
<ng__> i back again :D, today i made this simple program and I was thinking : is it possible using lists in this code?
<thizanne> ng__: what would you want to use lists for ?
<thizanne> if your goal is printing your stars, you don't need them
<ng__> wanted another way to solve this ;D
<ng__> thizanne, but would it be possible using lists?
avsm has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 260 seconds]
ulfdoz_ is now known as ulfdoz
<thizanne> yes ng__
<thizanne> but it's not useful
<ng__> thizanne, how?
<thizanne> it woud also possible with red-black tress
<thizanne> but there is no point in doing this :)
<thizanne> ng__: instead of printing yur sars, youcould put them in lists
<thizanne> and print the list element-wise at the end
<ng__> seems a bit strange, but I liked to try....
<thizanne> it's definitely strange
<thizanne> it's artificial
<thizanne> if you want to train with lists, you should do another thing
<thizanne> but be careful, you can't just "translate from C" if you want to use lists in OCaml
<ng__> what?
<thizanne> first, learn about lists :D
<ng__> yes ;D
<ng__> second?
<thizanne> second, you could recode the functions (approximately in this order) is_empty, length, nth, rev, ( @ ), map, fold_left, fold_right, map using fold_right
<thizanne> and then the other functions of the List module
<thizanne> (some of them being included in my previous order, just look at the function who do approximately the same things)
<ng__> omg... i'm reconsidering if I should try do this ;D
<ng__> *to
Neros_ has joined #ocaml
<thizanne> when you will be used to lists, you will find it very easy
Neros has quit [Ping timeout: 255 seconds]
<thizanne> you don't have to do all this in one step, it's only a suggestion about how you could train
<thizanne> in fact if you're able to code map, fold_right and map using fold_right, you will probably have well understood how it works
<thizanne> but coding the others will likely help you
<thizanne> well, on these words, good night
<ng__> thizanne, thanks, I'll try! if I have questions I come here, I have to read more about lists :D
<ng__> ;D
Arc_Koen has joined #ocaml
avsm has quit [Quit: Leaving.]
oriba has quit [Quit: oriba]
Arc_Koen has quit [Quit: and happy assassination]
Arc_Koen has joined #ocaml
Arc_Koen has quit [Client Quit]
Arc_Koen has joined #ocaml
Arc_Koen has quit [Client Quit]
Arc_Koen has joined #ocaml
Arc_Koen has quit [Client Quit]
madroach has quit [Ping timeout: 244 seconds]
Jeaye has quit [*.net *.split]
emias has quit [*.net *.split]
wormphlegm has quit [*.net *.split]
TDJACR has quit [*.net *.split]
elixey has quit [*.net *.split]
madroach has joined #ocaml
Jeaye has joined #ocaml
emias has joined #ocaml
wormphlegm has joined #ocaml
TDJACR has joined #ocaml
elixey has joined #ocaml
sepp2k has joined #ocaml
tufisi has quit [Read error: Operation timed out]
ng__ has quit [Quit: Leaving]
Progster has joined #ocaml
dwmw2_gone has quit [Remote host closed the connection]
jamii has quit [Ping timeout: 245 seconds]
Progster has quit [Ping timeout: 246 seconds]
cdidd has quit [Ping timeout: 244 seconds]
dwmw2_gone has joined #ocaml
ankit9 has joined #ocaml
sg has joined #ocaml
<sg> (q.head.prev <- Some n)
<sg> Error: The record field label prev belongs to the type 'a dqnode but is mixed here with labels of type 'b dqnode option
<sg> the types do match
<sg> so i am quite confused
avsm has joined #ocaml
leoncamel has joined #ocaml
<leoncamel> hey. Here is a newbie question: I wrote a simple file test.ml, which open external module Llvm. When I try to build it with ocamlbuild by command "ocamlbuild -use-ocamlfind -libs llvm test.native", it prompt a error : "Error: Unbound module Llvm". But, it does work with this command "ocamlfind ocamlc -linkpkg -package llvm test.ml -o test".
<leoncamel> My question is, how can I make ocamlbuild behave like the command with *ocamlfind* ? Thanks.
ben_zen has quit [Ping timeout: 246 seconds]
sg has quit [Ping timeout: 245 seconds]
<adrien> leoncamel: -libs is not for the ocamlfind support
<adrien> create a _tags file, and add a clause for package(llvm)
ankit9_ has joined #ocaml
ankit9 has quit [Ping timeout: 260 seconds]
rwmjones has quit [Read error: Operation timed out]
ontologiae has joined #ocaml
Yoric has quit [Quit: Instantbird 1.3a1pre -- http://www.instantbird.com]
Yoric has joined #ocaml
ontologiae has quit [Ping timeout: 245 seconds]
jave has quit [Ping timeout: 240 seconds]
sepp2k has quit [Remote host closed the connection]
jave has joined #ocaml
tufisi has joined #ocaml
Snark has joined #ocaml
avsm has quit [Quit: Leaving.]
ankit9_ has quit [Quit: Leaving]
hkBst has joined #ocaml
ontologiae has joined #ocaml
ocp has joined #ocaml
ocp has quit [Client Quit]
thomasga has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Jeaye has quit [Quit: WeeChat 0.3.9]
ocp has joined #ocaml
ontologiae has quit [Ping timeout: 246 seconds]
djcoin has joined #ocaml
hcarty has quit [Ping timeout: 256 seconds]
hcarty has joined #ocaml
ftrvxmtrx has joined #ocaml
pango has quit [Remote host closed the connection]
ontologiae has joined #ocaml
GnomeStoleMyBike has joined #ocaml
pango has joined #ocaml
mcclurmc1 has joined #ocaml
ocp has quit [Ping timeout: 245 seconds]
Neros_ has quit [Ping timeout: 245 seconds]
Kakadu has joined #ocaml
<GnomeStoleMyBike> Hi all
caligula__ has quit [Ping timeout: 246 seconds]
ollehar has joined #ocaml
ollehar has left #ocaml []
rwmjones has joined #ocaml
caligula__ has joined #ocaml
<Kakadu> hey
caligula_ has joined #ocaml
caligula__ has quit [Ping timeout: 260 seconds]
<orbitz> hi
beckerb has joined #ocaml
testcocoon has quit [Quit: Coyote finally caught me]
ontologiae has quit [Ping timeout: 272 seconds]
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 260 seconds]
testcocoon has joined #ocaml
hto has quit [Ping timeout: 244 seconds]
hto has joined #ocaml
wahnfried has quit [Ping timeout: 260 seconds]
emmanuelux has quit [Ping timeout: 246 seconds]
_andre has joined #ocaml
djcoin has quit [Ping timeout: 240 seconds]
eikke has joined #ocaml
cdidd has joined #ocaml
trotro has joined #ocaml
cago has joined #ocaml
leoncamel has quit [Remote host closed the connection]
ocp has joined #ocaml
leoncamel has joined #ocaml
emmanuelux has joined #ocaml
emmanuelux has quit [Ping timeout: 245 seconds]
ontologiae has joined #ocaml
iago has joined #ocaml
mjonsson has joined #ocaml
fraggle_laptop has quit [Remote host closed the connection]
fraggle_laptop has joined #ocaml
cdidd has quit [Ping timeout: 248 seconds]
mjonsson has quit [Remote host closed the connection]
BiDOrD_ has joined #ocaml
eikke has quit [Ping timeout: 248 seconds]
BiDOrD has quit [Ping timeout: 265 seconds]
<hcarty> thomasga: './opam64 init' doesn't work for me on an Ubuntu 12.04 64bit install. It tells me 'File /home/hcarty/.opam/compilers/system.comp does not exist'
mcclurmc1 has quit [Ping timeout: 265 seconds]
<hcarty> thomasga: Does the opam64 binary still require an existing OCaml installation?
<thomasga> when you do 'opam64 init' ?
<thomasga> normally it shouldn't require a preexisting installation
<thomasga> although it has not been very tested
<thomasga> opam init 3.12.1
<thomasga> you have to specify which version you want to install
eikke has joined #ocaml
<hcarty> thomasga: './opam64 init 3.12.1' sits and doesn't appear to do anything
<thomasga> opam —verbose init 3.12.1
<thomasga> I guess it is busy installing the compiler
<hcarty> thomasga: 'Cannot download 3.12.1/urls.txt, please check your connection settings.'
<hcarty> With '--verbose' I get a curl status display that never shows any progress
<hcarty> thomasga: Nothing gets downloaded from what I can see. top doesn't show any activity either.
<hcarty> thomasga: For reference, I'm trying to use the instructions here - http://opam.ocamlpro.com/doc/Quick_Install.html
<thomasga> damn, I'm looking at the code and the bit for giving a compiler version to install on init disappeared ...
<thomasga> so sorry no, it won't work yet
<thomasga> I'll fix it soon
<hcarty> thomasga: Ok thanks. I'll try again after it's been updated :-)
ollehar has joined #ocaml
f[x] has quit [Ping timeout: 248 seconds]
ocp1 has joined #ocaml
ocp has quit [Ping timeout: 255 seconds]
f[x] has joined #ocaml
<thomasga> hcarty: actually 'opam init -comp 3.12.1' should work
djcoin has joined #ocaml
<metadave> anyone interested in a Riak OCaml client? http://metadave.github.com/riak-ocaml-client/
Kakadu has quit [Quit: Konversation terminated!]
ollehar has quit [Ping timeout: 240 seconds]
<hcarty> thomasga: 'File /home/hcarty/.opam/compilers/3.12.1.comp does not exist'
<hcarty> thomasga: That's the error I get after running './opam64 init -comp 3.12.1'
mcclurmc1 has joined #ocaml
<thomasga> damn ...
<thomasga> well, this is broken, I'll fix that before 1.0
<thomasga> to be honest I thing you are the first trying to use opam without ocaml
<thomasga> s/g/k
ocp1 has quit [Ping timeout: 240 seconds]
cdidd has joined #ocaml
ng__ has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
jamii has joined #ocaml
<hcarty> thomasga: That's not surprising. I'm curious to see if opam is useful in its current state on a system without OCaml.
<hcarty> thomasga: Among other things, it gives me some idea of where ocamlbrew will/would fit in the OCaml ecosystem once opam is released in a stable state.
<hcarty> thomasga: I'm also trying to evaluate opam + ? vs ocamlbrew + (odb and/or opam) vs GODI + (odb and/or opam) for my own use.
uselpa has joined #ocaml
hkBst has quit [Quit: Konversation terminated!]
Neros has joined #ocaml
ollehar has joined #ocaml
uselpa has quit [Remote host closed the connection]
ollehar has quit [Quit: ollehar]
cago has quit [Quit: Leaving.]
Kakadu has joined #ocaml
<vbmithr> Hi
<vbmithr> I’ve got an ocaml question :)
<CmrPantoufle> go ahead
<vbmithr> I’d like to understand what caml does when I do:
<vbmithr> let ($) f g = f g
Neros has quit [Ping timeout: 248 seconds]
<vbmithr> print_char $ Char.chr $ 32+1
<vbmithr> This does not work, surprisingly for me
<CmrPantoufle> print_char (Char.chr (32+1))
<CmrPantoufle> Ah
<CmrPantoufle> Well :
<CmrPantoufle> val ( $ ) : ('a -> 'b) -> 'a -> 'b = <fun>
<thelema> vbmithr: associativity
<thelema> you want something that is right associative, but ocaml is left associative.
<CmrPantoufle> Anyway there is a composition operator in OCaml 4, so no need for $ anymore I believe
<thelema> vbmithr: try using `let (|>) x f = f x`
<thelema> CmrPantoufle: there's no standard syntax for this composition operator, just a builtin to make it efficient
<CmrPantoufle> thelema: you are talking about @@ ?
<thelema> external (|>) x f : ... = "%revapply"
<CmrPantoufle> Ok
<thelema> 32 + 1 |> Char.chr |> print_char
<thelema> because ocaml is eager, pipelining this way makes clear the order of operations
<CmrPantoufle> Yes.
<vbmithr> external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply";;
<vbmithr> Where are they available ?
<thelema> vbmithr: that's all that you need. Core and batteries provide this, although core uses the operator |!
<vbmithr> ok
mcclurmc1 has quit [Quit: Leaving.]
mcclurmc1 has joined #ocaml
<CmrPantoufle> Is there a way to have typeclasses in OCaml ?
<Qrntz> thelema, are there plans on using v4.00's compiler primitives in Batteries any soon?
<thelema> CmrPantoufle: two options: 1) objects and 2) modules.
<Qrntz> I'm aware of the backward compatibility reasons against that, but still
<thelema> Qrntz: Just need to do some pre-processing to make it happen at compile time.
<thelema> Qrntz: patches welcome. no camlp4.
<Qrntz> ah, alright then
<tizoc> hello
<thelema> tizoc: hello
<tizoc> when compiling a program (using ocamlopt) that includes Core and Async I'm getting very big binaries (13mb), is there any way to obtain smaller binaries? (I suppose what is happening here is that the whole Core library is being included even if I don't use most of it)
<The_third_man> k
<thelema> tizoc: don't 'open Core.Std' and directly access the modules you use.
<tizoc> thelema: ok cool, if I don't reference a module directly (or indirectly) it will not be part of the final binary then?
Cyanure has joined #ocaml
<thelema> tizoc: yes.
<tizoc> perfect
<tizoc> thelema: thanks
<thelema> tizoc: no problem.
avsm has joined #ocaml
tufisi has quit [Ping timeout: 246 seconds]
tufisi has joined #ocaml
ftrvxmtrx has joined #ocaml
Neros has joined #ocaml
ftrvxmtrx_ has joined #ocaml
<tizoc> oh well, most modules in Async itself open Core.Std
<thelema> it's a tough problem, there's been some suggestions that the compiler be able to optimize out values that don't affect the rest of the program, but it's difficult to do this, as value definitions often have side effects.
ftrvxmtrx has quit [Ping timeout: 272 seconds]
ng__ has quit [Quit: Leaving]
mcclurmc1 has quit [Ping timeout: 255 seconds]
<tizoc> http://www.algo-prog.info/ocaml_for_pic/web/index.php?id=OCamlClean just found this, but it is for bytecode programs
<thelema> yes, afaik there's nothing for native code programs
<thelema> once a module is referenced, all its code will be included in the final binary.
<thelema> s/module/compilation unit/
<tizoc> it reduced the bytecode version from 34M to 3.3M :)
<flux> sounds like a similar feature would be useful in the ocaml compiler as well
<thelema> interesting...
<thelema> I was not aware of this
<trotro> dead code should not compile :)
<tizoc> heh
<thelema> trotro: how to have libraries with separate compilation, then?
<trotro> it's a special case
<trotro> but when a main function is present
<trotro> dead code should be checked
<flux> so when producing executables
<trotro> yes
<flux> there are no 'main' functions in ocaml..
<trotro> yes, but you understand me :)
GnomeStoleMyBike has quit [Ping timeout: 256 seconds]
<flux> seems to make use of compiler libraries that thing
<flux> did someone try it, does it work?-)
djcoin has quit [Ping timeout: 252 seconds]
eikke has quit [Ping timeout: 248 seconds]
leoncamel has quit [Ping timeout: 245 seconds]
<pippijn> wmeyer: we can now generate menhir input
djcoin has joined #ocaml
Jeaye has joined #ocaml
tufisi has quit [Read error: Operation timed out]
Kalculus has joined #ocaml
<Kalculus> I have module CharMap = Map.Make(Char);; I also have a function CharMap.key list -> bool CharMap.t list = <fun> Can you give me an example of what I would give to this function to call it?
<flux> foo ['a']
<flux> CharMap.key = Char.t
trotro has quit [Quit: Leaving]
<flux> hmm, actually why doesn't this fact show in the generated manual page for Map.Make?
tufisi has joined #ocaml
<wmeyer> pippijn: great! I'll finish up the bits on the ast inference now
<wmeyer> pippijn: I saw the commit
<Kalculus> hmm.. let me see...
<Kalculus> flux: thank you
ontologiae has quit [Ping timeout: 264 seconds]
kmels has joined #ocaml
<Kalculus> hmm.. what does that function return. What exactly is a bool CharMap.t list ?
GnomeStoleMyBike has joined #ocaml
<thelema> Kalculus: a list of (char -> bool) mappings
<Kalculus> ah. let me try thanks
<thelema> (not functions, just maps)
<kmels> hello, I'm trying to install a package called proglangUtils with ocamlfind. Output I get: "ocamlfind install proglangUtils". I tried downloading the source (http://proglang.informatik.uni-freiburg.de/JavaScript/#proglangUtils) but it seems it has compilation errors. anyone familiar with the package?
<kmels> the output is "ocamlfind: The META file is missing"
<adrien> is there a file named "META" somewhere?
<adrien> why are you trying to install with ocamlfind specifically?
<kmels> there is, in the source code
<adrien> why do you install manually?
<kmels> because the instructions say it so. I want to test JSConTest (https://github.com/heidegger/JSConTest)
<kmels> adrien, manually is "tar xzvf ...; cd proglangUtils; make" ?
<adrien> and after that?
<adrien> you're talking about two issues at the same time, it's hard to follow
<adrien> well, quite a lot of things missing here; ask the authors directly I guess
<kmels> will do, thanks
iago has quit [Ping timeout: 256 seconds]
emmanuelux has joined #ocaml
emmanuelux has quit [Read error: Connection reset by peer]
<Kalculus> how exactly do I use a bool CharMap.t list ? can I print it out or get a specific element? I've tried CharMap.find 'A' x;; and some other stuff, but I just keep getting errors
<adrien> like?
hiredman has left #ocaml []
<Kalculus> List.find 'A' x;; List.find true x;; CharMap.is_empty x;;
<thelema> match x with [] -> () | m1::_ -> print_char(CharMap.find 'A' m1)
<thelema> oops, can't print_char a bool
<Kalculus> What is "match x with [] -> () | m1::_" doing to x to get m1?
<thelema> pattern matching.
<thelema> match [1; 2; 3; 4] with h::t -> (* h is 1, t is [2;3;4] *) Some h | [] -> None
<thelema> also `match [1;2;3;4] with a::b::c::d::[] -> (* a is 1, b is 2 ... *)`
<thelema> destructuring pattern matching
<thelema> giving names to parts of a structure when it matches a pattern
trotro has joined #ocaml
<Kalculus> hmm.. let me try to see if i get this
avsm has quit [Ping timeout: 256 seconds]
iago has joined #ocaml
uselpa has joined #ocaml
avsm has joined #ocaml
avsm has quit [Client Quit]
tac has joined #ocaml
tac-tics has quit [Ping timeout: 245 seconds]
uselpa has quit [Remote host closed the connection]
<Kalculus> thelema: thanks. i think i'm starting to get this
<thelema> Kalculus: you're welcome
iago has quit [Ping timeout: 272 seconds]
rwmjones has quit [Read error: Operation timed out]
emmanuelux has joined #ocaml
rwmjones has joined #ocaml
ocp has joined #ocaml
<Qrntz> is there any way to generally match an external function of a certain type in a module signature without hardcoding its C function name and/or fool the compiler into thinking it's a regular function?
<Qrntz> a crude example of what all that gibberish means in terms of where I want to get is https://gist.github.com/a01a94a0ae8eeb161664
<thelema> the module signature doesn't need the name, although it'll be a bit less efficient if it doesn't.
<thelema> type a type b val unsafe_get : a -> int -> b
ng__ has joined #ocaml
<Qrntz> thelema, it does work with concrete types, but I'm aiming at a generic functor that would apply to (e. g.) both String and Array
<thelema> how are you planning on using this?
<thelema> i.e. if you had a module of type WITH_UNSAFE_OPS, how could you use an unsafe operation?
<thelema> let x = M.unsafe_get [|7;8;9|] 3 in
<thelema> what type would x have
<thelema> I guess you'd want "let x : int = ..."
beckerb has quit [Quit: Konversation terminated!]
SanderM has joined #ocaml
<thelema> You can get closer to type safety by using a bunch of 'with's to clarify the module type
<thelema> but the problem is that what you want requires a more powerful type system than OCaml has; something about higher-kindedness
<thelema> i.e. you want `val unsafe_get : 'a 'b -> int -> 'a`
<Qrntz> well, my basic aim was something like «let module String = Unsafe(String) in let s = "foo" in s.(0) (* unsafe operation instead of safe due to the fact „s.(x)“ is equal to „String.get s x“ and String.get is now String.unsafe_get *)»
<thelema> for some specific 'b, like array or string
<Qrntz> indeed
<thelema> let module String = struct include String get = unsafe_get set = unsafe_set end
<thelema> alternately, just compile with argument -unsafe to turn off bounds checking
<Qrntz> -unsafe turns it off for a whole compilation unit though
<thelema> true.
<Qrntz> I wanted to have a somewhat elegant way to locally make shorthands unsafe, but oh well
<thelema> how about the first?
<thelema> module UnsafeString = ...
<Qrntz> the first is actually what I am using at the moment
<thelema> let module String = UnsafeString in ...
<Qrntz> yes, exactly
<Qrntz> but it has to be defined for each module manually
cdidd has quit [Remote host closed the connection]
iago has joined #ocaml
<Qrntz> well, alright then, I'll keep doing that until someone invents a better type system
<Qrntz> thanks for your attention
<thelema> you're welcome.
<thelema> Qrntz: I think ocaml doesn't use a higher-kinded type system because they're undecidable.
<Qrntz> thelema, are there languages that use one?
<thelema> haskell
<companion_cube> it's an extension, on haskell, isn't it?
<thelema> not sure
<thelema> I've just heard that haskell has higher-kinded types
<companion_cube> I think you need to active 2RankTypes, or stuff like this
<companion_cube> Rank2Types, or this kind of things
<companion_cube> again because of the undecidability
<thelema> this makes sense
<bitbckt> Scala, as well, but they're not as concerned about silly things like soundness.
<companion_cube> scala is unsound?!
<thelema> companion_cube: so I've heard too
<thomasga> any idea how to use the type: 'a t = (module Set.S with type elt = 'a) ?
<Qrntz> is higher-kindedness the reason for both Haskell and Scala having Turing complete type systems?
<thomasga> for instance, how to write the function cardinal: 'a t -> t ?
<thelema> thomasga: let intset : int t = (module Set.Make(Int)) ?
<thomasga> I've tried different solutions, but none seem to work
<thomasga> well, yes, I was more thinking about how to use the polymorphic version
<thomasga> 'a t -> int sorry
<thelema> ('a t) isn't a set, it's a set module
<thomasga> yes sorry
<thelema> although, hmm, I'm not sure what the type of cardinal would be...
rwmjones has quit [Ping timeout: 255 seconds]
<thomasga> something which takes the set module + a set and returns an int
<companion_cube> thelema: so it should be cardinal: ('a t).t -> int
<companion_cube> (with the correct syntax)
<thelema> (type elt) elt t -> ... (var ...) -> int
<thelema> hmm, how to get at the first parameter to specify the type of the second...
<companion_cube> my personal advice: use objects, not first-order modules ;)
<thomasga> well, that's not possible if you want to use external libraries
<thomasga> (for instance ocamlgraph)
<companion_cube> ocamlgraph uses first-order modules ? :(
<companion_cube> I thought it was older than 3.12
<thomasga> no, it uses modules and functor
<thelema> thomasga: ah, you can't. because of scoping of type constructors.
<thelema> # let cardinal (type elt) m s = let module S = (val m : Set.S with type elt = elt) in S.cardinal s;;
<thelema> # Error: This expression has type S.t but an expression was expected of type
<thelema> S.t
<thelema> The type constructor S.t would escape its scope
<companion_cube> thelema: ah, that's ok then, you can mix objects and modules
<thomasga> companion_cube: so how do you define a polymorhic version of a graph, using objects ?
<companion_cube> with classes, I suppose
<companion_cube> and class types
<thomasga> thelema: I've tried with type ('a,'b) t = (module Set.S with type elt = 'a and type t = 'b)
<thomasga> and size: ('a,'b) t -> 'b -> int
<thomasga> but doesn't get more luck
<thelema> yes, the problem is that you have to unpack the module S in order to use it, and the unpacked S.t can't be used as the function parameter.
<thelema> and it won't be able to unify with 'b
<thelema> because 'b is something different from S.* for any S
<thomasga> hum, well in this case the type 'a doesn't escape very far
<thelema> or maybe I'm making things up
<thelema> 'a isn't the problem, the problem is how to type the second parameter to size.
iago has quit [Ping timeout: 246 seconds]
<thelema> your ('a, 'b) t is close, trying to force S.t = b, but because how values in modules are typed...
<thomasga> ok, I'll go with another path then
<thomasga> (but not with objects)
<thomasga> thx anyway
<thelema> # let cardinal (type t) m s = let module S = (val m : Set.S with type t = t) in S.cardinal s;;
<thelema> val cardinal : (module Batteries.Set.S with type t = 'a) -> 'a -> int = <fun>
<thelema> hmm, maybe I'm wrong.
<thomasga> well I managed to define a function size
<thomasga> but then I wasn't able to use it :-)
<thomasga> (as in your example)
<companion_cube> objects are cool :p
<thelema> # module IS = Set.Make(Int);;
<thelema> # cardinal (module IS) (IS.singleton 3);;
<thelema> - : int = 1
<thelema> thomasga: works for me.
rwmjones has joined #ocaml
_andre has quit [Quit: leaving]
<thomasga> ha I see
<thomasga> you've constrained t instead of elt
<thomasga> hum
<thelema> yes
<thomasga> I don't see how to use it in practice :-)
<thelema> If you want to do something like to_list, you'll probably have to constrain both
<thomasga> type 'a t = (module Set with type t = 'a)
<thelema> no, back to your ('a, 'b) t
<thomasga> well if you have two parameters, you have to constraint them in the function body, so your solution don't work
<thomasga> reminder: I don't want to write Set.S in the function body, I want to use 'a t (or ('a,'b) t)
<thomasga> (to constraint the parameter functions for instance)
<thomasga> function paramaters
<thelema> # let mem (type t) (type elt) m s x = let module S = (val m : Set.S with type t = t and type elt = elt) in S.mem s x;;
<thelema> val mem : (module Set.S with type elt = 'a and type t = 'b) -> 'a -> 'b -> bool = <fun>
<thomasga> ha yes, actually it works!
<thomasga> cool
<thomasga> thx
<thomasga> I'll continue to play with that :-)
<thelema> no problem. I learned something too
kmels has quit [Read error: No route to host]
<thelema> what's your solution?
<thelema> for the using the type alias?
<thelema> # let mem (type t) (type elt) m s x = let module S = (val m : ('a, 'b) t) in S.mem s x;;
<thelema> Syntax error: ')' expected, the highlighted '(' might be unmatched
kmels has joined #ocaml
<thelema> I get wierd () errors in my attempt
<thelema> ah, mis-using t
<thomasga> I'm constraining the parameters
<thelema> let mem (type set) (type elt) m s x = let module S = (val m : (elt, set) t) in S.mem s x;;
<thomasga> let mem (type t) (type elt) m (s:t) (x:elt) = …. (val m) ...
<thelema> ah, that's nice.
<Kalculus> Is there an easy way to convert a Map's values to a list? Is Map.fold the best way? I basically just want to do a String.concat on the Map values
<thelema> Kalculus: yes, fold is best
<_habnabit> Kalculus, it's easier with batteries!
<thelema> _habnabit: quite true
<Kalculus> haha.. ok.. now my problem is i'm not sure how to use fold. hmm.. let's see.. let map_values_to_list = Map.fold (fun k v -> would k be the key and v be the value?
<thelema> yes
<thelema> let map_values_to_list map = Map.fold (fun _k v acc -> v :: acc) map []
rwmjones has quit [Ping timeout: 255 seconds]
SanderM has quit [Quit: I need to take it elsewhere.]
rwmjones has joined #ocaml
Yoric has quit [Ping timeout: 246 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
<Kalculus> ah ok. i see.. i didn't know i could put the 3rd parameter acc there thanks
<thelema> yes, map folds have 2 parameters + an accumulator
NaCl has quit [Ping timeout: 268 seconds]
djcoin has quit [Quit: WeeChat 0.3.7]
ontologiae has joined #ocaml
thomasga has quit [Quit: Leaving.]
thomasga has joined #ocaml
thomasga has quit [Client Quit]
avsm1 has joined #ocaml
Snark has quit [Ping timeout: 256 seconds]
eikke has joined #ocaml
ocp has left #ocaml []
sgnb` has joined #ocaml
NaCl has joined #ocaml
NaCl has quit [Changing host]
NaCl has joined #ocaml
sgnb has quit [Remote host closed the connection]
iago has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
ontologi1e has joined #ocaml
Cyanure has quit [Remote host closed the connection]
Submarine has quit [Ping timeout: 240 seconds]
ontologiae has quit [Ping timeout: 268 seconds]
gnuvince has joined #ocaml
eikke has quit [Ping timeout: 260 seconds]
ontologi1e has quit [Ping timeout: 256 seconds]
ng__ has quit [Quit: Leaving]
jamii has quit [Read error: Operation timed out]
trotro has quit [Quit: Leaving]
kmels has quit [Ping timeout: 260 seconds]
Kalculus has quit [Quit: -1]
emmanuelux has quit [Remote host closed the connection]
GnomeStoleMyBike has quit [Ping timeout: 252 seconds]
ontologiae has joined #ocaml
mjonsson has joined #ocaml
ontologiae has quit [Ping timeout: 256 seconds]
mfp has quit [Ping timeout: 246 seconds]
tufisi has quit [Quit: ...]
mfp has joined #ocaml