<pippijn>
# let open Const_eval in let open Ast in parse_int LIT_Dec "123";;
<pippijn>
Error: Reference to undefined global `Const_eval'
lorilan has quit [Quit: Quitte]
mjonsson has joined #ocaml
Tobu has joined #ocaml
oriba has quit [Quit: oriba]
philtor has quit [Ping timeout: 240 seconds]
wtetzner has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
andreypopp has joined #ocaml
KDr2 has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
Tobu has joined #ocaml
fantasticsid has joined #ocaml
<adrien>
p
<adrien>
Ptival: thanks
<thelema_>
pippijn: let me be more specific: I don't like "in" at the start of lines that have something else on them.
<thelema_>
pippijn: and the error means that the compiler doesn't know what Const_eval is, maybe you're not compiling in the right order; no const_eval.cmx?
everyonemines has joined #ocaml
Drup has quit [Quit: Leaving.]
Tobu has quit [Ping timeout: 272 seconds]
emmanuelux has joined #ocaml
Tobu has joined #ocaml
andreypopp has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
philtor has joined #ocaml
fantasticsid has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
mjonsson has quit [Remote host closed the connection]
Tobu has quit [Ping timeout: 260 seconds]
philtor has quit [Ping timeout: 245 seconds]
Ori_B has joined #ocaml
Ori_B has left #ocaml []
Tobu has joined #ocaml
emmanuelux has quit [Ping timeout: 245 seconds]
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
datkin has joined #ocaml
andreypopp has quit [Ping timeout: 245 seconds]
datkin has quit [Ping timeout: 255 seconds]
everyonemines has quit [Quit: Leaving.]
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
EmmanuelOga has joined #ocaml
EmmanuelOga has quit [Ping timeout: 244 seconds]
mort___ has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
MaskRay has quit [Remote host closed the connection]
Tobu has joined #ocaml
edwin has joined #ocaml
letrec has joined #ocaml
<mrvn>
does ocaml have GADT now?
<adrien>
yes, in SVN/3.13
Snark has joined #ocaml
<flux>
are there real-life examples other than parsers around for it?-)
* mrvn
only has 3.12.1-2
<adrien>
I think so but I don't know where they are :-)
<mrvn>
I want to try using GADT with phantom types to define functions that mutate the phantom type.
<adrien>
thelema would probably tell you to build a test prefix with 3.13-pre using odb.ml
<ousado>
mutate a type?
<mrvn>
'Foo t -> 'Bar t | 'Blub t -> 'Blubber t
<iZsh>
I'm still not sure what GADT are good for :)
Cyanure has joined #ocaml
edwin has quit [Quit: Leaving.]
edwin has joined #ocaml
edwin has quit [Disconnected by services]
edwin1 has joined #ocaml
edwin1 is now known as edwin
edwin has quit [Remote host closed the connection]
edwin has joined #ocaml
mort___ has quit [Quit: Leaving.]
<ousado>
iZish: you can use them to tag a type with an other type. AFAIU they are limited dependent types that can take types as parameters only, as opposed to dependent types, that can also take values as type parameters
<ousado>
one example for the latter would be statically tagging an array or list with its length - so you could e.g. index the array safely without checking bounds first
<mrvn>
ousado: you are describing phantom types
<ousado>
which one of the two do you mean?
<mrvn>
except maybe for the values as type part. but do gadt allow them?
Cyanure has quit [Ping timeout: 260 seconds]
<ousado>
no GADTs don't allow values as type parameters
<ousado>
AFAIK
<ousado>
but dependent types do
micro has left #ocaml []
<ousado>
it's possible that "phantom type" is also a valid description. but if you look at i.e. ATS you will find all of them supported, but no mention of the term "phantom type"
<mrvn>
well, you can already do phatom types in ocaml without gadt and with them you can tag arrays with their length for example.
<ousado>
as opposed to the "type" in "dependent type" ?
Tobu has quit [Ping timeout: 260 seconds]
<mrvn>
Is the ocaml manual for 3.13 online somewhere?
<iZsh>
3.13 is out?
<mrvn>
no
<adrien>
around June
<ousado>
yes, my above description is incomplete, or wrong for that matter, GADTs additionally allow recursion and pattern matching on multiple constructors, not just one. another term I found for GADT is GRDT - guarded recursive datatype.
<mrvn>
I just found this while googling: "Phantom types is another name of GADT."
<mrvn>
But I think gadt allows more than simple phantom types.
<ousado>
yes, I think that too
<adrien>
well, ocaml already had phantom types; why would GADTs would have been added if they were equal?
<ousado>
indeed
<flux>
well, phantom types always seem like that your internal implementation cannot make use of them, it is the external users that reap the benefits
<flux>
perhaps with GADTs you can better express similar limitations?
<flux>
but, really should start looking into GADT material :)
<iZsh>
understanding the type system is becoming like understanding quantum algorithms :P
<ousado>
OTOH sometimes things are possible but not practical with a given feature set. e.g. a dependent type for an array of exactly 4096 elements would be type ('a, 4096) t - if you write that as a phantom type as in the above example using zero /succ it becomes a lenghty thing
<mrvn>
flux: that is just because the type isn't private inside your module. You have to hide it in a submodule.
<flux>
mrvn, and then the limitation is moved into a another submodule. still the type system doesn't enforce it in that level.
<mrvn>
ousado: the phatnom type for fixed size arrays I had used ('a, d4 d0 d9 d6) t
<mrvn>
ousado: encoding each digit in a recursive type.
<mrvn>
flux: but the submodule would just declare the type. No operations on it.
Tobu has joined #ocaml
<ousado>
mrvn: yes, but you agree that you need to write out a whole lot more, explicitly, right?
<mrvn>
ousado: I'm not sure that gadt would allow you not to write out stuff when you want to limit your function to arrays of size 4096.
benozol has joined #ocaml
<ousado>
I was referring to dependent types in this case. I just tried to give an example where a given feature set makes something possible, but could be extended to make a given task way more convenient
<ousado>
I mean in your above type you need to encode not only the digits, but also e.g. the decimal system for, say, splitting an array
<mrvn>
The thing I want to do is have a byte stream and read int8/int16/int32/int64 values from it. Now the snag is that I don't want to allow unaligned access. So I want to encode the current alignment of the stream in the type.
<adrien>
you have a limited number of values; couldn't phantom types be enough?
<ousado>
wow.. that's pretty ambitious
<mrvn>
I can declare phantom types 'A0-'A7. get_int32 then needs type 'A0 stream -> 'A4 stream | 'A4 stream -> 'A0 stream
<mrvn>
With phantom types I can only declare ['A0 | 'A4] stream -> ['A0 | 'A4] stream
<mrvn>
Ok, now I have debs for 3.13. Lets see if they work.
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
funktronic has joined #ocaml
<funktronic>
any of you on mac? is the homebrew install better to use than the one from official site ?
<mrvn>
I need a frelling example on how to use gadt.
iago has joined #ocaml
ikaros has joined #ocaml
<funktronic>
with ocamlmakefile is it possible to change the target direcotry ?
<flux>
hcarty, does ocamlbrew support concurrent compilation?
ikaros has quit [Quit: Ex-Chat]
<flux>
hm, for some reason it only installed ocaml, nothing else
<flux>
ah, ran out of disk space
<iZsh>
@[<hov> is fine in Format, but I wish I could have a function to know beforehand whether or not it's going to fit
ikaros has joined #ocaml
cdidd has joined #ocaml
<funktronic>
any of you use the intellij idea plugin ?
Tobu has quit [Ping timeout: 272 seconds]
emmanuelux has joined #ocaml
Tobu has joined #ocaml
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
<mrvn>
First try with GADT: http://paste.debian.net/159310/ It seems to solve the problem of having to hide phantom types in a submodule.
<mrvn>
In foo and bar a "take2 off1" gives a compiler error
<mrvn>
But I think I'm doing something wrong because foo has a bunch of overhead when compiled.
<mrvn>
The GADT type doesn't get optimized away or something.
<flux>
pretty cool
benozol has quit [Quit: Konversation terminated!]
<flux>
although the GADTs don't seem to bring that much more to the table
<flux>
perhaps because there are encodings of GADTs with ocaml module system + phantom types
<flux>
although somewhere I read that GADT would be similar to 'first class phantom types', whatever that means
<mrvn>
flux: With GADT I can write match (t, x) with (Int, i) -> print_int i | (Float, f) -> print_float f
<mrvn>
The x has a different type in the 2 matches.
<mrvn>
Problem is I haven't figured out yet if I can get it accept match (t, x) with (Int, i) -> (Float, float_of_int i) | (Float, f) -> (Int, int_of_float f)
<funktronic>
does ocaml have a where binding like haskell ?
<adrien>
caml light had one; ocaml doesn't
<mrvn>
match x with a when a mod 2 = 0 -> ...?
<mrvn>
let x = { r with field = 2; }?
<mrvn>
or is where something completly different?
lorilan has joined #ocaml
<thelema_>
mrvn: where is a backwards let - x=y where x=5 and y=3
<funktronic>
other than being an idiot, it's t -> elt -> t
<funktronic>
i'm curious, ayone know why it was decided that it'd be elt -> t -> t instead of t -> elt -> t ?
<funktronic>
for sets
<thelema_>
funktronic: because it's functional as opposed to imperative.
<thelema_>
or put another way, immutable as opposed to mutable
<funktronic>
i guess being able to say let foo = set.remove bah isn't that handy
<funktronic>
i'm coming from F#, where the collection is usually the first arg
<thelema_>
mutable data structures usually come first in the argument list, as it's common to partially apply them to their data structure, as this makes sense more than once
<thelema_>
but for immutable, it's the opposite.
<thelema_>
That's the reasoning. It makes for annoyances in terms of argument order all the time
<thelema_>
Jane street (and apparently f#) have decided that consistency was more important than easy currying
<thelema_>
s/currying/partial application/
<funktronic>
in F# even immutable structures come first
<thelema_>
funktronic: that's what I said, f# has decided that consistency is more important than easy partial application
datkin has quit [Ping timeout: 255 seconds]
<funktronic>
stupid question.. what's the eaiest way to make a Hashtbl of string * int ?
<flux>
funktronic, let a = Hashtbl.create 10 in Hashtbl.add a "hello" 42
<flux>
mrvn, how would you loop with that?
<mrvn>
flux: with what?
datkin has joined #ocaml
<flux>
mrvn, how would you output each byte one-by-one with type t
<flux>
mrvn, I tried this but it didn't work: let rec loop ofs = if snd ofs < 5 then let (ofs, x) = t1 ofs in Printf.printf "%s\n" x; loop ofs
<mrvn>
flux: let rec print_n off = function 0 -> () | n -> let (off, x) = t1 off in Printf.printf "%s " x; print_n off (n-1)
<flux>
mrvn, and how do you call that?
<mrvn>
val print_n : ('a * 'a) t * int -> int -> unit = <fun>
<mrvn>
That suks.
<funktronic>
flux: then the type of the table would be (string, int) Hashtbl.t ?
<flux>
funktronic, yes
<funktronic>
is there a way to alias something like PersonCount = (string, int) Hashtbl.t ?
<flux>
funktronic, if you want to be explicit about it, you can write: let a : (string, int) Hashtbl.t = Hashtbl.create ..
<flux>
type person_count = (string, int) Hashtblt
<flux>
however, there is another way, involving functors and modules
<mrvn>
let rec print_n : type a b . ((a * b) t * int) -> int -> unit = function off -> function 0 -> () | n -> let (off, x) = t1 off in Printf.printf "%s " x; print_n off (n-1);;
<mrvn>
val print_n : ('a * 'b) t * int -> int -> unit = <fun>
<mrvn>
# print_n zero 4;;
<mrvn>
a b c d - : unit = ()
<funktronic>
flux: thanks
andreypopp has joined #ocaml
<mrvn>
flux: With GADT you seem to always have to specify the type or bad things happen.
<flux>
module PersonCount = Hashtbl.Make(struct type t = string let equal = (=) let hash = Hashtbl.hash end)
<flux>
funktronic, but perhaps the type alias is sufficient for your case
<flux>
funktronic, in any case, that only limits that the key is a string, the value can be anything
<funktronic>
ahh i see
<funktronic>
the Hashtbl.hash end .. what is that ?
<flux>
funktronic, it's the default hashing function that works on 'everything'
<thelema_>
funktronic: end just matches the struct
<flux>
ah right, I missed that
<funktronic>
is there a way to further restrict it ?
<funktronic>
sorry for all the questions, this is quite different from F#
<flux>
funktronic, well, you can define a module that is implemented in terms of Hashtbl
<flux>
perhaps a module type signature is sufficient
<flux>
(hmm, perhaps not)
<flux>
funktronic, but it wouldn't be Hashtbl anymore, if it mattersr
ftrvxmtrx_ has quit [Quit: Leaving]
datkin has quit [Ping timeout: 246 seconds]
<flux>
and you would need to spell out the functions you want to use on the data strcutre
<funktronic>
i see. so with the PersonCount module do i still need to use hashtbl.create ?
andreypopp has quit [Quit: Computer has gone to sleep.]
<flux>
funktronic, you would use PersonCount.create
<ousado>
I thought you know it since I mentioned it earlier
<mrvn>
No. I want to use ocaml.
<funktronic>
is it possible to decompose a list in a let binding ?
Tobu has quit [Ping timeout: 272 seconds]
<adrien>
let [ a; b; c ] = [1; 2; 3 ]
<adrien>
let [ a; b; c ] = [1; 2; 3; 4 ]
<adrien>
the second one would fail
<adrien>
and you'll always get a warning because of that
<adrien>
there's a syntax extension for cases where you know it can't fail
Tobu has joined #ocaml
MaskRay has quit [Quit: leaving]
<mrvn>
If a module defines 'let bind s = (take1 s, take2 s, take4 s, take8 s)' and I use 'let (t1, _, t4, _) = M.bind s' does ocaml optimize away the t2 and t8 or does it construct them and throw them away?
<mrvn>
[let take* = fun s x -> ....]
<adrien>
"take2 s" could have side-effects
<adrien>
so I don't think it would
<adrien>
(I don't think it would optimize)
<mrvn>
The take* are define just above the bind so it can know that they don't.
<adrien>
I don't think ocaml tries to guess that kind of things
<mrvn>
I would guess that it depends on the level of inlining it manages to do.
iago has quit [Quit: Leaving]
KDr2 has quit [Remote host closed the connection]
mrvn has left #ocaml []
<funktronic>
when does the Set.remove consider items to be equal ?
<_habnabit>
funktronic, when the compare function you provided to the functor returns 0
<funktronic>
thanks!
snearch has joined #ocaml
<thelema_>
ocaml doesn't optimize away any instructions you ask it to perform.
<thelema_>
even with tons of inlining, afaik, there's no dead code removal
<thelema_>
well, `if false then foo` gets removed...
letrec has quit [Ping timeout: 255 seconds]
sander has joined #ocaml
Drup1 has joined #ocaml
<funktronic>
is there a printf format for records? F# has %A that formats the record nicely
<thelema_>
funktronic: nope, you'll have to manually print the fields of a record.
<thelema_>
I usually make a function like this let print_r oc {foo; bar} = fprintf oc "{foo=%s; bar=%d}" foo bar
<thelema_>
and then I can do `printf "rec: %a" print_r r`
Drup1 has quit [Quit: Leaving.]
mrvn has joined #ocaml
<mrvn>
Anyone know if I can write a META file so that bigarray is only added if MyLib.BA.something is used?
<adrien>
package foo {
<adrien>
regular meta content
<adrien>
}
<adrien>
and use -package lib.foo
<mrvn>
and how to do that in oasis
<adrien>
haven't had to do it yet (but will have to soon)
<mrvn>
adrien: It would be cooler if there were something like archive(native,mt) but fur bigarray
<adrien>
you can set arbitrary predicates I think
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
Xizor has joined #ocaml
philtor has joined #ocaml
<funktronic>
if i say module Foo = Set.Make() and then i have a recotd with { a = Foo.empty; b = Foo.empty; } and later i do things like Foo.add myrecord.a value and add it to b also it won't be the asme set right ?
<funktronic>
basically, Set.Make() creates a module not an instance right
<thelema_>
funktronic: actually, in this case there's no real difference, as Foo.empty is the same.
<thelema_>
if you do `myrecord.a <- Foo.add value myrecord.a`, only myrecord.a will be updated
<mrvn>
Foo.add creates a new set every time
<thelema_>
immutable sets, mutable record field can point to different sets as you wish
<thelema_>
mrvn: well said.
<mrvn>
so "Foo.add myrecord.a value" changes nothing in the record.
<funktronic>
i had a typo
<funktronic>
i called the wrong unfction
<funktronic>
for the past 2 hrs i've been going "BUT HOW CAN IT BE IN THERE"
<funktronic>
yeah it works fine
<adrien>
:-)
philtor has quit [Ping timeout: 272 seconds]
<funktronic>
had the same issue in the F# version too
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
<funktronic>
the ocalide debug shows me close to worthless call stack.. any way to get it to show something more reasonable ?
<adrien>
define "close to worthless"
EmmanuelOga has joined #ocaml
<funktronic>
gives me a module and the char offset of the source of that module
andreypopp has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 246 seconds]
philtor has joined #ocaml
philtor has quit [Ping timeout: 244 seconds]
<funktronic>
hm.. looks like Str.split (Str.regexp ",") is the cause
andreypopp has quit [Quit: Computer has gone to sleep.]
thieusoai has quit [Quit: Leaving]
andreypopp has joined #ocaml
ftrvxmtrx has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
<funktronic>
yep.. weird.
<flux>
funktronic, btw, you don't happen to use multiple threads do you?
<adrien>
or interleave calls to functions in Str with different string and/or regexp parameters?
<flux>
because the Str module is utterly thread-unsafe even for situations where it seems it would be safe
<flux>
adrien, well, unsafety in such situations should be obvious..
<adrien>
(my sentence made no sense \o/ )
<flux>
in particular, Str.split (Str.regexp foo) is unsafe
<flux>
funktronic, I suggest you switch to ocaml-pcre
<flux>
although I cannot tell which bugs it has :-)
<flux>
but at least it won't surprise when code using that is put into two threads some point in the future..
<adrien>
hmmm
<flux>
ocaml-pcre has been very robust for me. the only trouble with it has been when I haven't read the fine documentation properly
<adrien>
"Reimplemented global_substitute and *split* in a tail-rec manner. Will be in 3.11."
<funktronic>
oh wait.. i'm running 3.12.1
<flux>
(but the documentation is good as well and my issue was a border case)
fraggle_ has joined #ocaml
mjonsson has joined #ocaml
snearch has quit [Quit: Verlassend]
andreypopp has quit [Quit: Computer has gone to sleep.]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
carrot has joined #ocaml
carrot has left #ocaml []
vivanov has joined #ocaml
<vivanov>
installed ocsigen in ubuntu -- 'eliomc: command not found'
<thizanne>
same on archlinux
<thizanne>
the solution for me was to make a package containing the whole bundle - rather than build each package (ocsigenserver, eliom...) individually
<thizanne>
maybe you could try to download the sources and run `make build install`
<vivanov>
ok thx :)
twittard has quit [Quit: twittard]
Snark has quit [Quit: Quitte]
avsm has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
fraggle_ has joined #ocaml
iago has joined #ocaml
asdfhjkl has joined #ocaml
andreypopp has joined #ocaml
vivanov has quit [Ping timeout: 252 seconds]
philtor has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
ikaros has quit [Quit: Ex-Chat]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
iago has quit [Ping timeout: 252 seconds]
djcoin has joined #ocaml
andreypopp has joined #ocaml
EmmanuelOga has quit [Quit: WeeChat 0.3.7-dev]
sander has quit [Quit: Leaving]
Submarine has quit [Ping timeout: 246 seconds]
edwin has quit [Remote host closed the connection]
philtor has quit [Ping timeout: 244 seconds]
everyonemines has joined #ocaml
djcoin has quit [Quit: WeeChat 0.3.2]
asdfhjkl has quit [Ping timeout: 260 seconds]
letrec has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]