2007-03-21

<hcarty> ocaml_newbie: omlet is a nice vim setup for ocaml

2007-03-19

<hcarty> So it seems the ; ends the expr, whereas using let .. in does not? I think I was just running in to a terminology issue here.
<hcarty> failwith "error" rather that "let _ = something in failwith "error""
<hcarty> pango: Thanks for the pointer - I think it's the use of "something;
<hcarty> I think I see what is happening in the tutorial vs this example. Interesting.
<hcarty> But -- if 1 = 1 then "1" else let _ = 2 in failwith "here";; -- gives "1"
<hcarty> The tutorial says it does..
<hcarty> For if ... else ... statments, does the ... block need surrounding parens?
<hcarty> I'm doing some pretty heavy development and refactoring at the moment, so I'm constantly commenting and uncommenting code blocks.
<hcarty> Yes, I'm looking in to how to do that now :-)
<hcarty> flux-: Thanks, that works well
<hcarty> I was happily using Omlet and vim, but I found it became much too slow with longer source files (a few hundred lines+)
<hcarty> I'm new to Emacs, so I'm not sure if I've done something wrong or if this is a limitation from elsewhere
<hcarty> Is it normal for Tuareg mode syntax highlighting to break when creating or deleting comments from an OCaml source file?

2007-03-16

<hcarty> So I guess I'm not really looking to copy the record, really.
<hcarty> Rather than making a long tuple, records seem like a cleaner way to go
<hcarty> I have a lot of data in various Bigarrays to pass around
<hcarty> Yeah, I think I can get what I need...
<hcarty> Nevermind, I think I found what I need
<hcarty> Or, I haven't yet found it I should say
<hcarty> Is there a shorthand for setting two records equal to one another, without typing out all of the elements? I think I read about one, but I can't find it.
<hcarty> pango_: Thanks for your continued assistance. You've been a huge help every time I've asked questions on here.
<pango_> hcarty: I doubt there's much different in performance between records and tuples, the memory layout is the same
<pango_> hcarty: I think I've read objects can be (ab)used to work around the need to use different field names in different record types
<hcarty> Is there a significant performance hit using records rather than tuples?
<hcarty> Wow, it seems that nesting records can make for some interesting definitions
<pango_> hcarty: I'd say yes, logically it can only remove some polymorphism
<hcarty> I'm rather new to this type inference thing, though I really like it
<hcarty> pango_: Does that mean that a type annotation would be used to make what would be 'a and make it some specific type?
<hcarty> pango_: Thank you very much. This is just what I needed
<hcarty> Would a definition look something like this then: let x = {Foo.a = 1; Foo.b = 2};;
<hcarty> Ah, ok
<hcarty> pango_: Curses, I was afraid that would be the answer. Thanks for the information
<hcarty> ex. type foo = {a: int; b: int};; type goo = {a: int; b: int; c: float};;
<hcarty> How do you disambiguate a record definition when you have multiple records defined with some matching element names?

2007-03-12

<mbp> hcarty: thanks anyway
<hcarty> Unfortunately, getting much more complicated than that goes beyond my current knowledge level
<hcarty> If you're using the toplevel (ocaml foo.ml) you could try using #use
<mbp> hcarty: I am generating some code to create a dynamic graph. The code for the graph needs some functions definitions before and after it
<hcarty> Not that I know of. What are you trying to accomplish with the include?
<mbp> hcarty: is there no built-in way?
<hcarty> mbp: You could use cpp or some other preprocessor

2007-03-10

<hcarty> Smerdyakov: Thanks, I'll take a closer look then.
<hcarty> So having that direct mapping takes a lot of headache out of the process
<hcarty> I'll have to take a look at that then - I'm reading large binary data sets of various type (16/32/64 bit ints, 32 and 64 bit floats)
<hcarty> So it's useful when wrapping libraries, among other things
<hcarty> Bigarray can be mapped directly to memory allocated for a C/Fortran array
<hcarty> If mlton does have something like that though, then the supposed speed increase when using tools like functors would be very attractive
<hcarty> Smerdyakov: If you're around - Does mlton have something along the lines of OCaml's Bigarrays? A large part of what I'm using OCaml for benefits from them, so without that I'd be reluctant to give mlton a shot.
<hcarty> flux-: Thanks - I think I found the post. That's unfortunate.
<flux-> hcarty, you can't, and I think I receal

2007-03-09

<hcarty> I can get one for bytecode-compiled code (ocamlrun -b) but not for the toplevel
<hcarty> How do you get a backtrace or code location for an exception in the toplevel?

2007-02-23

<tsuyoshi> hcarty: tuples and records are identical during runtime
<hcarty> flux-: Ok, thanks
<hcarty> Is there much or any performance hit when using records rather than, say, tuples to pass data around?

2007-02-21

<hcarty> Cool, thanks
<hcarty> love-pingoo:Sorry if I misunderstand - are you saying exceptions are faster?
<hcarty> You're welcome
<hcarty> datrus_: Are you trying to use: List.fold_right (fun a b -> a + b) [1;2;3] 4;;

2007-02-20

<hcarty> Regardless, it looks like it may just be simpler to use a bigarray and wrap the call to convert a given array in to a Bigarray
<hcarty> Is there a way to get an OCaml array length from the C FFI? I haven't found anything in the manual, but I may be missing something.
<hcarty> mbishop: You're welcome
<hcarty> Sorry, that should be '#use "topfind";;'
<hcarty> If you have findlib, you can use 'use "topfind";; #require "unix";;'
<hcarty> Then you may not have the library loaded - which I don't remember the syntax for at the moment
<hcarty> Once you do "open Unix;;" you don't have to use the Unix. prefix any more.
<hcarty> mbishop: Are you using "Unix.foo" to call functions, or just "foo"?

2007-02-16

<hcarty> beschmi: Thanks, I'll take a look
<beschmi> hcarty: i don't know if there is code folding for ocaml, but this one should work: http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
<hcarty> Is there a way to enable folding in tuareg mode? I'm relatively new to emacs, but I haven't found anything useful when searching online

2007-02-12

<stevan_> hcarty: I am finding the same issue, which is quite odd
<hcarty> Has anyone here had this problem before? Any suggestions?
<hcarty> I don't have trouble linking other libraries, and Str.* works in the toplevel
<hcarty> Error while linking foo.cmo: Reference to undefined global `Str'
<hcarty> Gives me:
<hcarty> ocamlfind ocamlc -package str foo.ml -o foo
<hcarty> I'm being told that the Str library isn't being linked in when I compile, though I am (trying to)

2007-02-09

<hcarty> Which is helpful when learning and playing with it
<hcarty> OCaml also has the benefit of being run as a (sort of) scripting language or as a compiled language
<hcarty> Plazma: It's kind of demonized in some places, but Perl may be another good option if you want something useful
<hcarty> Personally, I think programming in OCaml is a blast
<hcarty> It supports (and encourages) a very broad range of programming methods which will be helpful whether you settle on OCaml or some other language
<Plazma> hcarty, ive dabbled in many diff languages, but havent fully mastered one
<hcarty> Plazma: As one who is learning OCaml now as a 5th or 6th language, I think it would be a very good language if you're willing to deal with a potentially steep initial learning curve

2007-02-05

<hcarty> Good luck with the interview Smerdyakov

2007-02-02

<ulfdoz> hcarty: You can think about it as a transformer. For example, creating a binary tree from a list.
<ulfdoz> hcarty: For lists, map is often a functor.
<hcarty> ulfdoz: Thanks - I'm trying to see if they'll save me some code/copying and pasting
<ulfdoz> hcarty: Mac Lane, "Categories for the working Mathematician"
<ulfdoz> hcarty:
<hcarty> I'm trying to wrap my brain around them and implement something. Some extra examples would help and Google isn't providing much help.
<hcarty> Can you recommend any good docs, beyond chapter 2 of the OCaml manual, on functors?
<hcarty> Is there a way to match against "any of this variant type"?

2007-01-29

<hcarty> Ok, thank so much for your help
<hcarty> Is it possible to extract the "plain" Genarray.t from the tt value?
<hcarty> Ah... ok, I think I follow. I'll try it with my other code.
<hcarty> And I have to admit to being a little lost as to how to get ('a, 'b) Bigarray.kind out of this
<hcarty> http://0ok.org/test.ml is a short snippet of code which illustrates what I'm trying to do
<hcarty> I had to run for a bit, but I think I made some progress. I'm still getting type errors though and I'm not sure how to make the new variant type into a Bigarray.kind
<hcarty> I'm still in the learning stages with OCaml so I appreciate the help
<hcarty> much
<hcarty> pango and lmbdwr: Thank you both very mcuh
<lmbdwr> hcarty, try : type typeret = Cons of sometype | OtherCons of someothertype | ....
<hcarty> Do you know a method to get the same result? These can all be passed to Genarray.create, so I'm thinking that something should be able to be done here
<hcarty> match some_string with "UINT8" -> int8_unsigned | "FLOAT32" -> float32 | ... and so on
<hcarty> A string is returned from a C function, such as "UINT8" or "FLOAT32" that I want to use to generate a Genarray of the proper type
<hcarty> The bigarray will have some manner of numeric data in it
<hcarty> Sorry - I don't think I was clear with that
<hcarty> How do you write an function to do something like this?
<hcarty> However, trying to use a match str with ... gives me type errors
<hcarty> > int8_unsigned)
<hcarty> I want to find a bigarray type based on a string (ex. "UINT8" -
<hcarty> This seems to work properly, if it does what you want
<hcarty> lmbdwr: Could you use: match ([1;2;3],[2;4;5]) with (hd1::tl1,hd2::tl2) -> 1

2007-01-24

<hcarty> Other than wrapping everything two (or three) layers deep...
<hcarty> Has anyone else here faced this problem with other libraries and found a good way to get around it?
<hcarty> I'm having trouble with namespace collisions (int32 and friends, mainly) between OCaml's C interface and the HDF4 library

2007-01-21

<hcarty> Perhaps I can code up a little sugar to go around that and make it a little less verbose
<hcarty> mellum: Ah, ok... thanks.
<mellum> hcarty: yes, that should work
<hcarty> Without reverting to if ... else ...
<hcarty> Is there a way to match against a range? ex. match x with 1 -> foo | 2 .. 10 -> bar | _ -> goo

2007-01-20

<hcarty> pango: Thanks, I'll take a look
<pango> hcarty: maybe by also preprocessing some OCaml code with cpp ?
<hcarty> How do you get a #define'd constant exported from C to OCaml? Is this possible without creating new C code to tie it to a function or somesuch?

2007-01-19

<hcarty> I've been looking at omake, but setting things up to build properly is about as clear as mud to me at the moment
<hcarty> s/thsi/this/
<hcarty> I think that's what I have setup at the moment, though it's been a few months since I've been able to work on thsi :)
<hcarty> OCamlMakefile being that set of macros and whatnot, using (gnu)make?
<hcarty> Any recommendations for a build system? I'm working on a HDF library wrapper for OCaml.

2007-01-15

<hcarty> That could allow for some confusion - redefine (+) and (+.) to switch them around
<hcarty> OCaml does have the benefit of never (as far as I know) losing precision (float to int) accidentally
<hcarty> I'm still in the learning stages with OCaml, and every 100 lines of code or so flip between loving and hating it :-)
<hcarty> flux-: GCaml, perhaps? It's on the wikipedia page...
<flux-> hcarty, true
<hcarty> flux-: Creating a new operator could be handy too, in that case

2006-08-11

<hcarty> youknow365: I don't know if it will be of any use, but I think wyrd uses ncurses. I don't know how it is wrapped though.

2006-08-08

<hcarty> Speaking of un-invented ... is there anything special that needs to be done to use the extlib modules from an interactive ocaml session? #load "extlib/extLib.cma";; doesn't work for me. A subsequent open Std;; tells me Std is an unbound module.
<hcarty> I'm still early in the process though, and Haskell definitely has a lot going for it. Not the least of which is pugs :-)
<hcarty> dylan: Haskell is tempting... but this will eventually be for fairly large-scale number crunching... some numerical simulation work, and a ton of satellite data analysis/manipulation. So the (supposed?) speed benefits of OCaml over Haskell have pushed me in this direction.
<dylan> hcarty: haskell has the notation you mention, for the record. :)
<hcarty> Ok, thanks for the tip. It's difficult finding and breaking some of these old habits.
<hcarty> I've been using Perl for a long time, and the quick syntax is handy and readable for me. I've started learning OCaml for thesis/research related work - I'd like to avoid Fortran/C as much as possible.
<hcarty> I can... force of habit mainly :-)
<hcarty> Smerdyakov: Thanks, I'll look around
<Smerdyakov> hcarty, not that I know of in the main language... I'm sure someone has made a camlp4 extension for it.
<hcarty> Is there a shorthand syntax in OCaml for generating a list or array of values, like [ 1 .. 100 ] in Perl?