SEcki has quit [Remote host closed the connection]
boscop has quit []
thrasibule has joined #ocaml
_unK has quit [Remote host closed the connection]
enthymeme has joined #ocaml
seg_ has joined #ocaml
segmond has quit [Ping timeout: 260 seconds]
travisbrady has quit [Quit: travisbrady]
myu2 has joined #ocaml
myu2_ has joined #ocaml
myu2_ has quit [Client Quit]
myu2 has quit [Ping timeout: 245 seconds]
myu2 has joined #ocaml
myu2 has quit [Read error: Connection reset by peer]
myu2 has joined #ocaml
Morphous has quit [Ping timeout: 245 seconds]
maskd has quit [Ping timeout: 276 seconds]
Morphous has joined #ocaml
seg_ is now known as segmond
valross has joined #ocaml
sealion has left #ocaml []
maattd has quit [Ping timeout: 260 seconds]
Associat0r has quit [Quit: Associat0r]
enthymeme has quit [Ping timeout: 252 seconds]
enthymeme has joined #ocaml
wormphlegm has joined #ocaml
ulfdoz has joined #ocaml
ygrek has joined #ocaml
wormphlegm has quit [Quit: bye]
ftrvxmtrx has quit [Quit: Leaving]
ulfdoz has quit [Read error: Operation timed out]
myu2 has quit [Read error: Operation timed out]
Yoric has joined #ocaml
spearalot has joined #ocaml
myu2 has joined #ocaml
marteo has joined #ocaml
komar_ has joined #ocaml
komar_ has quit [Quit: WeeChat 0.2.6]
Yoric has quit [Quit: Yoric]
myu2 has quit [Remote host closed the connection]
enthymeme has quit [Ping timeout: 248 seconds]
avsm has joined #ocaml
ftrvxmtrx has joined #ocaml
myu2 has joined #ocaml
enthymeme has joined #ocaml
Gooffy has joined #ocaml
Yoric has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
ikaros has joined #ocaml
barismetin has joined #ocaml
pimmhogeling has joined #ocaml
Yoric_ has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
Yoric_ is now known as Yoric
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
maattd has joined #ocaml
thrasibule has quit [Ping timeout: 240 seconds]
myu2 has quit [Remote host closed the connection]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
matthieu has joined #ocaml
maattd has quit [Read error: No route to host]
drk-sd has joined #ocaml
ttamttam has joined #ocaml
sepp2k has joined #ocaml
Associat0r has joined #ocaml
valross has quit [Remote host closed the connection]
ikaros has quit [Quit: Leave the magic to Houdini]
valross has joined #ocaml
valross has quit [Quit: Ex-Chat]
lvillani has joined #ocaml
M| has quit [Ping timeout: 240 seconds]
lvillani has quit [Remote host closed the connection]
M| has joined #ocaml
Leonidas has quit [Ping timeout: 246 seconds]
Leonidas has joined #ocaml
pimmhogeling has quit [Remote host closed the connection]
peddie_ has quit [Ping timeout: 240 seconds]
peddie has joined #ocaml
lvillani has joined #ocaml
avsm has quit [Quit: Leaving.]
M| has quit [Ping timeout: 246 seconds]
M| has joined #ocaml
ftrvxmtrx has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
derdon has joined #ocaml
avsm has joined #ocaml
<hcarty>
Anyone here interested in a Google Wave invitation? I have several and no current use for them.
M| has quit [Ping timeout: 252 seconds]
pozic has joined #ocaml
boscop has joined #ocaml
<pozic>
Is it practical to write in a monadic style in OCaml?
<pozic>
That is, to use monad transformers, etc.
<hcarty>
pozic: I'm not familiar with it, but people do.
<hcarty>
pozic: Lwt is apparently monad-like in its design. There is a syntax extension called pa_monad which provides some extra syntax sugar for monads in general.
<pozic>
hcarty: pa_monad looks quite nice. How does that interact with error messages?
<pozic>
That is, do you get exact column error messages.
<pozic>
Or do you get messages that mention pieces of text that you didn't write yourself.
M| has joined #ocaml
<hcarty>
pozic: I'm not sure as I haven't used it. But it seems to be fairly well regarded, and most well-written syntax extensions still provide good error messages.
<hcarty>
Pointing to the code you wrote, rather than the underlying, transformed code.
<hcarty>
The content of the message may be a little syntax-specific. But it will likely point to the correct place.
<avsm>
camlp4 makes it pretty easy to track location of the code you wrote vs the generated code. and if you need to debug, you can just call 'camlp4o' directly to view the generated code
<pozic>
And how good is Pycaml?
<pozic>
It seems like it is not being maintained anymore.
<pozic>
This is built against python 2.x and Ocaml 3.04.
<pozic>
AFAIK, you cannot built against 2.x. You can build against 2.5, 2.6, but not have something which works for both.
<pozic>
build*
lvillani_ has joined #ocaml
M| has quit [Ping timeout: 240 seconds]
pimmhogeling has joined #ocaml
<thelema>
pozic: I'm using pycaml in my code - it works for me.
<pozic>
thelema: is it also complete?
<pozic>
thelema: I have been using Boost.Python, which is a very nice bidirectional interface.
<thelema>
complete? It seems as complete as the C API, which it seems to make available in its entirety.
<thelema>
but I just use it to call a python function and get the results back
<pozic>
thelema: but it also works the other way around, right?
<thelema>
you want a python main that calls ocaml functions?
smimou has joined #ocaml
<pozic>
thelema: that too.
<pozic>
thelema: bidirectional.
M| has joined #ocaml
<thelema>
I don't know if pycaml helps when you have a python main - I think for that you'd want to export the ocaml functions through OCaml's C api and get at them through Python's FFI
<pozic>
That's exactly what is nice about the C++ API. You need only C++ to write the Python extension.
<thelema>
I take that back - pycaml does allow ocaml to be used form python (or it claims to)
<thelema>
I don't see how it does that. But the C wrappers needed for ocaml are pretty simple.
rovar_ has joined #ocaml
_andre has joined #ocaml
ikaros has joined #ocaml
eldragon has quit [Remote host closed the connection]
spearalot has quit [Quit: Computer has gone to sleep]
eldragon has joined #ocaml
f[x] has quit [Ping timeout: 260 seconds]
<rovar_>
what is the recommended way in ocaml to specify enumerations which contain values?
<rovar_>
(not necessarily incrementing values)
<mfp>
Batteries's Enum ?
<mfp>
do you want an ADT with a next : 'a t -> 'a or similar operation, or something else?
<rovar_>
i am building an implementation of the BSON protocol http://bsonspec.org/#/specification It uses integers as indicators of the type.
<rovar_>
so I have a union representing all possible types, and I would like to have a corresponding data structure which maps the integer value to it
<adrien>
you mean an enum like 'type a = B of int | C of float' ?
<hcarty>
Or a "type a = B | C | ..." with a function "let int_of_a match x with | B -> 2 | C -> 5 | ..."
<rovar_>
kind of like type bsondata = a of 1 | b of 2 | c of 3 / etc
<rovar_>
hcarty, that would be more accurate, yes
<rovar_>
but I would like to pattern match using it
pimmhogeling has quit [Ping timeout: 245 seconds]
<rovar_>
also, they're not ints, but bytes.
ikaros has quit [Quit: Leave the magic to Houdini]
<gildor>
rovar_: just use it for ocaml-moifile, quite nice library
lvillani has left #ocaml []
M| has quit [Ping timeout: 264 seconds]
M| has joined #ocaml
<rovar_>
wow.. this is complex
M| has quit [Ping timeout: 260 seconds]
<rovar_>
is it possible to specify a function signature in an ml file?
<rovar_>
similar to haskell?
<thelema>
let fun f : int -> int -> int = fun x y -> 2 * x + y
<thelema>
err, [let f]
<thelema>
type annotations in .ml files are just restrictions - it's legal to annotate any function as ('a->'b) -- the compiler will narrow down from this type to whatever the actual type is
ttamttam has quit [Quit: Leaving.]
<rovar_>
sure.
<rovar_>
I'm familiar with Haskell, so I understand the semantics of an HM type inferred language, I'm just having a hard time searching for certain syntactical items :)
<thelema>
rovar_: why do you want to specify a function signature?
M| has joined #ocaml
<rovar_>
i'm just trying to determine which types exist, actually
<rovar_>
I need to specify a Calendar object of some sort for my union..
<rovar_>
speaking of which.. there appears to be some methods in Calendar_sig.S specifically i want from_unixfloat
<rovar_>
but I can't seem to access it...
<rovar_>
there it is, CalendarLib.Calendar.from_unixtime returns a CalendarLib.Calendar.t
<thelema>
maybe [open CalendarLib.Calendar] will help
<rovar_>
yea
<rovar_>
wow.. why would someone design an API this way?
<rovar_>
apparently usability was not at the top of their list..
<thelema>
I guess they packed the whole thing in CalendarLib, and Calendar is their main module, but they have a few more
<rovar_>
thelema, I'm trying to avoid using open until I get more familiar with the prevailing APIs
<rovar_>
I like to know where types/functions come from :)
<thelema>
maybe just [open CalendarLib] then. Calendar.foo seems explanatory
<rovar_>
that's what I did
<rovar_>
i'm still getting used to this module system.. i'd prefer to work with a type called calendar than Calendar.t
<rovar_>
I guess I could alias it :)
<thelema>
yup.
<thelema>
type aliases are free
<rovar_>
so if I have a function which is parsing a binary stream and i would like to pattern match on the value of a byte..
sepp2k has quit [Remote host closed the connection]
<rovar_>
can I use a function: byte_of_mytype to pattern match on the value?
<hcarty>
rovar_: Calendar is built on functors from what I understand. So there is a lot of repetition in the interface to allow for customized representations of date/time information.
<rovar_>
i guess I don't need to go that way.. i can just mytype_of_byte.. that would make much more sense..
<rovar_>
hcarty, that seems to make sense from the API docs, I guess that just wasn't apparent because noone's bothered to actually document anything. at the high level
<thelema>
match stream with '\x01'::t -> parse_name t |> parse_double ...
<hcarty>
rovar_: Module aliases are also a nice way to shorten what you have to type - "module C = CalendarLib.Calendar"
<rovar_>
ah.. good point.
<hcarty>
rovar_: But yes, the Calendar library does have a fairly significant initial learning curve, particularly if you are new to OCaml.
<hcarty>
It does tend to do a good job of being safe and internally self-consistent though.
<rovar_>
that's like import qualified in Haskell.. now we're speaking my language :)
<rovar_>
i like self-consistent :)
<hcarty>
It does make life just a little easier!
spearalot has joined #ocaml
<thelema>
I wonder why you'd need a calendar library - just return the 64-bit value, no?
<rovar_>
i'd prefer to return it into something more usable..
<thelema>
milliseconds since the epoch is TAI - why is this not usable?
<rovar_>
well it's certainly usable, but i would assume that the first thing a person would do with that value is convert it to a calendar or something else
<thelema>
That seems like a function of the client, and adding a calendar dependency for even clients that don't use the datetime stuff...
<hcarty>
rovar_, thelema: Indeed - it's much harder to ask "what was the previous month?" from a bare number
<rovar_>
i guess we can leave that as an exercise to the customer.. it will make my life easier too
<rovar_>
or i'll include a "utils" in a separate module
<rovar_>
so are int32's and int64's boxed?
<hcarty>
rovar_: Int32.t and Int64.t values are boxed
<rovar_>
how do those relate to int32 and int64?
<rovar_>
because they seem to be valid in my toplevel.
<thelema>
they're the same
<rovar_>
gotcha
<rovar_>
and are chars 8 bit values?
_unK has joined #ocaml
<thelema>
nope, 31
<thelema>
well, an array of n chars takes n+1 words in memory (n for data + 1 tag word w/ length)
<thelema>
which is why strings aren't arrays of chars
<rovar_>
not a problem here, I guess. So are the only ways to aggregate data types tuples and records?
ikaros has quit [Quit: Leave the magic to Houdini]
<thelema>
but when you convert something to a char, all but the bottom 8 bits are masked out
Yoric_ has joined #ocaml
pozic has quit [Quit: leaving]
<rovar_>
in Haskell, data types can consist of more than one type: e.g. data Foo = Mytype int string | MyOtherType int int int
Yoric has quit [Ping timeout: 252 seconds]
Yoric_ is now known as Yoric
seafood has quit [Quit: seafood]
<thelema>
type foo = Mytype of int * string | MyOtherType of int * int * int
<mfp>
rovar_: algebraic types work exactly the same way in OCaml
<rovar_>
except that the aggregation of types must explicitly be tuples
<mfp>
it's not a tuple in fact
<rovar_>
no?
<mfp>
Mytype of int * string is not the same thing as Mytype of (int * string)
<mfp>
the former is a constructor with 2 elements,
<mfp>
the latter one with 1 element which happens to be a tuple
<rovar_>
interesting
<mfp>
this is confusing, syntax-wise
<mfp>
it's clearer in the revised syntax
<rovar_>
revised syntax?
<mfp>
which was IIRC something like Mytype of int and string for the former
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
<mfp>
rovar_: a different syntax designed by camlp4's orig author
<mfp>
essentially no one uses it outside camlp4 (and syntax extensions that use it), though :)