ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.1 announcement at http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
<mhammons> hmm ok
<mhammons> but otherwise it's fine to have files like this: http://pastebin.com/yyK1Ach4
<nullcat> yes, i think it's fine
<mhammons> ok great :)
<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
<rgrinberg> vundle is the most popular
<rgrinberg> apart from that, it's merlin, ocp-indent (using dora-molly's plugin for it), and vim-ocaml
<struk> rgrinberg: no no, onboarding some vim uesrs with ocaml, but one of them is old school vim. he doesn't even use syntax highlighters
<struk> somehow he does with java, effectively. don't ask me how
<struk> another set of users are emacs types but I'm hoping someone else champions that initiative for me
<Algebr> hardcore
<rgrinberg> struk: there's this to get started fast https://github.com/OCamlPro/opam-user-setup/blob/master/vim/vim.ml
<rgrinberg> this in general i should say, https://github.com/OCamlPro/opam-user-setup/
<struk> cool, thank you
<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
<rgrinberg> struk: would be awesome to ctypes bindings for https://libgit2.github.com/
<rgrinberg> *hint hint*
hilquias` has quit [Ping timeout: 244 seconds]
<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?
<rgrinberg> :D
<rgrinberg> you mean this btw? https://github.com/cynddl/sublime-text-merlin
<dora-molly> yes, yes :)
<struk> dora-molly: I will not bother you about it unless I get him to start using it. Thanks for your eagerness though :)
BitPuffin|osx has quit [Ping timeout: 245 seconds]
<dora-molly> struk: It's just that users are too quiet… If something doesn't work, they don't complain and either get used to it or drop it
<dora-molly> usually it's easy to fix, but I need at least to know :D
<struk> I'm not quiet, don't worry. hehe
<rgrinberg> aye, i whine hard too
<dora-molly> and that's nice :-)
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Algebr> mirage is providing so many nice libaries
<rgrinberg> vbmithr_: you around?
<dora-molly> just pushed a small fix for sublime-text-merlin, better update to the latest version if you update merlin
<dora-molly> (minor protocol change in the to-be-announced new version)
<struk> I noticed, thanks. I will probably engage my sublime colleague on tues
Algebr has quit [Remote host closed the connection]
<rgrinberg> i also have a friend who wants to give ocaml a try but he's using atom :P
<struk> I got a pal who uses notepad. can you get on that too please?
<rgrinberg> dora-molly: i wonder if you can compile merling using js_of_ocaml and run it native in atom
<rgrinberg> would be useless, but a cool stunt
<struk> atom is interesting one to get, could capture larger web dev audience
<rgrinberg> struk: ah yes, the big 5 of text editors
<rgrinberg> emacs, vim, sublime, atom, and notepad
<rgrinberg> struk: perhaps if there was a json parser written in batch it would be possible
<struk> I really had some "developers" at my company use notepad. I was like dude, at least use notepad++
<struk> notepad is the worst editor of all time, even the original dos "edit" command was drastically superioir
<dora-molly> rgrinberg: you need to implement a few unix primitives and I/O
<dora-molly> but there is no fundamental reason that could prevent that
<dora-molly> I considered running merlin in a webworker
<dora-molly> but I am not familiar enough with web to make that easy and I have no incentive other than "it's possible"
<dora-molly> :DD
<rgrinberg> dora-molly: whose idea was it to change `gd` to open a new window...
<dora-molly> let g:merlin_split_method = "never"
<dora-molly> does that fix your problem?
<rgrinberg> dora-molly: awesome! thanks
<rgrinberg> ^_^
<dora-molly> ahhhh, it's full of bugs
<rgrinberg> not even sure what happened to case_analysis()
<dora-molly> I thought I had checked, but its not the version I pushed
<dora-molly> pffff
<rgrinberg> dora-molly: have you seen this https://bitbucket.org/camlspotter/ppx_implicits ?
<rgrinberg> what is this craziness..
<dora-molly> :), it's a mix of "deriving/type-conv" like syntax extension and a roundtrip to the typechecker
<rgrinberg> could be useful for replacing jsc's <:sexp_of< ... >> stuff
<rgrinberg> (if modular implicts never make it)
<dora-molly> hop, push -f
<dora-molly> hmm
<dora-molly> it's precisely for that kind of stuff
<dora-molly> it's quite hackish, I wouldn't want to rely on that
<dora-molly> (tough it's fun as a toy project)
<rgrinberg> dora-molly: PS it seems like going to module defintion is still failing sometimes for me
<rgrinberg> screenshot about is when i hit `gd` on Arg
<dora-molly> rgrinberg: I'll take a look at that tomorrow, I am going to sleep
<rgrinberg> dora-molly: aye. NP. it's pretty late over there across the pond...
swgillespie has joined #ocaml
slash^ has joined #ocaml
Simn has joined #ocaml
nullcat_ has joined #ocaml
inf-gropeoid has quit [Quit: fix config]
inf-gropeoid has joined #ocaml
MercurialAlchemi has joined #ocaml
ollehar has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
swgillespie has joined #ocaml
wwilly has joined #ocaml
<vbmithr_> rgrinberg: now yes
<vbmithr_> rgrinberg: thanks for your PRs but I merged my dev branch
<vbmithr_> rgrinberg: I've just tried conduit and it removed tons of boilerplate code, just awesome
A1977494 has joined #ocaml
matason has joined #ocaml
tane has joined #ocaml
Gama11 has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
matason has quit [Ping timeout: 244 seconds]
jabesed has quit [Ping timeout: 256 seconds]
struk has quit [Ping timeout: 256 seconds]
A1977494 has left #ocaml [#ocaml]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ggole has joined #ocaml
rgrinberg has joined #ocaml
asQuirreL has joined #ocaml
rgrinberg has quit [Ping timeout: 250 seconds]
robink has quit [Ping timeout: 244 seconds]
robink_ has joined #ocaml
mhammons has quit [Remote host closed the connection]
Kakadu has joined #ocaml
<ollehar> No download of RWO? hm
nullcat_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mhammons has joined #ocaml
<mhammons> hi all
<mhammons> I'm having some opam troubles
<mhammons> I'm trying to install opam-doc, so I can have documentation on the stuff installed by opam
<mhammons> and I get this error
<mhammons> opam-doc is not available because your system doesn't comply with preinstalled & ocaml-version = "4.01.0".
<mhammons> my ocaml version is certainly 4.01.0, I used opam switch '4.01.0'
<mhammons> and I ran eval `opam config env` afterwards
<companion_cube> maybe there's a special switch for opam-doc, I don't remember
<companion_cube> anyway I'm not sure it's still relevant, since dsheets works on codoc
<mhammons> ?
<mhammons> i don't find either dsheets or codoc in opam
<companion_cube> it's work in progress
Anarchos has joined #ocaml
milosn has quit [Ping timeout: 258 seconds]
rgrinberg has joined #ocaml
<reynir> what's codoc? :)
<companion_cube> https://github.com/dsheets/codoc hopefully, the incoming ocamldoc killer
<flux> well, opam-doc isn't an ocamldoc replacement, so I'm not sure if they compete?-o
<flux> I would really like that all my installed packages came with manual pages :-)
<companion_cube> hmmm
<flux> and then the other way would be to jump from Merlin to the documentation of the symbol under cursor
<tane> yeah, that'd be great
<companion_cube> yes, me too
<companion_cube> it's possible with opam right now, but not simple to do
<flux> isn't opam-doc part of the solution?
<companion_cube> maybe
tane has quit [Quit: Verlassend]
rgrinberg has quit [Ping timeout: 256 seconds]
<mhammons> hmm
<mhammons> is there any way to just do "ocaml -I +extlib src.ml" instead of "ocaml -I ~/.opam/4.02.1/lib/extlib src.ml"?
<companion_cube> ocaml -I `ocamlfind query extlib` src.ml, maybe
keen_________ has joined #ocaml
keen________ has quit [Ping timeout: 255 seconds]
ollehar has quit [Quit: ollehar]
<mhammons> sigh, now it's complaining that it can't find extlib during linking
<mhammons> I read I can use #require to load the external module, but I just get "Unknown directive `require`." When I try to use it
<companion_cube> first: are you writing a one-file script?
<companion_cube> if not, 'ocaml' is not the right tool; ocamlc or ocamlopt are
<mhammons> i'm using ocamlc
<mhammons> and yes
<mhammons> and I've included #use "topfind" at the top of my .ocamlinit
<companion_cube> ocanmlfind ocamlc -linkall -package extlib src.ml -o foobar
jeffmo has quit [Quit: jeffmo]
<companion_cube> .ocamlinit is used only for toplevel
<companion_cube> but yeah, if you're writing a script, #!/usr/bin/env ocaml #use "topfind";; #require "extlib";; ....
<companion_cube> should work
<mhammons> just getting syntax errors
<mhammons> hold on
<mhammons> that's my source file
<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)
<mhammons> that did it
<mhammons> thanks
<companion_cube> if you want to have several files, etc. I recommand using ocamlbuild https://ocaml.org/learn/tutorials/ocamlbuild/
<mhammons> ok
<mhammons> so now I'm having a seperate problem
<mhammons> as you see, I have on line 20 a stream of lines defined
<mhammons> and I'm getting "Fatal error: exception Stream.Failure" when I run the program
<mhammons> so I tried switching with End_of_file -> None to Stream.Failure -> None
<mhammons> and I get "Fatal error: exception End_of_file"
<companion_cube> it probably means you reached the end of the stream
<mhammons> so it seems I need to catch both
<mhammons> but "with Stream.Failure -> None with End_of_file -> None" doesn't seem to catch End_of_file
chambart has joined #ocaml
<companion_cube> your code looks ok, it should catch end of file at the proper place
<companion_cube> I mean the code at http://pastebin.com/bx4bLQyv
<companion_cube> (minus the beginning of course)
<companion_cube> so my guess is it does'nt find the proper line
<mhammons> hmm ok
<companion_cube> I mean that getVtkSizeInfo will raise Stream.Failure if no line satisfying your criterion is found
<mhammons> that's strange
<mhammons> cause stream_filter should catch that right?
<mhammons> and return None instead
<companion_cube> no, because you use Stream.from
leafac has joined #ocaml
<companion_cube> 'a Steam.t is not the type unit -> 'a option
<companion_cube> but Stream.from converts the latter into the former
<mhammons> ah
<mhammons> so the issue is my Stream.next s;; line
<companion_cube> yes
<companion_cube> it fails if s is empty
ingsoc has joined #ocaml
<Drup> dora-molly: (about ppx-implicit) and with no reasonable export solution and arg it's just so ugly
<Drup> (and call that implicit is a bit ...)
<mhammons> companion_cube: ok, so this is the latest version of my code http://pastebin.com/1S4HMjd7
<mhammons> which works
rgrinberg has joined #ocaml
<companion_cube> yeah
<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..
idegen has quit [Quit: Leaving.]
struk has joined #ocaml
<mhammons> hmm
<mhammons> I'm getting a syntax error on line 67 of this: http://pastebin.com/rp4PfNXd
<mhammons> any ideas why?
<dora-molly> ; after done
<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."]
Tamae has joined #ocaml
rgrinberg has joined #ocaml
leafac has joined #ocaml
QuanticPotato has joined #ocaml
onebooks has quit [K-Lined]
onebooks has joined #ocaml
onebooks has quit [K-Lined]
c355E3B has joined #ocaml
<mspo> I'm getting a build failure for opam 1.2.2
<mspo> ocamlfind ocamldep -I core -I solver -I repositories -I client -I client/ client/opamGitVersion.ml > ._d/client/opamGitVersion.d
<mspo> ocamlfind ocamlopt -package unix,extlib,re,re.emacs,re.str,re.perl,re.pcre,re.glob,cmdliner,ocamlgraph,cudf,dose3,jsonm -c -g -w +a-4-9-32-41-44-45-48 -bin-annot -short-paths -safe-string -I core -I solver -I repositories -I client -I client/ client/opamGitVersion.ml
<mspo> ocamlfind ocamlopt -package unix,extlib,re,re.emacs,re.str,re.perl,re.pcre,re.glob,cmdliner,ocamlgraph,cudf,dose3,jsonm -c -g -w +a-4-9-32-41-44-45-48 -bin-annot -short-paths -safe-string -I core -I solver -I repositories -I client -I client/ client/opamArg.ml
<mspo> File "client/opamArg.ml", line 250, characters 17-34:
<mspo> Error: Unbound value Arg.doc_alts_enum
<mspo> ../OCamlMakefile:1076: recipe for target 'client/opamArg.cmx' failed
<mspo> same with 1.2.1
blech_ has joined #ocaml
BitPuffin|osx has quit [Ping timeout: 258 seconds]
nullcat has joined #ocaml
Tamae has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
k1000 has quit [Ping timeout: 265 seconds]
k1000 has joined #ocaml
wraithm has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
rgrinberg has joined #ocaml
ygrek has joined #ocaml
hilquias has joined #ocaml
QuanticPotato has quit [Ping timeout: 265 seconds]
<vbmithr_> Can somebody explain me again the diff between MODULE_TYPE with type t = sth VS MODULE_TYPE with type t := sth ?
<dora-molly> vbmithr_: type t will not be part of the resulting module type in the second case
<dora-molly> consider module type T = sig type t val empty : t end
<dora-molly> T with type t = int is definitionally equal to sig type t = int val empty : t end
<dora-molly> T with type t := int is definitionally equal to sig val empty : int end
oscar_toro has quit [Ping timeout: 272 seconds]
<vbmithr_> dora-molly: thanks!
Anarchos has quit [Ping timeout: 255 seconds]
obadz has quit [Ping timeout: 252 seconds]
seanmcl has joined #ocaml
obadz has joined #ocaml
<vbmithr_> any way to "extract" a module type from a module implementation (in the code)
<vbmithr_> like saying: module M : module type of N (where N is an existing module somewhere)
kushal has quit [Ping timeout: 272 seconds]
rock_neurotiko has joined #ocaml
<dora-molly> module M : module type of struct include N end
rock_neurotiko has left #ocaml [#ocaml]
Hannibal_Smith has quit [Quit: Leaving]
esden has quit [Remote host closed the connection]
<vbmithr_> mmh… does not seem to work here
<ggole> module M = struct type t end module A : module type of M = struct type t = int end
Hannibal_Smith has joined #ocaml
esden has joined #ocaml
<vbmithr_> let f m = let module E = (val m : module type of M) in ()
<vbmithr_> This does not work
<vbmithr_> wrong syntax
struk has quit [Ping timeout: 265 seconds]
<vbmithr_> It seems I can't use "module type of M" here
<dora-molly> module types in packages is required to be a path
<dora-molly> module type S = module type of struct include M end
<dora-molly> (val m : S)
c355E3B has quit [Quit: Leaving]
<vbmithr_> Ok!
<ggole> Just module type S = module type of M should be ok
sepp2k has joined #ocaml
<vbmithr_> yeah, module type of M indeed extracts the module signature
<vbmithr_> cool
<tobiasBora> Hello !
<tobiasBora> Does anyone knows a way to "map" an output_channel so that everytime you output a string in this channel a callback function is called ?
<companion_cube> if only
<dora-molly> the include M has the effect of strengthening the module type, marking it explicitly equal to N
<dora-molly> module type of N just give you the type of a module with the same signature
<dora-molly> module M : sig type t end
<dora-molly> then module type of M = sig type t end
<dora-molly> module type of struct include M end = sig type t = M.t end
<tobiasBora> companion_cube: the if only is for me or another conversation ?
<ggole> dora-molly: oh, hmm. I wasn't aware of that.
kushal has joined #ocaml
<dora-molly> ggole: useful if you want to preserve equality
swgillespie has joined #ocaml
<companion_cube> to you, tobiasBora
<companion_cube> in_channel is a bit limited
<companion_cube> if it weren't, Printf would be much better, for instance
<tobiasBora> companion_cube: Hum... And why nobody tries to create a better in_channel ?
Anarchos has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
<companion_cube> tobiasBora: it's easy to create a better in_channel, but it won't get standard
struk has joined #ocaml
<tobiasBora> And it's not possible to create complex out_channel that could perform operations on the string they get ?
<companion_cube> that's the problem with the stdlib
<tobiasBora> If the standards are included in the better in_channel wouldn't it be ok ?
kushal has quit [Quit: Leaving]
ygrek has quit [Ping timeout: 265 seconds]
<tobiasBora> And it's not possible to play with pipe to do that ?
TheLemonMan has joined #ocaml
<companion_cube> the problem is it's very hard to convince maintainers to add or change stuff in the stdlib
octachron has quit [Quit: Leaving]
asQuirreL has quit [Ping timeout: 264 seconds]
<mhammons> hi all
<mhammons> I'm getting this weird error message from fprintf
asQuirreL has joined #ocaml
<zozozo> in your code, the second argument you give fprintf is a string, but it should be a format string
<struk> rgrinberg: can you add .mlt syntax support please? thanks.... :)
oscar_toro has joined #ocaml
<companion_cube> .mlt ? what's that?
<companion_cube> tobiasBora: with pipe and a thread, maybe
<companion_cube> but that's be overkill
<flux> mhammons, the format argument of printf functions is magic. but what are you trying to accomplish?
<flux> mhammons, it looks like you are missing maybe something like "%s%s%d" after 'oc'
<companion_cube> struk: but addig support for .mli into what? :p
<struk> companion_cube: ha. vim-ocaml , so it treats the mlt as as an ml file basically. should be easy
<companion_cube> oh I see
<companion_cube> I'm lucky I use qtest :p
<struk> anyhow, qtest doesn't syntax higlight my code either, which is irritating!
<struk> well, maybe vim-ocaml turned it on.. but I doubt that
<companion_cube> yeah, agreed
<mhammons> flux: I'm trying to make a header for a file
<mhammons> and I make it a list so it's not a huge nasty string
<mhammons> flux: something like this: http://pastebin.com/YtSzi5YU
<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.
<ggole> format_of_string is %identity
<ggole> Basically Obj.magic with a nice name.
<ggole> Printf.printf (Scanf.format_from_string "test%s" "%s") "zonk";;
<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> which links to nocrypto issue...
<nullcat> the hmac-sha1's issue is simpler
Submarine has quit [Quit: Leaving]
QuanticPotato has quit [Ping timeout: 240 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<blech_> nullcat, does feed do what you want?
QuanticPotato has joined #ocaml
<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 need to implement this sig
<nullcat> feed is concat is a good idea
<nullcat> i can keep a buffer inside it and feed adds into buffer, maybe like that?
<blech_> yeah
<blech_> then when you call result you execute Nocrypto.Hash.SHA1.hmac on the whole shebang
<nullcat> yes
<blech_> this of course assumes init; feed a; feed b; result is equivalent to init; feed (a+b); result
<nullcat> yes, that's what I want to say
<nullcat> is this assumption true?..
mhammons has quit [Quit: Konversation terminated!]
QuanticPotato has joined #ocaml
<nullcat> well, assumption is always true. i mean is the statement in the assumption true...
<nullcat> ok i should go to try myself...
<l1x> nullcat: amazing, thank you!
asQuirreL has quit [Read error: Connection reset by peer]
asQuirreL has joined #ocaml
<nullcat> blech_: it's true. so i can do this. Thanks!
<blech_> nullcat, glad to hear it
<blech_> do you want me to reply to the issue on github?
ygrek has joined #ocaml
<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
<nullcat> cool. thanks!
Hannibal_Smith has joined #ocaml
Denommus has joined #ocaml
leafac has quit [Quit: Leaving.]
<l1x> nullcat: i am don
<l1x> t understand something about Bytes.set
<nullcat> ?
<l1x> it mutates the passed in variable right?
<nullcat> yes. mutate...
<nullcat> so you want a new string?
<nullcat> and keep `text` unchanged?
BitPuffin|osx has joined #ocaml
<l1x> yes
<l1x> there is Bytes.copy I guess
<nullcat> so you copy before call function?
<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?
<nullcat> yes that's a good post
freling1 has joined #ocaml
<companion_cube> Lwt.async?
<companion_cube> nullcat: unless you meant in a separate thread
<nullcat> um i just do something like "if condition then (* wait 2 seconds *)"
<nullcat> wait 2 seconds and proceed
<companion_cube> oh
<nullcat> it should block the computation
<companion_cube> Lwt_unix.sleep 2. >>= fun () -> .....
<nullcat> no it's os dependent
<companion_cube> then I don't know :(
<nullcat> for Lwt_unix.sleep, it blocks current lwt thread and let other threads proceed, right?
<companion_cube> yes
freling has joined #ocaml
hilquias has quit [Read error: No route to host]
idegen has joined #ocaml
freling1 has quit [Ping timeout: 272 seconds]
mengu has quit [Remote host closed the connection]
<struktured> nullcat: just for comparsion's sake, I looked at async's time/at functions, and it looks purely based on ivars and their scheduler, not unix (directly). https://github.com/janestreet/async_kernel/blob/master/src/clock_ns.ml#L98-L123
<struktured> if it is actually is "pure", then same could be written in lwt if you were skilled enough (I'm not)
<companion_cube> /nick comparsion_cube
<struktured> ha
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<companion_cube> incoming containers release, btw
* struktured feels ground shaking, almost loses balance...
<struktured> disruptive? or mild?
<companion_cube> should be very mild!
<struktured> great
rgrinberg has quit [Ping timeout: 264 seconds]
<companion_cube> I don't think there is anything breaking
<nullcat> thanks..
<struktured> nullcat: this is the black magic, behind the timer: https://github.com/janestreet/core/blob/master/src/timing_wheel_float.ml
<nullcat> too hard for me..
<nullcat> to read
<struktured> yeah it is interesting though, I might review it later for a theoretical exercise
rgrinberg has joined #ocaml
rand000 has quit [Quit: leaving]
Denommus has quit [Ping timeout: 246 seconds]
rgrinberg has quit [Ping timeout: 256 seconds]
Hannibal_Smith has quit [Quit: Leaving]
hay207 has quit [Ping timeout: 258 seconds]
rgrinberg has joined #ocaml
freling has quit [Quit: Leaving.]
<rgrinberg> nullcat: i think Lwt.ignore_result is analgous to don't_wait_for in async
<nullcat> i tried but it does not really halt the computation
<rgrinberg> but Lwt.async is useful for this stuff as wel
<nullcat> Lwt.ignore_result (Lwt_unix.sleep 2. >>= fun () -> return (print_endline "2")); print_endline "1";
robink_ is now known as robink
<nullcat> this prints "1" immediately and then "2"
<rgrinberg> nullcat: that's what i'd expect
<rgrinberg> what do you want it to do?
<companion_cube> strange, why doesn't it wait 2s ?
<rgrinberg> companion_cube: i think it does wait 2s, it prints the 1 immediately
<nullcat> rgrinberg: wait till the api rate limit is gone. during this time, let other threads proceed
<rgrinberg> nullcat: but what does that have to do with what you're talking about?
<rgrinberg> if you have a lwt thread that is determined when the api rate limit is gone then you just bind on that
<rgrinberg> everything else should proceed while that's blocked
<nullcat> um, yeah.......
<nullcat> Lwt_unix.sleep (!wait_time) >>= fun () -> ... ?
QuanticPotato has quit [Quit: Leaving]
<rgrinberg> nullcat: sure
<nullcat> wait_time is a ref. it is zero when we haven't reached the limit
<nullcat> ok
<nullcat> but is it any overhead? Lwt_unix.sleep 0 returns immediately ?
<nullcat> if we don't wait, why not just call the function
<rgrinberg> you can optimize it if you really want to (if !wait_time = 0.0 then Lwt.return_unit else Lwt_unix.sleep (!wait_time))
<rgrinberg> i wouldn't bother though
<nullcat> if there is no need to wait, we don't need to create a thread that waits zero second
<nullcat> cool
Simn has quit [Quit: Leaving]
<nullcat> this is good... thanks!
<nullcat> yeah, i shouldn't bother this actually
<rgrinberg> also because that's not a nice way of checking for 0 in floats :P
<rgrinberg> yeah don't bother prematurely optimizing
<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 ?
<rgrinberg> tobiasBora: yep.
<tobiasBora> rgrinberg: Does ocp-indent can understand the lwt syntax extension ?
<nullcat> "Fatal error: exception Unix.Unix_error(Unix.EINVAL, "select", "")" don't know what happend for Lwt_unix.run ...
<tobiasBora> *can...
<rgrinberg> tobiasBora: yeah! but you must configure it
<nullcat> invalid argument...
<rgrinberg> nullcat: first of all, use Lwt_main.run.
<rgrinberg> the lwt_unix version is deprecated
<nullcat> ok
<rgrinberg> nullcat: can i see the whole code though?
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<nullcat> i figured out why.. hold on seconds
<nullcat> maybe 5 mins later?
<tobiasBora> rgrinberg: Where should you put it ? Anywhere in the ascendant path ?
<rgrinberg> tobiasBora: in the project root directory.
<tobiasBora> I will give it a try, thank you !
<rgrinberg> tobiasBora: NP
Kakadu has quit [Remote host closed the connection]
<nullcat> rgrinberg: pushed. https://github.com/marklrh/otter/blob/master/lib/api.ml#L147 <- warning: super ugly piece of code
<nullcat> i'll take a rest onw
<nullcat> now
<blech_> companion_cube, you mentioned a containers release?
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<companion_cube> yes, once it's merged in opam-repo
<companion_cube> a smallish one, with bugfixes and new functions in core/
chambart has joined #ocaml
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Algebr has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
seanmcl has quit [Read error: Connection reset by peer]
Gama11 has quit [Read error: Connection reset by peer]
<blech_> so why does it feel like every ocaml blogger uses octopress?
<Drup> oh ?