<nullcat>
but usually it's written as let () = fprintf oc "P2\n%d %d\n%d\n" 5 5 255
<nullcat>
also, if you are not playing in toplevel and want to compile to bytecode or machine code, you don't have to add two semicolons after every statement
<mhammons>
you mean if i use let () = I don't have to use all those semicolons?
<nullcat>
um every statment
<mhammons>
oh
<nullcat>
let vtk ... let pgm... let oc..
<mhammons>
i was having a weird error with fprintf saying i gave it too many arguments earlier, that why I added them
<nullcat>
um...
<nullcat>
not sure why
<mhammons>
yeah, I'll remove them and see what happens
<nullcat>
it shouldn't make any difference
<nullcat>
e
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
leafac has quit [Ping timeout: 246 seconds]
chambart has quit [Ping timeout: 240 seconds]
badkins has quit []
<pippijn>
Drup: ping
MercurialAlchemi has quit [Ping timeout: 272 seconds]
idegen has quit [Quit: Leaving.]
<mhammons>
how do I get rid of this unbound module extlib error? I'm using ocaml -I +extlib mysourcefile.ml, and I installed extlib through opam
<Drup>
pippijn: pong
<pippijn>
Drup: pm?
<Drup>
not received anything
<pippijn>
I don't pm people without permission
<pippijn>
so this is a request for permission
<Drup>
I grant you the permission to pm me. :3
oscar_toro has joined #ocaml
sivoais_ has joined #ocaml
AdmWiggin has joined #ocaml
AlexRussia has quit [Ping timeout: 264 seconds]
iZsh has quit [Ping timeout: 264 seconds]
tianon has quit [Ping timeout: 264 seconds]
sivoais has quit [Ping timeout: 264 seconds]
LnL has quit [Ping timeout: 264 seconds]
LnL_ has joined #ocaml
robink_ is now known as robink
LnL_ is now known as LnL
iZsh has joined #ocaml
sivoais_ has quit [Read error: Connection reset by peer]
sivoais has joined #ocaml
AlexRussia has joined #ocaml
orbitz_ has joined #ocaml
orbitz has quit [*.net *.split]
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
darkf has joined #ocaml
hilquias has joined #ocaml
rand000 has quit [Quit: leaving]
struk has joined #ocaml
AdmWiggin is now known as tianon
swgillespie has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
swgillespie has quit [Client Quit]
hilquias` has joined #ocaml
idegen has joined #ocaml
hilquias has quit [Ping timeout: 244 seconds]
Algebr has joined #ocaml
rgrinberg has joined #ocaml
<Algebr>
Someone familiar with core's Reader/Writer/Pipes stuff care to help me out. http://pastebin.com/vG8WUdwB This sort of works but I get an exception saying that ((exn ("can not read from reader" ("in use" which is related to line 12.
<Algebr>
<struk>
rgrinberg: u da man dude! finally setup that vim-ocaml project. yay for _oasis syntax support. Your instructions were confusing for a green vim user such as myself though. I set it up with "cd ~/.vim/bundle && git clone git@github.com:rgrinberg/vim-ocaml.git" . (I have pathogen installed, perhaps that is why it worked)
<struk>
Algebr: looking. I used pipes recently for something, so maybe my knowledge is applicable..
<rgrinberg>
struk: I should have put some instructions for pathogen users too :P pathogen is old school and i've never used it
<rgrinberg>
so I thought users would figure it out
<struk>
what should I be using these days? I want to onboard some vim people onto ocaml at work, so any tips helpful
<rgrinberg>
struk: you're onboarding them with vim AND ocaml at the same time?
<rgrinberg>
good luck :P
<rgrinberg>
struk: you should probably upgrade from pathogen to one of those fancy plugin managers they have these days
<struk>
of course majority use eclipse, which is unfortunate. one uses sublime though, hoping merlin works decent w/that
<rgrinberg>
struk: yeah that's more than a little culture shock
<rgrinberg>
in my experience, if the person is coming from using scripting languages. e.g. python, perl. they're much more content with the tooling
<rgrinberg>
(and amazed by accurate auto complete!)
<struk>
yeah I could see that
<struk>
Algebr: so, iter_without_pushback...you really mean to invoke that on each recursive call?
<Algebr>
struk: I want to be able to take input from stdin while still getting any data from the other side and printing it to screen.
<rgrinberg>
Algebr: you should still call iter_withouh_pushback only once
<struk>
yeah, it might be run several at time in your loop, as the first won't necessarily terminate
<rgrinberg>
and calling Reader.pipe multiple times is also fishy
<Algebr>
okay, I can remove that. Any suggestion on how I can get either side updated automatically while also being able to read in from stdin?
<struk>
what do you mean by side exactly? are u just trying to read stdin w/o blocking, or ..?
<rgrinberg>
struk: i think he's doing an stdin prompt while trying to write to it
<Algebr>
yes
<rgrinberg>
Algebr: i don't think you're doing anything wrong but making terminal ui's isn't my strongpoint...
<Algebr>
I want to read from stdin on either side of a client/server and have either one be updated whenever the pipe is updated.
<rgrinberg>
you could probably accomplish this relatively easily wih lambda-term
<Algebr>
Not so much terminal ui but general idea..isn't there some way to register a callback to a pipe?
badon has quit [Disconnected by services]
badon_ has joined #ocaml
<rgrinberg>
Algebr: Pipe.iter/iter_without_pushback is that...
<struk>
yeah, hence why it doesnt belong in the rec loop, most likely
<Algebr>
will try now, my concern is that it won't happen each time, ie more than once?
<struk>
you can capture the deferred computation and see if it is realized
<rgrinberg>
Pipe.iter ~f will call f for every element in the pipe
<struk>
that too :)
idegen has quit [Quit: Leaving.]
<Algebr>
omg
badon_ has quit [Ping timeout: 265 seconds]
<Algebr>
so simple, code worked just by moving the iter outside the loop. I knew I was so close.
<struk>
sweet, I love being right
<struk>
:D
<Algebr>
+!
<rgrinberg>
i love being left!
<struk>
I was using pipes then I realized I can actually completely avoid them with sneaky little combinations of monads. I don't know what the implication is on the scheduler/queue though
badon has joined #ocaml
<struk>
in other news, git has all but deprecated my use of rsync and scp lately, and I love it
<struk>
I was looking for a simple ocaml git api but the mirage one was over my head at first glance
<struk>
I have zero experience with that, and if I'm integrating any native crap into ocaml, it's going to be coherence+POF, as that will open floodgate at work for me
<Algebr>
rgrinberg: what would be the purpose of using git c apis?
<struk>
also, I would prefer a pure ocaml git solution, but something higher level than mirage's version
<Algebr>
to create a different git command line written in ocmal?
<struk>
for me, I just want to never exit utop
<rgrinberg>
Algebr: as opposed to using mirage/ocaml-git?
<Algebr>
yea, or just the git command line tool
<rgrinberg>
sure, if your use case is simple enough for the git command line tool you should stick to that
<rgrinberg>
as for vs. mirage/ocaml-git, libgit is more extensive, better tested, has a ton of docs
<rgrinberg>
not that there's anything wrong with the pure ocaml solution. But I've used scripting languages enough to get used to relying on c api's :P
<struk>
Algebr: I went hours without leaving utop the other day. was awesome. but using git was still klunky, among some other typical command line tools
<rgrinberg>
struk: let me introduce you $ git repl
<struk>
rgrinberg: what is thaT?
<rgrinberg>
struk: it's a cool little gimmick
<Algebr>
what is that, git doesn't know about a git repl command
<rgrinberg>
Algebr: you must not have git-extras installed
<rgrinberg>
it's just a tiny repl for git subcommands
<rgrinberg>
e.g. branch
<struk>
nor do I apparently
<Algebr>
rgrinberg: okay i got it, what's something cool
<rgrinberg>
Algebr: it's really nothing special
<Algebr>
ah, its nice, now I don't have to keep typing git as the prefix
<rgrinberg>
Algebr: that's about it..
<struk>
actually this is awesome
<struk>
let git () = Sys.command "git repl" ;;
<struk>
in utop
<Algebr>
ha
<struk>
then git();; pull -ff <ENTER> CTRL-D
<struk>
back to utop
<struk>
tada
<struk>
its not a bad tactic to drop into other shells when needed
<struk>
thanks
<rgrinberg>
struk: so you use core at work?
<struk>
rgrinberg: eh, not a real dependency yet, but it could be. I use core/async personally tough
<struk>
*though
<Algebr>
rgrinberg: getting git-extras is amazing
<rgrinberg>
i see, so you like it but don't consider it a real requirement.
<struk>
core I'm whatever about. async I like though
<rgrinberg>
i tend to agree, but when showing ocaml to other people i find it necessary to quickly dispel to them that simple things are painful with the stdlib
<struk>
I like containers better than core, for most part, because I have more control over its fate and it doesn't annoy people to depend on it
<rgrinberg>
Algebr: there's some cool things in there :P
<struk>
wow theres alot of stuff...
<rgrinberg>
$ git show-unmerged-branches <3
swgillespie has joined #ocaml
<Algebr>
this is a god send
<struk>
seriously, I have a colleague who wrote an algorithm for that because he didn't know extras existed
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
<dora-molly>
struk: sublime support is not totally satisfying
<dora-molly>
struk: although I can provide support to improve it, I just need report from users :P
<rgrinberg>
dora-molly: aren't you sick of learning api's of editors you will never use?
<mhammons>
i do not have ocaml installed through my package manager anymore
<mhammons>
i'm doing everything through opam
<companion_cube>
where's your syntax error?
<mhammons>
line 1
<mhammons>
and the error is literally "Error: Syntax error"
<companion_cube>
ocaml src.ml does that?
<mhammons>
yeah, though technically it's named learning.ml
<mhammons>
ocamlfind ocamlc -linkall -package extlib learning.ml -o learning is the command I'm using
<companion_cube>
you're confusing "ocaml" (interactive use) and "ocamlc" (bytecode compilation)_
<companion_cube>
just try "ocaml learning.ml", if you have only one file and don't care about perf
<companion_cube>
otherwise you need to remove the first lines of the file (they are only for interactive use), and use something like "ocamlfind ocamlopt -linkall -package extlib learning.ml -o learning"
<companion_cube>
(native compilation)
<mhammons>
ok, so I removed the required and such
<mhammons>
and I'm back to "Reference to undefined global `ExtString'"
<mhammons>
and yeah, I'd like to have a compiled program
rand000 has joined #ocaml
<companion_cube>
hmm, try and replace 'linkall' with 'linkpkg'
<companion_cube>
(an option that comes from ocamlfind)
<companion_cube>
you don't seem to benefit much from using Stream :)
<mhammons>
No, not yet
<companion_cube>
(ok, full disclosure: I have an iterator library based on unit -> 'a option)
<mhammons>
I'm trying to practice with them, because I'd like to read in a file as a list of bytes later on
<companion_cube>
sure
<Drup>
just use something else than Stream :D
<Drup>
rgrinberg: did you take a look at the lastest stuff on ocsigenserver/cohttp ?
rgrinberg has quit [Ping timeout: 258 seconds]
jeffmo has joined #ocaml
<mhammons>
so, what is a good option for searching through an in_channel till I find a certain line?
<mhammons>
aside from Stream
jeffmo_ has joined #ocaml
jeffmo_ has quit [Client Quit]
jeffmo has quit [Ping timeout: 244 seconds]
Hannibal_Smith has joined #ocaml
Cyanure has joined #ocaml
<flux>
1) read line 2) determine if it's the one you want? 3) if not, recurse :)
<mhammons>
flux: well, I meant more how I do that and quit when I hit the one I want
<mhammons>
without using a mutable variable
Haudegen has quit [Ping timeout: 246 seconds]
<flux>
well, one way to do it: let rec iterate_till_matches f = let line = input_line stdin in if not (f line) then iterate_till_matches else line
ingsoc has quit [Ping timeout: 246 seconds]
Submarine has joined #ocaml
Submarine has joined #ocaml
<companion_cube>
you can do that with iterators
<flux>
let matching_line = iterate_till_matches (fun line -> line = "hello")
<companion_cube>
gosh, didn't write Gen.IO.lines
chambart has quit [Ping timeout: 244 seconds]
sdothum has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
Haudegen has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
badon has quit [Ping timeout: 265 seconds]
<mhammons>
ok, so I've got new code that works, but I should learn to write classes now: http://pastebin.com/1rkKu6UE
<companion_cube>
looks fine, but what do you mean, "classes"? you mean the object-oriented part of ocaml?
<companion_cube>
imho, objects in ocaml are not a good topic for beginners
<dmbaturin>
And you can live happily without them even if you are not a beginner.
A1977494 has joined #ocaml
<mhammons>
yeah, I mean the object oriented part
<mhammons>
though what I'm really looking for is a way to replace my string list list with an object that has names for both of the elements
<dmbaturin>
You can use a record for that.
<dmbaturin>
type foo = { bar: string list; baz: string list }
<mhammons>
that works just fine
Gama11 has quit [Read error: Connection reset by peer]
A1977494 has left #ocaml [#ocaml]
rgrinberg has joined #ocaml
<dmbaturin>
Also, "if (List.length l) = 2 then l" is better written as "match l with [_; _] -> l | ...".
<dmbaturin>
(or _ :: _ :: [], if you prefer)
leafac has quit [Ping timeout: 256 seconds]
onebooks has joined #ocaml
<mhammons>
dmbaturin: well, I'm probably gonna switch to a tuple
<dmbaturin>
Even more important with List.hd and List.tl that raise an exception for empty lists, so destructuring lists with pattern matching is not just more consice and expressive, but also safer (and the compiler will tell you if matching is not exhaustive).
leafac has joined #ocaml
rgrinberg has quit [Ping timeout: 276 seconds]
<mhammons>
dmbaturin: is there a way to match on options?
<companion_cube>
match x with None -> ... | Some y -> ...
leafac has quit [Ping timeout: 250 seconds]
<dmbaturin>
There is nothing special about option, you can match on it like any other type. It's just "type 'a option = Some of 'a | None"
<mhammons>
ok nice
<dora-molly>
flux: Merlin can now report documentation for item under cursor
<companion_cube>
oh
<mhammons>
dmbaturin: can you match on stuff like String.exists?
<companion_cube>
dora-molly: what is the vim shortcut ? :>
<dora-molly>
during completion?
r0ckn3ur0tik0 has joined #ocaml
leafac has joined #ocaml
r0ckn3ur0tik0 has quit [Remote host closed the connection]
rock_neurotiko_ has joined #ocaml
<companion_cube>
oh ok
rock_neurotiko_ has quit [Remote host closed the connection]
rock_neurotiko has joined #ocaml
onebooks has quit [Excess Flood]
onebooks has joined #ocaml
<flux>
dora-molly, 2.2?
<dora-molly>
yep
rock_neurotiko has quit [Remote host closed the connection]
rock_neurotiko has joined #ocaml
<adrien>
I see merlin is trying to catch up with firefox version numbers
<flux>
hmph, the new Merlin says "Uninterpreted extension 'lwt'"
<dora-molly>
adrien: how?
<flux>
well, if it's trying it, it's not doing a very good job?
<dora-molly>
did you load a ppx to process your lwt annotations?
<flux>
yes.. but I guess it was something in my emacs state, restarting merlin seemed to fix it, though I did reopen the buffer before
<dora-molly>
strange
leafac has quit [Quit: Leaving.]
<adrien>
dora-molly: just joking: you're pushing versions out quite frequently
<adrien>
but not yet major ones every 3 months
<dmbaturin>
mhammons: You can match on values that functions return, as in match Foo.bar x with ... You can also use guarded patterns, match x with _ when x > 0 ...
leafac has joined #ocaml
<mhammons>
dmbaturin: that's what I was looking for :)
leafac has quit [Ping timeout: 264 seconds]
<companion_cube>
if/then/else are still useful sometimes
idegen has joined #ocaml
seanmcl has joined #ocaml
rgrinberg has joined #ocaml
<mhammons>
So, here's the new version of my program, any suggestions on making it a little smaller? http://pastebin.com/zMSbdz46
rgrinberg has quit [Ping timeout: 264 seconds]
<flux>
well, at least you should close_in the file even if End_of_file is raised
srcerer_ has joined #ocaml
srcerer has quit [Ping timeout: 245 seconds]
rock_neurotiko has left #ocaml ["http://quassel-irc.org - Chatee cómodamente donde sea."]
<flux>
maybe you could write function to reduce duplicity and the function would be called like: coalesce [get "DIMENSIONS" (function _::tail -> Some tail | _ -> None); size]
<flux>
coalesce would be function: let rec coalesce xs = match xs with [] -> None | Some x::_ -> Some x | _::rest -> coalesce rest
rock_neurotiko has joined #ocaml
rock_neurotiko has left #ocaml [#ocaml]
<flux>
let get line name f = if String.exists line name then f (String.nsplit line " ") else None
<flux>
and along these lines.. ;-)
ingsoc has joined #ocaml
<flux>
..so probably the match (line, tup) with pattern guards would go away..
<dora-molly>
and you problably want ic after input_byte on 64
keen__________ has joined #ocaml
keen_________ has quit [Ping timeout: 246 seconds]
<mhammons>
ok, got everything fixed :)
rgrinberg has joined #ocaml
AndChat|618624 has joined #ocaml
<AndChat|618624>
Modules are essentially just a superset of records right? I mean they are both basically the same thing
AndChat|618624 is now known as TSMI
octachron has joined #ocaml
shinnya has quit [Ping timeout: 255 seconds]
rgrinberg has quit [Ping timeout: 255 seconds]
mhammons has quit [Quit: Konversation terminated!]
mhammons has joined #ocaml
<dmbaturin>
TSMI: Modules have nothing to do with records.
hay207 has joined #ocaml
<companion_cube>
they have the same implementation underneath; but modules contain much more things (types, sub-modules, ...) and have some notion of subtyping
<TSMI>
I don't follow. Theyre a named collection of static labels each of which correspends to some ocaml datatype
<hay207>
hello guys, what to do in codeblocks to be able to compile an ocaml project?
<hay207>
i get no errors
<hay207>
but this: Linking stage skipped (build target has no object files to link)
<dmbaturin>
Well, you can't use modules as values, neither records have anything like signature matching or functors.
<ggole>
You can use modules as values.
<dmbaturin>
hay207: I never used codeblocks, but if it can invoke "make" as build command, it should work with ocamlbuild/oasis or something else that can produce makefiles.
<dmbaturin>
Some IDEs allows you to specify custom build commands, in this case it may work with any build tool.
milosn has joined #ocaml
<TSMI>
Right, modules are first class values. Which makes me wonder what function records serve
<ggole>
Try programming with modules and find out :)
<dmbaturin>
Even though they are first class, you can't really use them in the same fashion as records with the same ease. :)
<hay207>
guys i am new to ocaml, , i tried renaming the file name into test.ml
<TSMI>
they have a more verbose syntax and you can't pattern match on them
<hay207>
what to do exactly to make ocaml work with codeblocks
<hay207>
or someone post a site explaining the steps
<ggole>
And polymorphism is a bit problematic
<dmbaturin>
hay207: You may as well be the first person to ever try that.
<hay207>
ocaml with an IDE?
<dmbaturin>
Every IDE has its own quirks when it comes to language support. Some make it easy, some don't.
<hay207>
or try what
<ggole>
TSMI: unifying them wouldn't be impossible: Andreas Rossberg's 1ML attempts to do something of the sort
<dmbaturin>
hay207: With codeblocks.
<hay207>
k then eclipse
<dmbaturin>
I've seen people doing eclipse and xcode integration at least.
<hay207>
how to make ocaml work with eclipse
<hay207>
what to write in executable in eclipse
darkf has quit [Quit: Leaving]
obadz has quit [Ping timeout: 256 seconds]
<dmbaturin>
I'd also ask the question if it's worth the effort to make it work with eclipse.
<hay207>
xcode i dont use it, using linux
obadz has joined #ocaml
<hay207>
i think ide's try to reduce coding efforts
<hay207>
i will ask in #eclipse then
<hay207>
thanks dmbaturin
<dmbaturin>
It will not give you things people usually use IDEs for, like drag and drop GUI designer.
<dmbaturin>
Integrating things like merlin (type display and completion) is likely to be _harder_ than with vim and emacs.
contempt has quit [Ping timeout: 252 seconds]
Hannibal_Smith has joined #ocaml
obadz has quit [Ping timeout: 245 seconds]
obadz has joined #ocaml
willy_ has joined #ocaml
hay207 has quit [Ping timeout: 256 seconds]
wwilly has quit [Ping timeout: 264 seconds]
rgrinberg has joined #ocaml
hay207 has joined #ocaml
obadz has quit [Ping timeout: 264 seconds]
obadz has joined #ocaml
rgrinberg has quit [Ping timeout: 276 seconds]
obadz has quit [Ping timeout: 256 seconds]
obadz has joined #ocaml
ingsoc has quit [Quit: Leaving.]
Haudegen has quit [Ping timeout: 246 seconds]
contempt has joined #ocaml
obadz has quit [Quit: leaving]
obadz has joined #ocaml
<octachron>
ggole: Few weeks ago you mentionned that there was a potential issue with local open within pattern (i.e. M.(pattern) ). Do you happen to remember what was the issue?
<ggole>
match foo with M.{ x; y } -> ... is a syntax error
<ggole>
Well, same with [] and ()
<ggole>
I can't remember if I checked whether this is still the case in 4.03
<octachron>
true, but is there any obstruction to the existence of this syntax?
<ggole>
Not sure
<octachron>
It is still the case in 4.03. I am playing with a patch that add this local open syntax.
<ggole>
There could be an objection that M.(...) is sugar for let open M in ..., and that doesn't make sense in patterns
<ggole>
eg, the sugar would be quite different on the pattern and expression sides
obadz- has joined #ocaml
hay207 has quit [Ping timeout: 264 seconds]
<ggole>
I don't actually think that's a very strong objection, but it might be worth asking the maintainers what they think
Haudegen has joined #ocaml
BitPuffin|osx has joined #ocaml
obadz has quit [Ping timeout: 276 seconds]
<octachron>
The main difference would be merely which construction between M.(..) and let open M in expr is the primitive one
kushal has joined #ocaml
<ggole>
Wouldn't the second imply including let expressions in patterns?
Haudegen has quit [Ping timeout: 265 seconds]
BitPuffin|osx has quit [Remote host closed the connection]
BitPuffin|osx has joined #ocaml
<octachron>
I was unclear. I was thinking that for pattern M.() would be the primitive construction and not let open M in ...
obadz- is now known as obadz
<apache2>
is TypeRex (typerex.org) useful, or what is the nicest emacs environment for ocaml development?
<octachron>
`let open .. in` construction in the pattern side would look quite foreign
shinnya has joined #ocaml
<ggole>
Yeah
<ggole>
apache2: most people seem fond of merlin
rgrinberg has joined #ocaml
<flux>
I undestand typerex has mostly fallen out of maintenance?
Anarchos has joined #ocaml
rgrinberg has quit [Ping timeout: 258 seconds]
Haudegen has joined #ocaml
<companion_cube>
well, new release of containers on its way
<apache2>
flux: that was what I was asking, thanks
<apache2>
ggole: isn't merlin a part of tuareg?
<companion_cube>
no, it's not
<zozozo>
companion_cube: with split packages or not yet ?
<companion_cube>
not yet
<companion_cube>
I'm not sure how to do it, it will break build systems :/
<ggole>
apache2: merlin has some light integration with tuareg, but it's a separate thing
<ggole>
You can install it from opam pretty easily.
<companion_cube>
so for now, I keep it the way it is
<companion_cube>
apache2: in particular, merlin works with other editors
<apache2>
I meantt to ask if it wasn't /incorporated/ in tuareg mode, but OK, I'll have a look at that too
<ggole>
tuareg is blissfully ignorant of merlin's shenanigans
rgrinberg has joined #ocaml
rock_neurotiko has joined #ocaml
seanmcl has quit [Ping timeout: 265 seconds]
rgrinberg has quit [Ping timeout: 256 seconds]
Tamae has quit [Ping timeout: 276 seconds]
rock_neurotiko has left #ocaml ["http://quassel-irc.org - Chatee cómodamente donde sea."]
<flux>
mhammons, I don't think you can do it this way. format strings are evaluated at compile time, and the contents of that string is constructed at runtime.
<mhammons>
damn
<flux>
while there is a way to concatenate format strings, I don't think it's applicaple here..
<mhammons>
well I put in the large, nasty version and it works, but I wish this way worked
<ggole>
You can construct format strings at runtime
<flux>
I think a reasonable solution would be: construct your template string as you do now, and then use some String.replace "%s" yourstring
<ggole>
But that's not usually a great thing to do
<flux>
ggole, but he has a list of strings.. can you concatenate that?
<mhammons>
is there a way to print a byte to a file?
<ggole>
Yeah, there's some conversion (I think in Scanf?)
<ggole>
Scanf.format_from_string
<mhammons>
just fprintf oc "%c" char?
<ggole>
You have to give a format string with the expected type though
<flux>
ggole, right, that could actually work here
<flux>
mhammons, that works, there seems to be also output_byte
<ggole>
And if the type of the constructed string you pass in doesn't match, you get an exception.
<flux>
and it's not in the Scanf module but rather in Pervasives
<struk>
companion_cube: "au BufRead,BufNewFile *.mlt set filetype=ocaml "
<ggole>
?
<mhammons>
so basically (format_from_string (String.join "\n" header))?
<ggole>
format_from_string isn't in pervasives?
<flux>
ah, it's different function, format_of_string :)
<struk>
companion_cube: hacked into my vimrc, trying to make vim-ocaml support it now
<flux>
ggole, so should this work? Printf.printf (Scanf.format_from_string ("%s" : string)) "hello" doesn't.
<flux>
right :). so mhammons code would become: Printf.fprintf oc (Scanf.format_from_string (String.join "\n" header) "%s%d")) ..
<mhammons>
wow
mhammons_ has joined #ocaml
<struk>
ggole: obj magic wouldn't give you those sort of compiler errors though, so it's better, right?
mhammons__ has joined #ocaml
<flux>
%identity uses one finds from the OCaml standard libraries are safe.. except for Obj.magic :)
mhammons has quit [Quit: Konversation terminated!]
<ggole>
Actually looking at the type, it seems to be safe
<ggole>
It doesn't take a string at all!
<flux>
yes, that's why it din't work :)
mhammons_ has quit [Ping timeout: 245 seconds]
<rgrinberg>
struk: what's mlt?
<rgrinberg>
people stil use kaputt?
<flux>
what's the hip testing framework all young kids use?
<rgrinberg>
flux: ounit
<rgrinberg>
or it's prettier and younger sister - alcotest
slash^ has quit [Read error: Connection reset by peer]
<companion_cube>
:D
<rgrinberg>
and i guess c-cube's quickcheck for property testing
* companion_cube
tends to use qtest for simple things, though
<rgrinberg>
companion_cube: no ppx_test?
mhammons__ is now known as mhammons
<companion_cube>
well, it's on code that should be compatible 4.0x
<companion_cube>
(containers)
<rgrinberg>
i can't wait for 4.03 to start dropping non-ppx ocaml everywhere :P
<mhammons>
ppx?
<struk>
rgrinberg: ha yes a new project does
<Anarchos>
flux final users ?
<rgrinberg>
struk: i could add set ft=ocaml for *.mlt files in vim-ocaml btw
mengu has joined #ocaml
<struk>
rgrinberg: yeah I did that in my vimrc but didn
<rgrinberg>
i'm just not sure sure if that extension is used for other filetypes perhaps
<companion_cube>
mhammons: a recent preprocessing system for ocaml
<struk>
't know where it belonged in vim-ocaml
<struk>
rgrinberg: is there a set if unset concept in vim? that would be fine w/me too
<mhammons>
nice
<rgrinberg>
struk: i'm not sure. but that won't work if everydoes it right?
<rgrinberg>
struk: and it's also dependent on plugin loading order
<struk>
rgrinberg: honestly I seriously doubt any vim users would need mlt to mean something else. scouring the internet now and its not popular beyond ocaml world
QuanticPotato has joined #ocaml
<rgrinberg>
struk: fine :P
<struk>
rgrinberg: :) I don't care that much, I can always fork and pin the repo at work any how :)
sepp2k has quit [Quit: Leaving.]
<rgrinberg>
struk: i just pushed a commit to add .mlt
<struk>
so if you think it's pollulting vim-ocaml, just leave it out
<companion_cube>
struk: well some hipster ocaml users might use melt (a LaTeX ocaml frontend)
<companion_cube>
.mlt doesn't sound absurd for melt files :p
<rgrinberg>
struk: do you use syntastic?
<struk>
companion_cube: dang ur right
<struk>
rgrinberg: yeah I do.
<rgrinberg>
struk: wondering if it's worth the effort to add syntastic syntax checking for _oasis files
ggole has quit []
<struk>
rgrinberg: well, your change works. thanks!
<companion_cube>
rgrinberg: ♥
<struk>
rgrinberg: I don't think oasis is disappearing over night..if anything it's proliferating..so..worth it! I think
<rgrinberg>
oasis dissapearing over night would be too awesome
Gama11 has joined #ocaml
robink_ has quit [Ping timeout: 248 seconds]
<companion_cube>
well that'd give a big incentive to many people to contribute to assemblage real quick
robink_ has joined #ocaml
hay207 has joined #ocaml
<adrien>
can we avoid spending some time without anything that gets the job done most of the time?
willy_ has quit [Quit: This computer has gone to sleep]
<companion_cube>
adrien: come on, you're being too pragmatic! :D
<adrien>
:)
struk has quit [Ping timeout: 244 seconds]
<nullcat>
anyone has experience with nocrypto?
struk has joined #ocaml
struk has quit [Ping timeout: 265 seconds]
<nullcat>
should my library handle both lwt and async? based on rgrinberg's experience with cohttp, I tend not to do that...
<rgrinberg>
nullcat: otter you mean?
<nullcat>
yes
struktured has joined #ocaml
<rgrinberg>
i would say not to bother until someone explicitly shows some interests
<nullcat>
then this means I should abstract out IO
<nullcat>
do abstract now... or it will be painful to refactor later?
<rgrinberg>
it will be easy to refactor later because refaactoring is easy in ocaml :P
<nullcat>
ok
<companion_cube>
easy but boring
<companion_cube>
tedious*
badon has joined #ocaml
cmtptr has quit [Quit: leaving]
<l1x>
hi
cmtptr has joined #ocaml
<l1x>
is there a way to replace the nth character in a string?
<rom1504>
yes
<cmtptr>
yes.
<nullcat>
let s = "str" in s.[0] <- 'b'; s;;
<nullcat>
gives you "btr"
<nullcat>
or in 4.02, do "let s = "str" in Bytes.set s 0 'b'; s;;"
<blech_>
nullcat, I've been playing with nocrypto this weekend
<blech_>
what are you trying to do?
MercurialAlchemi has quit [Ping timeout: 256 seconds]
<nullcat>
so i will use SHA1 module, and keep feeding it. call `digest` when i want the result?
<blech_>
I think you call get
<nullcat>
then ``hmac`` function is not used..
<nullcat>
ok get
<blech_>
I'll play around in utop, one sec
<nullcat>
the problem is that i don't understand what is hmac_sha1, is it some sort of.. extension to sha1?
<nullcat>
don't know much about cryptography
Cyanure has quit [Remote host closed the connection]
<blech_>
being relatively new to this myself, I don't have a great understanding of the details I'm sorry. Here's a question for you, could you not wrap nocrypto's hmac to replicate that interface?
<blech_>
i.e. init = new instance of internal cstruct/bytes, feed = concat, result = hmac(internal storage)
QuanticPotato has quit [Ping timeout: 276 seconds]
<nullcat>
i can remove cryptokit and use nocrypto only.
<blech_>
also in response to your earlier statement from what I understand sha1/md5 and such are just the hashing algorithms that you can swap out and HMAC is a specific way of generating a hash that includes a secret key in a safe way
<l1x>
well you can do a let in block and create a new bytes there and return that
<nullcat>
yeh..
<nullcat>
mutable string is a problem but in 4.02, you can pass -safe-string to toplevel or compiler to check this
<companion_cube>
or safe_string in _tags file
<nullcat>
companion_cube: so is there a function now that can do immutable string set?
<nullcat>
like, set returns a new string
<nullcat>
and does not change the original one
<l1x>
let s = "str" in for i=0 to ((Bytes.length s) - 1) do print_endline (let ss = (Bytes.copy s) in Bytes.set ss i '.';ss); done ; print_newline ();;
<l1x>
you can do this
<nullcat>
yes definitely you can
<companion_cube>
nullcat: not that I know of, although you can write it using String.init
<companion_cube>
let set s i x = String.init (fun j-> if i=j then x else s.[j]) (String.length s)
<nullcat>
yeah...
<nullcat>
l1x: so the above function is immutable set..
<l1x>
isnt there all of the variables immutable by default?
<l1x>
(i am brand new to ocaml)
<companion_cube>
l1x: the variables are, the things they point to, not necessarily
rock_neurotiko has joined #ocaml
<nullcat>
yeah, this is a shame...
<companion_cube>
e.g. let x = [| 1; 2 |] in ...
<companion_cube>
here, x is a binding to a mutable array
<companion_cube>
that's not a shame (except for strings indeed)
<companion_cube>
ML is impure, and that's cool
<nullcat>
string is still not. I remember they want to change it to immutable in 4.03?
<nullcat>
yeah i mean mutable string is a shame
<nullcat>
other things, like array, ref. I like them
<l1x>
companion_cube: i see, can I make it immutable?
<companion_cube>
safe-string does this
<nullcat>
$ocaml -safe-string
<nullcat>
open toplevel that when you mutate string, it errors
<l1x>
Option -safe-string separates the types string and bytes, making strings immutable.
<companion_cube>
you need to give people time to adapt to immutable strings
<companion_cube>
yep
<l1x>
but i use bytes
<l1x>
it is not a big deal tome
<companion_cube>
both are useful
<l1x>
just want to know from the safety point of view
<nullcat>
companion_cube: do you know there is something like async's don't_wait_for for Lwt?
<nullcat>
like val don't_wait_for: unit Lwt.t -> unit
<nullcat>
seems Lwt_unix.run can do that, but it's os dependent?
<rgrinberg>
nullcat: if you want optimization work i can give it to you believe me ;)
<nullcat>
thanks!
<nullcat>
i understand.
systmkor has quit [Quit: Leaving]
<tobiasBora>
Does anyone knows a good way to configure tuareg mode to indent the comments ?
<tobiasBora>
I would like that emacs ident the multilines comments with the code, but it always come back to the beginning of the line so that I need to manually add spaces...
<rgrinberg>
tobiasBora: have you tried using ocp-indent to indent?
<rgrinberg>
i don't use emacs, but ocp-indent indents comments correctly for me in vim. should be the same in emacs
<tobiasBora>
rgrinberg: and you can use it with tuareg ?