<datrus>
i'm building a C extension to ocaml. in one function i need to take a list as a parameter. does anyone know where i can find sample code to decode a list value from C?
<DRMacIver>
Yeah, that looks like it works. Thanks.
Roughest has quit ["Konversation terminated!"]
Mr_Awesome has joined #ocaml
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
<falconair>
do you know if the events of the Event module are the same as F#'s events? I think there is an F# do that says that its events are based one some 'wire' methodology
<falconair>
...let me look it up
<flux__>
I doubt they have anything to do with each other
<flux__>
anyway, the Event-module doesn't have an opinion what kind of events you haave
<flux__>
they could be functions for all it cares
<dark_light>
:)
<falconair>
from "Simplicity and Compositionality in Asynchronous Programming through First Class Events" :
<falconair>
"Much of what is presented here is inspired by James Margetson's personal use of a related event model called 'wires'"
<flux__>
but I still think it's some #-technology-specific feature
<flux__>
oh, it's the same page
<flux__>
almost
<falconair>
ehh, i can't find this Mr. Margetson and his 'wires' ...
datrus has quit ["leaving"]
pango has quit [Remote closed the connection]
<dark_light>
When the light syntax option is enabled 'in' is optional. The token after the '=' of a 'let' definition begins a new block, where the pre-parser inserts an implicit separating 'in' token between each 'let' binding that begins at the same column as that token.
dibblego has quit [Read error: 110 (Connection timed out)]
<dark_light>
but, hmmm.. some features depends on syntax alignment, like python.. well, not so cool mixture things. ML was never identation-oriented..
danly has joined #ocaml
danly has quit [Read error: 54 (Connection reset by peer)]
<Ugarte>
dark_light: Events are a feature of C#/.NET. So first class events is actually a fairly simple thing to add to F#.
tmorris has joined #ocaml
tmorris is now known as dibblego
<Ugarte>
As for using F#, it runs on Mono as well as on the MS .NET SDK, so there's not a really good reason to avoid using it.
<Ugarte>
Unless you fear that the compiler will be abandoned at some point and the language will disappear, which seems unlikely in at least the short run.
<Ugarte>
It has a fair amount of adoption in MSR.
<dibblego>
what is MSR?
<Ugarte>
Microsoft Rsearch.
<Ugarte>
Where Don Syme works.
<dibblego>
ah right
<Ugarte>
MSR is from where F# comes.
<Ugarte>
Sorry :)
<Ugarte>
I shouldn't use acronyms.
<Ugarte>
He responds to e-mail. You could write him and ask about the future of F#. But Id on't think it's going anywhere.
<levi_home>
With a program I was writing, I kept F# and OCaml versions in sync for a while, but F# was just so much less convenient and so much slower, I eventually gave up on it.
<levi_home>
(F# with Mono, that is)
<Ugarte>
It's not impossible to keep them in sync. It's not even that difficult.
<Ugarte>
So that's another reason not to worry too much about using it.
<dibblego>
why slower?
<Ugarte>
Though I guess the only time you'd reaelly use it would be for the libraries, in which case you'd still be fucked if F# vanished.
<levi_home>
Because the OCaml compiler is really good.
<Ugarte>
I'm using F# at work, actually.
<dark_light>
Ugarte, mono doesn't implement the entire .NET. and, especially, mono doesn't have the power to determine the future changes on the platform. that's a very different situation than, let's say, python
<levi_home>
And Mono is okay, but not great.
<dibblego>
my boss and I are currently deciding between O'Caml and F#, but neither are anywhere near well informed enough
<Ugarte>
Oh, and F# is open source.
<Ugarte>
dark_light: It doesn't implement the Windows.* libraries, but that's not a huge loss.
<dibblego>
I have to buy a book, but it seems that Practical O'Caml is getting a bad reputation
<Ugarte>
Mono's performance is also quite reasonable.
<Ugarte>
dibblego: It's worth noting that there are no published books on F# yet. But most OCaml books largely apply.
<levi_home>
Certainly good enough for desktop apps.
<Ugarte>
Don Syme is working on an F# book.
<dark_light>
Ugarte, the main example of the site i read was about System.Windows.Forms
<Ugarte>
dark_light: Yeah, that's what I meant.
<dark_light>
Ugarte, i am not saying F# is a bad idea, just my thoughts about the platform
<Ugarte>
Windows.Forms is also really nice. Mono claim to be working on it, but I wouldn't hold my breath.
<levi_home>
I was doing AI algorithms, though, and OCaml was just way faster than F# on Mono.
<Ugarte>
No, your thoughts are totally accurate.
<Ugarte>
I wasn't criticising you.
<dibblego>
Ugarte, can you recommend any books? I've seen the PDFs online, but I struggle to learn off the monitor and there aren't hard copies available
<Ugarte>
dibblego: Hmm. I like that OReilly book, but it's online. ;)
<Ugarte>
I learned OCaml in school, so I never had a real textbook, to be honest.
<Ugarte>
And I'm real rusty in patches.
<dibblego>
yeah I've seen that one
<Ugarte>
I've been doing a lot of F# lately, but I write that in a bit of a weird style, since a lot of my code interacts with C# libraries I've written and stuff.
<Ugarte>
Which is fun, but a bit...odd.
<Ugarte>
But it's incredibly convenient. For instance, I have a tool in F# that calls plugins from DLLs written in C# (well, could be anything, but presumably C# so other people cna write them).
<levi_home>
I learned from the reference manual, which is really really good, and the O'Reilly book.
<Ugarte>
I'll try to get my boss to order that for me.
<Ugarte>
The key point for me is the .NET interaction.
<Ugarte>
Because we're nearly entirely .NET, and having access to that range of libraries is nice.
<levi_home>
I'd never used .net before, so that wasn't a big attraction to me. OCaml had libraries for everything I needed.
<Ugarte>
Yeah.
<Ugarte>
I'm saying, this is why F# may not be attractive to everyone.
<levi_home>
I also wanted to try out some of the things that F# didn't support, like functors.
<Ugarte>
And some people miss what OCaml has and F# doesn't.
<Ugarte>
Right.
<dark_light>
well.. by the way.. someone knows a good library that parses HTML? like DOM but i want one that parses malformed html too (like the gecko 'quirks' mode)
<Ugarte>
Hmm.
<levi_home>
Mostly I missed OCaml's blazing speed. :)
<Ugarte>
You can use XmlDocument if you're using F# on .NEt, but it's a strict/validating parser.
<dark_light>
Ugarte, and worse (for me), it's based on xml, and not sgml
<Ugarte>
levi_home: We've had some perf issues on complex stuff, but largely it hasn't been a problem.
<Ugarte>
dark_light: Ah.
<dark_light>
i am thinking in using just regexes, but it's not very fun..
<Ugarte>
I'm trying to think of how hard it'd be to write that.
<dark_light>
currently i am using a bit of parsers written in a mix of ocaml, c, sed and shell scripting, :-(
<Ugarte>
I need to write an XML parser, actually.
<Ugarte>
Ew.
<levi_home>
Ugarte: I had to implement non-optimal AI search algorithms as part of an assignment, so performance was very important to me.
<dark_light>
i am using Genlex to parse things
<levi_home>
Ugarte: In general, I'm sure it wouldn't be a big problem.
<dark_light>
but Genlex has some odd limitations so i have to use a sed script (and a C one too) to "treat" the string for him
<dark_light>
i am thinking in learning perl, maybe it's what i need..:)
<Ugarte>
Ew.
<Ugarte>
No.
<dark_light>
(Genlex was meant to parse things that are similar to ocaml's syntax, html definitively not being one of those things)
<levi_home>
You could jump straight to Perl 6, which is only slightly insane and has transformed the 'regex' concept into a full parsing system. :P
dibblego has quit [Read error: 54 (Connection reset by peer)]
<dark_light>
levi_home, Hmmm. :P
dibblego has joined #ocaml
<levi_home>
Seriously, Perl 6 has some cool stuff, but the 'regex' thing, now called 'Perl 6 Rules' or something, still looks like a huge mess.
<dark_light>
i was thinking. i love sed, i love shell scripting, so i should love perl too. but i love ocaml, so i should love python and not perl. or maybe i should give up them and learn lisp. or java.
<dark_light>
levi_home, hmmmmmmmm.
<levi_home>
I was simultaneously learning OCaml and Perl, and I found the syntaxes eerily similar in some ways.
<dark_light>
wow. :-P.
<levi_home>
You can do functional programming in perl.
<dark_light>
seriously?
<levi_home>
Yup.
<dark_light>
levi_home, but i "can" do functional programming in C too... eheh..
<levi_home>
Anonymous functions, lexical scope, closures, etc.
<dark_light>
levi_home, in perl, functions are first class values?
<dark_light>
wow, closures
<levi_home>
Yup.
<dark_light>
levi_home, nice thing
<levi_home>
There's a book, 'Higher Order Perl', that talks all about functional programming in Perl.
<dark_light>
perl 5 or above?
<levi_home>
The premise is that Perl is really more like Lisp than C, so people should take advantage of that fact.
<levi_home>
Perl 5.
<levi_home>
Perl 6 is even more so.
<dark_light>
levi_home, for me, perl is a lot like C. the syntax has a "C feeling" on it. but i don't know so much of perl
<levi_home>
Yes, the syntax very roughly resembles C, but that's just the surface.
<levi_home>
Clearly the semantics do not resemble C at all except in a few cases where just about everything resembles C.
<levi_home>
Anyway, if you can get past the extremely kludgy nature of perl, it can be wielded in a pretty powerful manner. Perl 6 removes a good bit of the most obvious kludginess.
<levi_home>
But neither are OCaml, so not terribly relevant here.
<dark_light>
(just to make it clear, what is kludgy?)
<dark_light>
levi_home, i think it's a good idea mix sed-like commands with c-like command with other things i didn't knew perl do, specially when doing a "script", not a big system
Mr_Awesome has quit ["and the Awesome Level drops"]
<levi_home>
dark_light: Sure, domain-specific languages are a good thing.
<levi_home>
But in perl, they're thrown together in a somewhat ad-hoc manner with the glue between them all hidden in a byzantine C implementation.
dobblego has joined #ocaml
dobblego has quit [Client Quit]
<dark_light>
sometimes i think it would be better if i had only one basic language with many domain-specific set of syntax extensions+default libraries
<dark_light>
but that seems hard. when i am doing a shell script i don't want to care about existence of types.
<levi_home>
That's the idea behind Lisp and, to a lesser extent, Camlp4.
dobblego has joined #ocaml
<levi_home>
There's a scheme called scsh that has an awk-like mini-language built in.
<dark_light>
levi_home, maybe it would be nice if there are a shell with lisp semantics and more-or-less equivalent with default sh
<dark_light>
scsh?
<levi_home>
It's great for the sort of things I'd like to do with shell, but can never remember the syntax for.
<dark_light>
i was looking for some lisp-variant interpreter
<flux__>
dark_light, there exists a tool (I don't recall the name) that parses such html and produces cleaned up html as output.. maybe you can find it at freshmeat.
<dark_light>
it is a shell in the common sense? i can't do ls here :( it's like the ocaml toplevel, right?
<dark_light>
flux__, hmmm.. some html beautifier/fixer? thanks
<levi_home>
It is not a command processing shell, it's a scripting shell.
<dark_light>
(i was doing ad-hoc correction that quoted the tag parameters and deleted all stuff i don't need)
<dark_light>
levi_home, well, like the top level
<flux__>
dark_light, actually I'm not sure if this applies, it was actually a html->xml-converter.. but I used html-xml-utils-3.7
<dark_light>
html accepts unquoted parameters like <a href=b> (what is ugly)
<dark_light>
levi_home, seems nice that scsh=)
<Ugarte>
There's such a lib for Python called Beautifulsoup.
<Ugarte>
It's quite nice.
<Ugarte>
zzzz
<levi_home>
dark_light: Another interesting thing in this vein is the Listener in McCLIM, a Common Lisp command shell sort of thing.
trrkkkkk has joined #ocaml
yondalf has joined #ocaml
trrkkkkkk has quit [Read error: 148 (No route to host)]
<dark_light>
levi_home, scsh doesnt seems very pr
<dark_light>
short
<dark_light>
but well i must sleep.. bye
yondalf_ has joined #ocaml
yondalf has quit [Read error: 60 (Operation timed out)]
mbishop has joined #ocaml
_fab has joined #ocaml
yondalf has joined #ocaml
Skal has joined #ocaml
yondalf_ has quit [Read error: 110 (Connection timed out)]
Snark has joined #ocaml
sponge45 has quit ["zzzzzzzzzz"]
yondalf has quit [Read error: 54 (Connection reset by peer)]
yondalf has joined #ocaml
ikaros has joined #ocaml
kwak_ has joined #ocaml
dobblego has quit ["Leaving"]
yondalf_ has joined #ocaml
yondalf_ has quit [Client Quit]
yondalf has quit [Read error: 110 (Connection timed out)]
_JusSx_ has joined #ocaml
ikaros has quit [Remote closed the connection]
ikaros has joined #ocaml
ruben17 has joined #ocaml
ulfdoz has quit [Read error: 54 (Connection reset by peer)]
ulfdoz has joined #ocaml
jajs has joined #ocaml
bluestorm has joined #ocaml
ikaros has quit [Remote closed the connection]
ikaros has joined #ocaml
ikaros_ has joined #ocaml
ikaros has quit [Client Quit]
ikaros_ is now known as ikaros
smimou has joined #ocaml
yondalf has joined #ocaml
love-pingoo has joined #ocaml
_JusSx_ has quit [Client Quit]
ruben17 has quit []
swater has joined #ocaml
trrkkkkkk has joined #ocaml
trrkkkkk has quit [Read error: 148 (No route to host)]
yondalf_ has joined #ocaml
_JusSx_ has joined #ocaml
yondalf has quit [Read error: 60 (Operation timed out)]
ikaros has quit [Remote closed the connection]
ikaros has joined #ocaml
yondalf has joined #ocaml
ruben17 has joined #ocaml
ikaros has quit ["Leaving"]
batdog|gone is now known as batdog
ikaros has joined #ocaml
yondalf_ has quit [Read error: 110 (Connection timed out)]
jajs has quit [Remote closed the connection]
yondalf_ has joined #ocaml
yondalf has quit [Read error: 60 (Operation timed out)]
yondalf_ has quit ["leaving"]
jajs has joined #ocaml
<DRMacIver>
Is there a good way to convert between an integer and its binary representation in ocaml?
<DRMacIver>
By 'good way' I mean library function I suppose.
<DRMacIver>
Modular arithmetic sounds like it will be horribly inefficient.
<bluestorm>
hum DRMacIver
_fab has quit []
<bluestorm>
do you know about the binary operators ?
<lde>
it has to share at least 23 properties with sml
<pango_>
I heard the english version never went in print
_JusSx_ has quit [Client Quit]
<dibblego>
is type inference optional? can I explicitly specify types?
<pango_>
static typing is probably the main difference with the other large family of functional language spawned from Lisp
<lde>
i don't think there are strict rules
<pango_>
dibblego: you can add type annotations, that will be added to the typing constraints... But not override what can be inferred from the remaining of the code
<lde>
just as for fp language
<lde>
uh, functional language
<dibblego>
ok, so if one were to write "hello world" (fib?), they'd download the compiler (name?) and I'll assume everyone uses emacs
<pango_>
ocaml provides two compilers (bytecode compiler ocamlc, native code compiler ocamlopt -where available-) and a toplevel, ocaml
<pango_>
for small tests you can directly use the toplevel, without any editor or compilation
<dibblego>
ok thanks - I just found "ocaml-core" as a debian metapackage and that seems to come with "everything"
<dibblego>
toplevel meaning an interpreter?
<pango_>
read-eval-print-loop, aka REPL
<pango_>
so the short answer is yes :)
<dibblego>
ta :)
<lde>
well, the standard ocaml tarball comes with "everything"
<lde>
s/standard/official/
<bluestorm>
pango_:
<bluestorm>
and you can use 'ocaml' as an interpreter