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
jabesed has joined #ocaml
<sdegutis> What do you hate most about OCaml?
AltGr has joined #ocaml
<whitequark> the way it isn't used more
<whitequark> :]
<Drup> ahah, that's such a good answer <3
arboris` has joined #ocaml
yaewa has joined #ocaml
moei has quit [Ping timeout: 272 seconds]
<struktured> nice
arboris has quit [Ping timeout: 272 seconds]
tobiasBora has joined #ocaml
pdewacht has joined #ocaml
ThePawnBreak has quit [Ping timeout: 264 seconds]
<struktured> sdegutis: in all seriousness, for me it's maintaining two separate files per module that gets on my nerves. not a huge deal though. the 2nd thing is I really wish vim used syntax highlighting in omnicompletion window, but that's not ocaml's fault :)
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<sdegutis> ah
yaewa has quit [Read error: Connection reset by peer]
moei has joined #ocaml
<struktured> sdegutis: also, I think something like this would really be helpful to ease some generic painfulness (modular implicits) : http://oud.ocaml.org/2012/slides/oud2012-paper4-slides.pdf
<sdegutis> struktured: hey dont i remember you from #ruby or something?
<sdegutis> years ago?
<sdegutis> or #python
<struktured> sdegutis: maybe?? I dabbled but never wrote any serious stuff in ruby. same with python but I used python more recently (then switched to ocaml)
<sdegutis> ok
<struktured> sdegutis: u thinking of #qt maybe? lurk there a bit
<sdegutis> maybe
rgrinberg has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
<sdegutis> RWO is not a skimmable book :'(
moei has quit [Read error: Connection reset by peer]
<sdegutis> How do you know when to make a new type or a new module containing a type 't'?
<sdegutis> RWO is a frustrating book.
moei has joined #ocaml
<struktured> sdegutis: it's not necessary to learn ocaml at all.
<sdegutis> struktured: uhh
<Drup> potential usage in a functor, I guess ?
<struktured> sdegutis: the book I mean, there are other books and examples
arboris` has quit [Ping timeout: 265 seconds]
jabesed has quit [Ping timeout: 240 seconds]
<struktured> sdegutis: if you want to associate operations with some type, its usually worth making a module and bundling all the operations together, much like you would a class
<sdegutis> oh cool
<sdegutis> "OCaml from the Very Beginning will appeal both to new programmers, and experienced programmers eager to explore functional languages such as OCaml"
<sdegutis> I'm neither.
<Drup> this one is more geared toward beginners in programming in general, afaik
<sdegutis> I'm not new at programming, and I have much experience with FP concepts.
<struktured> sdegutis: okay, then More Ocaml? http://ocaml-book.com/more-ocaml-algorithms-methods-diversions/
<struktured> sdegutis: or even better, just wrote some code :)
<sdegutis> Fine.
<Drup> or read the official manual :D
<sdegutis> Now to find some way to interface with C code.
<struktured> I wasn't in love with the ocaml manual's take on functors
<Drup> it's a bit ... rough.
<Drup> sdegutis: by curiosity, why do you find RWO frustrating ?
<sdegutis> Drup: did you write it?
<sdegutis> what's the best emacs mode for ocaml?
<struktured> tuareg mode is popular
<Drup> tuareg mode + merlin
<Drup> sdegutis: why do you assume that ? :)
<sdegutis> Drup: intuition
<sdegutis> Drup: so did you?
<Drup> very bad one then :D
<sdegutis> ok
<sdegutis> ugh tuareg seems to require i use ;; to get indentation back to top-level
<Drup> nope
yaewa has joined #ocaml
ivan\ has quit [Read error: Connection reset by peer]
<Drup> (or the direct method, then see the official manual)
ivan\ has joined #ocaml
<whitequark> ctypes++
moei has quit [Ping timeout: 245 seconds]
bytbox has quit [Remote host closed the connection]
<sdegutis> let x = "hello world!" in print_string x
<Drup> (and for indentation, see ocp_indent)
<sdegutis> not found
<struktured> sdegutis: opam package name is ocp-indent "-" not "_"
<sdegutis> opam?
<sdegutis> well
<sdegutis> im not going to do any yak shaving tonight.
<sdegutis> thats a sure way to kill any interest i have in ocaml
<struktured> sdegutis: the typically used ocaml packaging manager. highly recommended. what are you doing now to install?
<sdegutis> nothing
<sdegutis> i have hi.ml and thats all
<sdegutis> which apparently has a syntax error because it doesnt end in ;;
<Drup> I doubt so :p
<struktured> sdegutis: if you were going through RWO it puts you through a process of making a decent ocaml environment
<sdegutis> one with Core
<sdegutis> which im not going to install
jao has joined #ocaml
<struktured> sdegutis: you can skip that part if you want and do the reamainder
jao has quit [Changing host]
jao has joined #ocaml
<struktured> sdegutis: also, install != must use either
<Drup> sdegutis: that's a minor part of the instructions, you should do the rest
<Drup> I linked that 10 minutes ago :D
<sdegutis> nic
<sdegutis> e
<sdegutis> $ opam init
thomasga has quit [Quit: Leaving.]
<sdegutis> Illegal instruction: 4
<sdegutis> lolololol
<Drup> o_O
<sdegutis> $ opam --help -> Illegal instruction: 4
<Drup> system ?
<sdegutis> osx 10.10
<sdegutis> (.1)
<sdegutis> yakkkkk
* Drup invoke AltGr
<sdegutis> all i did was `brew install opam`
<AltGr> *Hellllooooo*
<AltGr> what's up ?
<Drup> successful invocation !
<Drup> but apparently, the issue was already filled.
araujo has joined #ocaml
araujo has joined #ocaml
dmbaturin has joined #ocaml
<Drup> AltGr: is the feature field going to be in 1.2.1 ?
<AltGr> ah yeah. No idea really. I should be getting a mac soon to be able to test and reproduce such issues. At the moment I only have a working system.
<AltGr> (troll inside)
enitiz has quit [Ping timeout: 245 seconds]
<AltGr> Drup: my idea was to put it there, but still flagged as experimental, because it feels a bit underspecified yet
<Drup> yay !
<AltGr> experimental, as in, not expected to appear in opam.ocaml.org's repo
<Drup> :(
<Drup> and the compiler-as-packages ?
<AltGr> the basic features allowing it are there. But the repo probably won't be rewritten with ocaml packages right away
<Drup> ok
<Drup> mostly cute utf8 in 1.2.1 then :<
<Drup> (which is obviously the most important feature)
<AltGr> well the cute utf8 is the visible part of a rewritten command-running engine, which should allow better parallelism, error recovery and stability
<Drup> AltGr: do you plan to rewrite the history to add {build} on ocamlfind everywhere ?
<Drup> the repository*
<AltGr> I did but there's the 'bytes' stuff in the way
<Drup> how is that in the way ?
<AltGr> I have a bunch of such rewrites planned (and scripted) but am waiting for https://github.com/ocaml/opam-repository/pull/3143
<Drup> (bytes shouldn't have been included in ocamlfind and be done at the opam level instead ..)
<AltGr> if you use Bytes from ocamlfind in a library, then it's no longer a build dependency
<Drup> yeah
justinfront has left #ocaml [#ocaml]
<Drup> AltGr: what's blocking for depopts to conflicts ?
<AltGr> there's a long thread on opam-devel ml if you're interested. Basically: opam 1.1 support
<Drup> ah, yes, obviously
<AltGr> well, let's get back to writing lisp
<Drup> lisp ? :|
ygrek has joined #ocaml
<Drup> *e*lisp, I suppose ? :x
<pippijn> why doesn't ocamlc/ocamlopt topologically sort the inputs?
<pippijn> is there any situation where you don't want it to do that?
AlexRussia has quit [Ping timeout: 245 seconds]
yaewa has quit [Read error: Connection reset by peer]
moei has joined #ocaml
<AltGr> hm, if you want a specific order and added a backwards dependency by mistake ? %)
<pippijn> backwards dependency?
<pippijn> you mean cyclic?
<pippijn> if you want a specific order, I think you're doing something very wrong
<AltGr> I was imagining three modules doing just side-effects that I want ordered A B C, without dependencies, then I add a dep C -> B
<pippijn> but ok
<AltGr> Quite unlikely, yes, but you said *any* situation :)
<pippijn> in that case, you can still do it manually
<pippijn> yeah
<pippijn> I see
<pippijn> but it could check whether the modules are topologically sorted, and leave the order alone in that case
<pippijn> otherwise, toposort them
darkf has joined #ocaml
<pippijn> I'm in the situation where I need to implement a topological sort again
<pippijn> very annoying
<AltGr> I know the feeling
<pippijn> jane street solved it by reading .d files and writing a collection to another file, then reading that file and doing stuff... ew
<AltGr> If there's anyone motivated to contribute to opam-user-setup for vim, that'd be gladly welcome. I've updated the README and am trying to switch from static to "as much dynamic as possible"
<AltGr> for emacs I'm doing `opam list --installed --safe --short <packages>`, and configuring the returned packages
swgillespie has joined #ocaml
<struktured> man I think I'm hitting GC performance degradation running an experiment in utop. any one know how to tune it for more memory using some sort of profile?
<struktured> {Gc.minor_heap_size = 262144; major_heap_increment = 15; space_overhead = 80; verbose = 0; max_overhead = 500; stack_limit = 1048576; allocation_policy = 0}
<Drup> if you are hitting GC performance degradation in utop, you shouldn't be using an interpreter anymore....
keen__________42 has joined #ocaml
<struktured> Drup: I still kind of want to, if you think it' spossible to beef it up. I want it to serve as a sort of scientific repl thingy
<struktured> also it could just be a bug in more code, who knows
<struktured> *more/my
keen__________41 has quit [Ping timeout: 264 seconds]
<Drup> you should get yourself a native repl, too
<struktured> Drup: what do you mean by native here?
<Drup> native as in "will load native code and compile the code to native"
<struktured> oh I see. so when I do something like #require foobar the default is to use the non-native version?
<Drup> iirc, yes
<struktured> ok thanks for help will look into this further
AlexRussia has joined #ocaml
enitiz has joined #ocaml
mcc has joined #ocaml
<struktured> hmm bumped it with OCAMLRUNPARAM but it still slows down after about 300 iterations. guess its debugging time
<sdegutis> How do directories factor into OCaml projects?
<sdegutis> Do intermediate directories become intermediate module names? Or are all files generally put in the top level? Or neither?
<struktured> sdegutis: no hard rule. the convenition is that subfolders are container modules basically. also they are used to create multilibrary projects
<sdegutis> does their presence effect module names?
<sdegutis> like is foo/bar.ml now turned into Foo.Bar ?
<struktured> sdegutis: depends how you compile it ultimatey, but in general yes
<sdegutis> is there a build tool for ocaml (that doesnt depend on Core)?
<struktured> several, all with limitations. oasis I personally recommend for some simple projects.
<sdegutis> oasis it is then
<sdegutis> my project is very simple: i just want to wrap a small C library
<pippijn> sdegutis: OMake
<pippijn> sdegutis: what build tool depends on Core?
<sdegutis> pippijn: omake compared to oasis?
<pippijn> oasis is not a build tool
<sdegutis> i no longer trust struktured
<pippijn> it's a project tool
<pippijn> it generates some ocamlbuild input
<sdegutis> i now trust struktured once again, and no longer trust pippijn
<pippijn> okay
<sdegutis> wait reverse that again
<sdegutis> omake it is
<sdegutis> this is really confusing
<sdegutis> i just want to make an executable that compiles several .ml and .mli files and uses a C library
<sdegutis> and probably has opam libs like ctypes
<pippijn> omake is a very generic build tool that can be used to do everything you could ever want
<struktured> haha omake, ocamlbuild, oasis, obuild, etc etc
<whitequark> omake is a pain to install
<pippijn> yeah
<pippijn> opam install omake
<sdegutis> whitequark: what do you use?
<pippijn> painful!
<whitequark> i'm really wary of using anything that requires a set of patches just to build
<whitequark> sdegutis: ocamlbuild
<pippijn> aptitude install omake
<pippijn> or: git clone https://github.com/bobzhang/omake-fork && cd omake-form && make install # or something like that
<pippijn> s/form/fork/
<sdegutis> # () ;;
<sdegutis> its a weird alien smiley
<sdegutis> (with a beard)
<pippijn> whitequark: that's a ridiculous requirement
<pippijn> omake is very very good
<sdegutis> so many yaks to shave
<sdegutis> i wonder how many days before i can write some ocaml
<pippijn> sdegutis: what do you have against Core?
<struktured> hmm, my slowness if from plotting thousands of points onto a graph dynamically..guess I'm not surprised
<struktured> *if/is
<sdegutis> pippijn: i want to learn ocaml before learning some company's additions for it
<sdegutis> i dont care how jane their street is
<pippijn> makes sense
<pippijn> I wouldn't recommend using jenga for now
<pippijn> I'm working on something on top of jenga
<sdegutis> ok
<pippijn> when that's finished, it's easy to use
<sdegutis> ill just use ocamlbuild for now
<pippijn> that's probably easiest
<sdegutis> im literally just compiling against a single C library
<sdegutis> and i have like one file right now
<pippijn> if you don't have requirements that go beyond what ocamlbuild has built-in
<sdegutis> $ cat hi.ml
<sdegutis> let x = "helloworld!" in print_string x
<sdegutis> should that end in ;; ?
<pippijn> no
<pippijn> oh
<sdegutis> ocaml < hi.ml tells me it should
<pippijn> yeah, maybe
<pippijn> ocaml is a repl
<pippijn> don't do that
<pippijn> ocamlc hi.ml && ./a.out
<sdegutis> right
<sdegutis> no ocamlc does bytecode
<sdegutis> ocamlopt hi.ml
<pippijn> so?
<Drup> pippijn: do you have a good omake tutorial ?
<pippijn> Drup: no, but the manual is very good
<pippijn> look at https://github.com/pippijn/obuild for ideas
ygrek has quit [Ping timeout: 272 seconds]
<Drup> the manual starts by explaining how to build C
<Drup> seriously
<Drup> sdegutis: use oasis.
<sdegutis> wy
<pippijn> Drup: so?
<pippijn> C is much easier to build than ocaml
<Drup> pippijn: don't advise omake (and even less jenga of even your overlay on top of jenga) for beginners
<Drup> it's not the intended target
<Drup> and it's not the correct tool
<pippijn> Drup: there are examples of how to build ocaml in the omake examples
<Drup> yeah, great, it's ~~super powerful~~, you can even compile latex with it
<mcc> Drup: "Lexing" is standard library, right? So it introduces no dependencies?
<Drup> mcc: yes
<mcc> 'k
<Drup> pippijn: a tool for beginner should have builtin trivial rules for compiling ocaml, period.
<sdegutis> Drup: oasis then?
<pippijn> sdegutis: ocamlbuild
<sdegutis> arggg
<pippijn> ocamlbuild hi.native && ./hi.native
<sdegutis> i do feel myself hating the ocaml ecosystem more and more by the second
<sdegutis> pippijn: whats "hi.native"?
<Drup> we might have a small issue with build systems in the ocaml ecosystem
<Drup> but some people are not helping =__=
<sdegutis> Drup: ocamlbuild then?
<pippijn> Drup: if people didn't produce so much crap..
<Drup> because they tend to conflate what they need with what the rest of the world need
<sdegutis> leiningen got this right
<Drup> in particular, pippijn, flexibility is not something needed by a beginner.
<pippijn> ocamlbuild is good for simple tools
<sdegutis> is there somthing like leiningen for ocaml?
<Drup> sdegutis: oasis is an overlay on top of ocamlbuild anyway
<sdegutis> im writing a very simple tool that has 5 files:
<pippijn> simple programs and libraries: ocamlbuild
<pippijn> oasis is just another thing to learn, don't bother for now
<sdegutis> thing.ml, thing.mli, mylib.c, mylib_ext.c, mylib.h
<pippijn> more things to get wrong
<sdegutis> thats all i got
<sdegutis> ok googling ocamlbuild tutorial
<Drup> ahah
<pippijn> :|
<Drup> pippijn: I must say, I don't even know how to build C libraries with ocamlbuild
<mcc> Drup: When I put this next patch in-- do you have any objection to using my custom struct internally and then converting to Lexing.position on export?
<Drup> while with oasis, it's trivial
<pippijn> okay
<pippijn> it's trivial with ocamlbuild, too, but not well described anywhere I know
<sdegutis> should .ml files end in ;; ?
<pippijn> sdegutis: okay, oasis has reasonable docs (for simple use cases), maybe it's better to start with oasis
<pippijn> sdegutis: no
<sdegutis> ok
<pippijn> enter "oasis help" and read what that says
<Drup> mcc: yes
<sdegutis> how do you fix the indenting in emacs in tuareg?
<Drup> mcc: I mean, yes you should do it like that, I don't have any objection
<sdegutis> pippijn, Drup: i am using this toturial: https://nicolaspouillard.fr/ocamlbuild/ocamlbuild-user-guide.html
<Drup> sdegutis: It shouldn't be completely broken, what's your file ?
<sdegutis> Drup: let x = 3 ;;
q66 has quit [Quit: Leaving]
<Drup> remove the ";;" :p
<sdegutis> Drup: every line after this is 2-spaces indented
<Drup> the complete file please.
<sdegutis> Drup: with ;; removed, every line after this is like 8 spaces indented
<sdegutis> Drup: $ cat hi.ml
<sdegutis> let x = 3
<Drup> what are you typing *after* then ?
<sdegutis> enter
<sdegutis> oh sorry, i mean the "return" key
<Drup> then type something meaningful, a let for example ~~
<sdegutis> the key above right-shift
<sdegutis> oh, the new statement is indented right
<sdegutis> only blank lines are super-far-indented
<Drup> oh and
<Drup> don't read this ocamlbuild tutorial
<Drup> really, don't
<Drup> it will only confuse you
<sdegutis> ok
<sdegutis> plz 2 give me 1
<Drup> I linked one
<sdegutis> you linked an oasis one no?
<Drup> yes
<sdegutis> wth i thought i was gonna use ocamlbuild
* sdegutis sighs
<sdegutis> can the CSources field take globs?
<sdegutis> like *.c ?
<Drup> I'm pretty sure that it doesn't.
<sdegutis> wow
<sdegutis> im not gonna manually list all my .c files
<sdegutis> theres like 50 of them
<pippijn> sorry, you have to
<sdegutis> i refuse
<pippijn> ls *.c >> _oasis
<pippijn> or
<mcc> write a perl script that generates a _oasis file which generates ocamlbuild…
<pippijn> echo *.c >> _oasis
<sdegutis> oh only 33 actually
<pippijn> mcc: been there
<sdegutis> echo *.c doesnt expand
<pippijn> sdegutis: why not?
<sdegutis> oh yeah ti does
<sdegutis> i forgot the subdir
<pippijn> *.c is done by your shell
<pippijn> not by ls
<Drup> wait, are you starting your ocaml exploration by writing a binding to a C library ? =__=
<pippijn> some people like it rough
<sdegutis> Drup: because my hello-world is writing a window manager
<sdegutis> i know how to use this C lib better than i know any algorithm
<pippijn> Drup: my hello-world was a C parser
<pippijn> I for one fully endorse this window manager hello-world
<Drup> it's not rough, it's meaningless, you will not see most of the high lever nice features of OCaml, only the sordid memory model
<Drup> pippijn: writing a C parser or a window manager is fine, but doing the binding ? ew
Rebelion has quit [Quit: Saliendo]
<sdegutis> Drup: i get to write a variant type to represent possible lua values, how much better can thou gettest for high level feature stuffeth?
<pippijn> heh
<Drup> oh, yet another lua person ! :D
<pippijn> I see GADTs in your future
<sdegutis> pippijn: whats gadt
<Drup> quick, mcc !
shinnya has quit [Ping timeout: 272 seconds]
<sdegutis> in my Swift version, i switched from an enum (like an ocaml variant type) to using a protocol (like an ocaml signature) to represent Lua.Value
<pippijn> sdegutis: it's where your ADTs have different types depending on the variant selected
<sdegutis> mainly because i wanted to support naturally supporting built-in literals
<sdegutis> but i cant do that here, can i?
<Drup> indeed
<sdegutis> also, i loved trying to make an automatic type checker for swift-written functions that get put into lua
<sdegutis> id love to try and do the same in ocaml
<Drup> (lot's of lua people going around)
<pippijn> sdegutis: you can do many really cool things with ocaml types
<sdegutis> can i make the 'string' type conform to a signature of my own devising?
<pippijn> example?
<sdegutis> like: type t var some_function: t -> int
<sdegutis> or maybe -> string, whatever, doesnt matter
<sdegutis> can i "extend" the built-in string type so that some_function takes a pure string?
<Drup> you still have a very object centric view of the world
<sdegutis> yea im sleepy and only half paying attention
<Drup> Just write a function.
ygrek has joined #ocaml
<pippijn> sdegutis: you can make: val some_function : string -> int
<pippijn> sdegutis: and that function translates string to t and t to int
<pippijn> sdegutis: you can do this automatically using tools provided by the ocaml type system
<sdegutis> im thinking of Swift right now, and in Swift i can make a function so that it returns a list of 't, where 't confirms to interface/protocol LuaValue which has a method t.push()
lordkryss has quit [Quit: Connection closed for inactivity]
<sdegutis> This way, I could return this from a swift function: [1234, "foo", 3.14] and its valid without any type conversions, because int, float, and string all conform to my protocol (i extended them)
<Drup> you can't do it this way in ocaml.
<sdegutis> and in ocaml i want to return [1234; "foo"; 3.14] from a function that returns "lua_type list"
<sdegutis> where lua_type is a signature that anything can conform to i guess
<Drup> No, that's not how it works
<Drup> use an ADT.
<sdegutis> sum type?
<sdegutis> i.e. variant type?
<Drup> yes
<sdegutis> but i want to be able to extend it later to new types from outside the definition of this type
<sdegutis> but variant types are not extensible from without
<pippijn> => expression problem
<Drup> why ?
<sdegutis> thats why i moved from a swift enum to a swift protocol
<Drup> example of things you only want to add after the fact ?
<sdegutis> Drup: because i want to be able to return some_rect instead of Table.to_table some_rect
<sdegutis> Drup: mostly other structs like point, rect, size, range, etc
<pippijn> you want implicit conversions?
<Drup> sdegutis: just define type alias and conversion functions.
<sdegutis> i didnt think you needed to *convert* something to a signature
<Drup> you should extend your adt for that
<Drup> you should not need to extend your adt for that*
<sdegutis> Drup: i want other uses of my library to be able to do it, with my library being sealed
<Drup> they can define conversion functions and type aliases too
<sdegutis> ok
<sdegutis> ill do that
<Drup> Lua types are fixed, they are not extended. Your interface is weird if you allow to arbitrary add new kind of lua objects.
<sdegutis> i agree
chouser has quit [Ping timeout: 276 seconds]
<sdegutis> sum type is coolest
<sdegutis> and bestest
<pippijn> I have a network packet encoder/decoder with extensible formats
<pippijn> and composable
oriba__ has quit [Quit: oriba__]
<pippijn> with combinators
<pippijn> you can do something similar for your lua thing
<pippijn> to describe structural information about your lua tables in static types
<pippijn> that can then be used to automatically decode/encode the tables into statically typed ocaml tuples
<pippijn> but that will sit on top of your low level api
<Drup> pippijn: that will still not give you the coertions he wants
ontologiae has quit [Ping timeout: 244 seconds]
<Drup> but, as you said "I see great GADTs in your future".
<sdegutis> my first ocaml code: type lua_type = String | Number | Boolean | Function | Table | Userdata | LightUserdata | Thread | Nil
jao has quit [Ping timeout: 252 seconds]
<sdegutis> oh right, gotta figure out the build system
<sdegutis> grahahla;hs;dflsad
<Drup> mcc: you ok for the example thing ?
<sdegutis> cant i just pass all my stuff to ocamlopt?
<sdegutis> or ocamlc?
<sdegutis> oasis is so far broken and retarded
<sdegutis> i didnt make any typos but i got a broken makefile
<pippijn> you probably forgot commas
<pippijn> sdegutis: can you show your _oasis?
<sdegutis> oh, "src" needs to have stuff in it
<sdegutis> fixed.
<pippijn> ok
<sdegutis> i just had ./hi.ml not ./src/hi.ml
<pippijn> oasis *is* broken and retarded
<pippijn> but yeah, that was a mistake
chouser has joined #ocaml
<sdegutis> Oh nice, I can just edit _oasis aftre the Makefile is created, and not have to keep re-creating the makefile
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
<sdegutis> if a function takes no args, do you call it like foo () or foo ?
<Drup> with ()
<sdegutis> i assume foo () since foo just returns the function
<sdegutis> ok
<sdegutis> thx
<sdegutis> its weird that () is called unit and [] called nil
<sdegutis> seems it should be reversed
<pippijn> why?
<sdegutis> nil is teh absence of value like () is, and [] is the foundation for a potential list like [] is
<sdegutis> *and unit is the fou--
<Drup> hum, no, it's the opposite in all the language I know
<sdegutis> im not talking about other languages
<Drup> in particular, nil is call nil in lisp.
<sdegutis> im talking about english/latin
<Drup> Oh.
<Drup> well, () is not the absence of value
<pippijn> () is a value
<Drup> it's literally the only value in it's type.
<sdegutis> its a singleton value that has no semantic meaning except the absence of any other value
<Drup> hence, unit.
<sdegutis> bla
<sdegutis> whatever
<pippijn> None has the semantic meaning of "no value"
<sdegutis> which is funny cuz its also a value
<sdegutis> alternative of Some x
<pippijn> yes
<pippijn> no value = exception
<pippijn> exceptions are a way to write partial functions
<pippijn> I don't like exceptions for anything but very local control flow
<sdegutis> how can you print a rough description of a function value?
<sdegutis> doesnt matter what it is, could be an address for all i care
<pippijn> print_int (Obj.magic value)
* Drup cries.
<sdegutis> thanks
<sdegutis> none of my changes are taking effect when i run make
<sdegutis> oh nm
<sdegutis> im editing ./hi.ml not ./src/hi.ml
alpen has joined #ocaml
<sdegutis> how do you use ctypes inside a .ml file and not in th repl?
kapil__ has joined #ocaml
mcc has quit [Ping timeout: 245 seconds]
<sdegutis> so far, ctypes is poorly documented
<sdegutis> Drup: you use ctypes right?
<sdegutis> yay!
<sdegutis> pippijn, Drup: whatcha think?
<pippijn> [_] | _ is the same as _
<sdegutis> oh right
<sdegutis> it didnt compile before, saying it was missing a thing, and i added that
<sdegutis> turns out it was because i really forgot [_ ; x] and had [_] in its place
<sdegutis> so oops.
<sdegutis> pippijn: looks like you were having the same issue last year http://irclog.whitequark.org/ocaml/2013-09-02.txt
<sdegutis> not about the match, but about ctypes
<sdegutis> ugh so frustratingggggg
<pippijn> sdegutis: I wasn't having issues there
<pippijn> technomancy was
<sdegutis> oh yeah
<sdegutis> well either way, hes the one who told me to look into ocaml last year
<sdegutis> i cant figure out how to get a very dead-simple ctypes example to work
<sdegutis> i put open Ctypes at the top of my .ml file and it says error
<sdegutis> Error: Unbound module Ctypes
<chouser> is there any way to avoid repetition in match patterns?
<sdegutis> chouser: got an example?
<sdegutis> chouser: in return maybe you can help me figure out this ctypes crap
<chouser> That is, some way to abstract out a pattern that shows up a lot?
<pippijn> chouser: functions
<chouser> You can call function on the left of a -> ?
<pippijn> chouser: other than that, no
<pippijn> chouser: no
<chouser> oh
<sdegutis> chouser: can you please paste an example?
<pippijn> and I also wish we had some sort of pattern construction
<sdegutis> pretty much all google results for "Error: Unbound module Ctypes" point to that IRC conversation between pippijn and technomancy from last year
<pippijn> simple compile time pattern construction
<sdegutis> and the answer pippijn gave him (to use #require "ctypes.foreign";;) does not apply to my .ml file
<sdegutis> that only applies in the interactive prompt
<pippijn> 2013-09-02 21:49 <pippijn> <*.ml>: package(ctypes)
<pippijn> 2013-09-02 21:49 <pippijn> then it compiles
<pippijn> 2013-09-02 21:49 <technomancy> true:package(ctypes.foreign),thread,annot,debugging should do it
<sdegutis> oh let me put that in my _oasis somewhere
<pippijn> that goes in _tags
<sdegutis> oh let me look for _tags
<pippijn> but you can also put it in _oasis, with a different format
<pippijn> something like Dependencies
<pippijn> look in the manual
<chouser> I've got a record type in a variant such that this is a valid pattern: Types.Types.List { Types.Types.value = [(Types.Type.Symbol {Types.Types.value = "foo" })] }
<sdegutis> chouser: remove Types.Types. in all places but one
<chouser> And then I've got a few matches that use that with different strings for "foo"
<pippijn> looks like you want local open
<sdegutis> chouser: just one is enough to make the type inferer work
<pippijn> Types.Types.(pattern)
<chouser> I can say: module T = Types.Types
<sdegutis> OT WOPRKKSKS!!!
<sdegutis> yeah pippijn's way also works
<pippijn> Types.Types.(List { value = [(Symbol {value = "foo" })] })
<chouser> That brings it down to just: T.List { T.value = [(T.Symbol { T.value = "foo" })] }
<sdegutis> or more better: Types.Types.(<expr>)
<pippijn> it's not really expr, it's patt
<pippijn> but yeah
<sdegutis> chouser: Types.Types.(List { value = [(Symbol { value = "foo" })] })
<sdegutis> or something i dunno
<sdegutis> i dont know ocaml
<pippijn> am I being ignored?
<pippijn> 04:54 < pippijn> Types.Types.(List { value = [(Symbol {value = "foo" })] })
<sdegutis> yes pippijn knows comal
<chouser> Hm, in other places if I don't say T.value, it warns me about that being "not visible in current scope"
<chouser> But there's no way to define a word "list_symbol" to take a string param and define it to mean that whole mess?
<chouser> or something?
<pippijn> nope
<pippijn> you can match one thing, and then match the other thing
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<chouser> with a nestes match ... with clause?
<chouser> nested
<pippijn> that might not be very useful
<pippijn> I don't know what you're doing
<chouser> sure
<chouser> But you've answered my question, thanks.
<chouser> I think Scala's pattern-matching syntax is similar, but is extensible. Hmm.
<pippijn> yes, but at runtime
<pippijn> unapply is executed at runtime
terry852 has joined #ocaml
<chouser> These ocaml-compiled executables start up so quick too. A very nice change from Clojure.
<pippijn> ocaml 0.02s user 0.00s system 97% cpu 0.020 total
<pippijn> yeah, hello world takes 0.004 seconds
<chouser> hm, so a lot of this pattern-matching text is due to my use of a record
psy has joined #ocaml
terry852 has quit [Read error: Connection reset by peer]
<chouser> this record type only has two fields. I could totally get away with a * t. What's that called? Compound type?
terry852 has joined #ocaml
<pippijn> tuple
<chouser> I could use a tuple, and everything would be shorter. And more obscure. Hm.
swgillespie has joined #ocaml
* chouser will just keep typing.
chinglish has joined #ocaml
<pippijn> is it type t = Symbol of symbol | List of list and symbol = { value : string } and list = { value = t List.t }?
<pippijn> if it is, then I'd suggest using type t = Symbol of string | List of t list
<sdegutis> let lua_new_state = foreign "luaL_newstate" (void @-> returning ptr lua_State) --- ugh this fails so confusingly
<chouser> This gist is a bit outdated now, but the definition of MakeVal.t (line 6 and on) is still basically what I
<pippijn> this doesn't have a record
<sdegutis> yay it compiles!
<sdegutis> it just fails at runtime, thats all.
pyon has quit [Ping timeout: 255 seconds]
<sdegutis> Fatal error: exception Dl.DL_error("dlsym(RTLD_DEFAULT, luaL_newstate): symbol not found")
<sdegutis> yep, even though i actually have the file that defines it in my CSources section
<sdegutis> and the file that implements it
pyon has joined #ocaml
<chouser> pippijn: the with_meta record on line 5 that is used on lines 7,8,9, and 11
<chouser> that's the record that's a candidate for being a tuple
<pippijn> ah
<pippijn> yeah, hm
<pippijn> chouser: that's a problem :)
<chouser> heh
<pippijn> I have this problem, too
<chouser> one of my own making, no doubt
<pippijn> my "meta" has 5 fields
<sdegutis> By itself, OCaml is useless to me.
<sdegutis> And it's nearly impossible to get it to work with an extremely simple C library.
<chouser> :-( FFI is always painful.
<sdegutis> No, no it's not.
<sdegutis> I've had a very pleasant experience with FFI in many, many other languages -- even FFI with C.
<sdegutis> This is just a neglected and abandoned language.
<sdegutis> And the people who could fix either the documentation or the tooling, apparently haven't and aren't.
<sdegutis> This is the 6 lines of code I can't get working: https://gist.github.com/sdegutis/d6f7060ff76b7d7185c8
<sdegutis> I'm just trying to use: lua_State* luaL_newstate(void);
enitiz has quit [Ping timeout: 245 seconds]
<chouser> Hm, well, I've done FFI in python, ruby, and Java, and I can't say a one of them was pleasant.
<pippijn> sdegutis: can you produce a failing testcase?
<sdegutis> chouser: for ruby this was pretty easy https://github.com/ffi/ffi
<sdegutis> pippijn: see the gist I just linked to
<pippijn> right
<pippijn> sdegutis: you need to link your program against lua
<sdegutis> I have embedded it's source
<pippijn> nm yourprog | grep luaL_newstate
<sdegutis> notice the lua/ dir, and its presence in _oasis
<sdegutis> but you're right, it's not present
<sdegutis> none of the Lua functions are
<pippijn> the C code is not being built
imslavko__ has joined #ocaml
<sdegutis> lemme guess, im totally misunderstanding Oasis?
<imslavko__> how to print a pair of strings with Printf? I have `("a tuple" "like this")`
imslavko__ is now known as imslavko
<sdegutis> imslavko: pair.(0) and pair.(1) I think?
<imslavko> oh, thanks!
<sdegutis> imslavko: now your turn to help me with CSources
<sdegutis> fair?
<imslavko> no idea what they are about
<pippijn> sdegutis: you need , between your C sources
<sdegutis> ugh
<imslavko> is "CSources" a special name of some library?
<imslavko> or just C files in general?
<sdegutis> Ah, so the earlier advice of echo lua/* was invalid.
<pippijn> I don't know who gave you that advice
<pippijn> but it may be valid
<sdegutis> hhhahahahaaa "Solver failed:"
<sdegutis> oasis sucks
<pippijn> now, move lua into src
<pippijn> mv lua src
IbnFirnas has quit [Read error: Connection reset by peer]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<sdegutis> fixed, it compiles!!!
<sdegutis> i moved all files from lua/ into src/
pyon has quit [Remote host closed the connection]
<sdegutis> and i removed all "lua/" in _oasis
<sdegutis> but `nm ./hi.native` still has no "lua" anywhere in it
<pippijn> yeah
<pippijn> the problem is that it statically links against the C code
<pippijn> and the symbols are not referenced
<pippijn> sdegutis: no idea, I don't know ctypes
<pippijn> I only make native bindings with the standard ocaml ffi thing
<pippijn> you can do this:
<pippijn> cd _build
<pippijn> ocamlfind ocamlopt -verbose -linkpkg -package ctypes.foreign src/hi.cmx -cclib -Wl,--whole-archive -cclib src/libhi_stubs.a -cclib -Wl,--no-whole-archive -o src/hi.native
smtb has quit [Quit: Page closed]
<pippijn> but then it still doesn't find the symbol, despite it being in the binary
<sdegutis> pippijn: is the standard ffi thing pretty easy?
<pippijn> yes
<sdegutis> i have no problem using that instead if it doesnt require me to write tons of bridging c code
<pippijn> it depends
<pippijn> if you need to write tons of ocaml bridging code with ctypes, then you also need to write tons of bridging C code
<sdegutis> uh
<sdegutis> can you point me to a small hello world for a simple c function for ocaml?
<sdegutis> yeah i was already reading that
<sdegutis> it was referencing context that it didnt explain anywhere else
<sdegutis> so i assumed its just crappy documentation and nobody noticed
chouser has quit [Ping timeout: 245 seconds]
swgillespie has joined #ocaml
pyon has joined #ocaml
<sdegutis> I think I really would have liked OCaml.
<sdegutis> Too bad.
sdegutis has quit [Quit: Leaving...]
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
<imslavko> hey guys, I am pretty new to OCaml and getting a syntax error. The error message is quite unhelpful "Error: Syntax Error", can anyone help please? I have a github repo: https://github.com/Slava/decaf/tree/parser-base
lambdahands has quit [Ping timeout: 244 seconds]
<S11001001> imslavko: you could try deleting halves until you find the section whose deletion removes the error
<imslavko> I somewhat know what line causes issue, if this helps: https://github.com/Slava/decaf/blob/parser-base/test.ml#L21
<imslavko> I don't know how to fix it though :(
<imslavko> if you run `make` for this branch, the error would be File "test.ml", line 24, characters 0-3:
<imslavko> Error: Syntax error
<imslavko> S11001001 I am just getting desperate here, I tried putting semicolons, moving stuff around, etc
<imslavko> in that line I just want to print the result of function of type (string * string) list
ygrek has quit [Ping timeout: 240 seconds]
psy has quit [Ping timeout: 245 seconds]
psy has joined #ocaml
MercurialAlchemi has joined #ocaml
IbnFirnas has joined #ocaml
cdidd_ has joined #ocaml
cdidd has quit [Ping timeout: 264 seconds]
lambdahands has joined #ocaml
lambdahands has quit [Ping timeout: 246 seconds]
ygrek has joined #ocaml
antkong has joined #ocaml
orbitz_ has quit [Quit: Reconnecting]
orbitz has joined #ocaml
arboris` has joined #ocaml
chinglish has quit [Quit: Nettalk6 - www.ntalk.de]
ggole has joined #ocaml
araujo has quit [Quit: Leaving]
arboris` has quit [Remote host closed the connection]
terry852 has quit [Remote host closed the connection]
ebzzry has quit [Ping timeout: 256 seconds]
lambdahands has joined #ocaml
IbnFirnas has quit [Read error: Connection reset by peer]
<imslavko> thanks to manu3000 for helping me in PM
lambdahands has quit [Ping timeout: 246 seconds]
Haudegen has quit [Ping timeout: 245 seconds]
Haudegen has joined #ocaml
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
octachron has joined #ocaml
IbnFirnas has joined #ocaml
antkong has quit [Ping timeout: 255 seconds]
Haudegen has quit [Ping timeout: 245 seconds]
Haudegen has joined #ocaml
ebzzry has joined #ocaml
jonludla` has quit [Quit: Coyote finally caught me]
Kakadu has joined #ocaml
antkong has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
oscar_toro has quit [Ping timeout: 252 seconds]
thomasga has joined #ocaml
antkong has quit [Ping timeout: 240 seconds]
matason has joined #ocaml
bytbox has joined #ocaml
vanila has joined #ocaml
octachron has quit [Ping timeout: 245 seconds]
larhat has joined #ocaml
lambdahands has joined #ocaml
Simn has joined #ocaml
BitPuffin has quit [Ping timeout: 245 seconds]
octachron has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
lambdahands has quit [Ping timeout: 255 seconds]
axiles has quit [Quit: Quitte]
IbnFirnas has quit [Read error: Connection reset by peer]
AlexRussia has quit [Ping timeout: 264 seconds]
hellofunk has quit [Remote host closed the connection]
mort___ has joined #ocaml
hellofunk has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
mort___ has quit [Ping timeout: 265 seconds]
_andre has joined #ocaml
Haudegen has joined #ocaml
ivan\ has quit [Read error: Connection reset by peer]
AlexRussia has joined #ocaml
ivan\ has joined #ocaml
mort___ has joined #ocaml
yomimono has joined #ocaml
IbnFirnas has joined #ocaml
hellofunk has quit [Ping timeout: 272 seconds]
hellofun` has joined #ocaml
rand000 has joined #ocaml
hellofun` is now known as hellofunk
aluuu has joined #ocaml
skinkitten has joined #ocaml
AltGr has left #ocaml [#ocaml]
jonludlam has joined #ocaml
kapil__ has quit [Quit: Connection closed for inactivity]
ebzzry has quit [Remote host closed the connection]
lordkryss has joined #ocaml
aluuu has quit [Ping timeout: 245 seconds]
lambdahands has joined #ocaml
Thooms has joined #ocaml
lambdahands has quit [Ping timeout: 252 seconds]
thomasga has quit [Quit: Leaving.]
yomimono has quit [Ping timeout: 245 seconds]
thomasga has joined #ocaml
ontologiae has joined #ocaml
ingsoc has joined #ocaml
yomimono has joined #ocaml
IbnFirnas has quit [Read error: Connection reset by peer]
thomasga has quit [Quit: Leaving.]
zwer_r has joined #ocaml
zwer_r has quit [Client Quit]
Submarine has quit [Remote host closed the connection]
zwer has quit [Ping timeout: 250 seconds]
hekmek has joined #ocaml
zwer has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
IbnFirnas has joined #ocaml
ontologiae has quit [Ping timeout: 265 seconds]
AlexRussia has quit [Ping timeout: 256 seconds]
ebzzry has joined #ocaml
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
ollehar has joined #ocaml
pgas` has joined #ocaml
pgas has quit [Remote host closed the connection]
stux has quit [Ping timeout: 252 seconds]
tianon has quit [Ping timeout: 252 seconds]
Armael has quit [Ping timeout: 252 seconds]
Armael has joined #ocaml
axiles has joined #ocaml
martintrojer has quit [Ping timeout: 252 seconds]
stux has joined #ocaml
martintrojer has joined #ocaml
enitiz has joined #ocaml
Thooms has quit [Quit: WeeChat 1.0.1]
tianon has joined #ocaml
lambdahands has joined #ocaml
BitPuffin has joined #ocaml
lambdahands has quit [Ping timeout: 264 seconds]
enitiz has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
Thooms has joined #ocaml
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 246 seconds]
ingsoc has quit [Quit: Leaving.]
Thooms has quit [Quit: WeeChat 1.0.1]
pdewacht has quit [Ping timeout: 245 seconds]
octachron has quit [Ping timeout: 265 seconds]
thomasga has joined #ocaml
araujo has joined #ocaml
araujo has joined #ocaml
araujo has quit [Changing host]
IbnFirnas has quit [Read error: Connection reset by peer]
kapil__ has joined #ocaml
pdewacht has joined #ocaml
Hannibal_Smith has joined #ocaml
badkins has joined #ocaml
ollehar has quit [Read error: Connection reset by peer]
chouser has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
cojy_ has quit []
cojy_ has joined #ocaml
hellofunk has quit [Remote host closed the connection]
ollehar has joined #ocaml
IbnFirnas has joined #ocaml
bytbox has quit [Remote host closed the connection]
octachron has joined #ocaml
matason has quit [Ping timeout: 276 seconds]
shinnya has joined #ocaml
lambdahands has joined #ocaml
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
lambdahands has quit [Ping timeout: 264 seconds]
mobajm has quit [Ping timeout: 240 seconds]
ontologiae has joined #ocaml
tane has joined #ocaml
bytbox has joined #ocaml
ygrek has joined #ocaml
sdegutis has joined #ocaml
<sdegutis> Can you do pattern matching in a let symbol binding for variant types?
matason has joined #ocaml
<Drup> yes
<Drup> but it's not a good idea for variant types with more than one variants, because it would lead to incomplete pattern match
Thooms has joined #ocaml
<sdegutis> Drup: I plan to have a function verify ahead of time that it is in fact the right type
<sdegutis> Drup: what's the syntax for this?
vbmithr has joined #ocaml
<Drup> you mean, like a "typeof" ?
<thizanne> sdegutis: for the syntax, `type t = A of int;; let foo = A 3;; let A bar = foo` binds 3 to bar
<flux> but you will get a warning unless you disable them
<flux> in general it may be a better idea to pass on the deconstructed value you get while checking instead of the original one
<Drup> (I tend to put parentheses there, for clarity : "let (A bar) = ...")
<flux> so you get to benefit from the type checking
<Drup> flux: if there is only one variant, it's fine.
<flux> but I guess there are cases when it's not practical
<flux> drup, sounds to me there are many
<flux> as checking beforehand was mentioned
<companion_cube> btw whitequark, I had a problem with qualifying attributes in a ppx_deriving plugin
<sdegutis> oh nice
<whitequark> companion_cube: yes?
aluuu has joined #ocaml
<companion_cube> https://github.com/c-cube/cconv/blob/master/ppx/ppx_deriving_cconv.ml#L26 <--- using this, I thought "foo [@@cconv.ignore]" would work
<sdegutis> thizanne, Drup, flux: my plan is to have type lua_value = Integer of int | String of string, etc, and I will pass "lua_value list" into a Lua function defined in OCaml, and I can define it as let my_lua_fn (String s) (Integer i) = do_something s i
<whitequark> it should
<Drup> sdegutis: ah, you want partial definition
<Drup> then no, you can't do that.
<sdegutis> Drup: partial definition? that doesn't sound right
<Drup> do a pattern match
<sdegutis> oh sorry no no no
<sdegutis> I meant let my_lua_fn [(String s); (Integer i)] = do_something s i
<Drup> and what do you do if it's not exactly a string and an integer
<ggole> You can do that, but you'll get warnings
<Drup> ?
<sdegutis> I just took an argument called "args" and destructured it later
<companion_cube> hey, ppx_deriving_yojson isn't compatible with ppx_deriving 2.0 ? :(
<sdegutis> Drup: there is a function earlier that verifies at runtime that it is in fact a string and an int
<companion_cube> gah, never mind
<Drup> sdegutis: no, you can't do that.
<sdegutis> Drup: hy not?
<sdegutis> Drup: this one part of my code is not perfectly compile-time verifiable but that's inevitable because i'm wrapping a dynamic language (lua)
<sdegutis> Drup: im pretty sure i can do this
<sdegutis> Does anyone in here have experience with using ctypes with C files that are part of my project's own source, as opposed to being a statically linked library?
<def`> sdegutis: the usual way to fix this is to make the verification function produce a value with a stricter type
<sdegutis> def`: but I need a specific type signature for all my Lua functions written in OCaml
<sdegutis> def`: in this case: () -> lua_value list
<def`> sdegutis: then you juste assert false :P
<sdegutis> er wait, I had that wrong: lua_value list -> lua_return_value
<sdegutis> def`: what? im confused
<def`> let my_lua_fn = function [(String s); (Integer i)] -> blabla | _ (*anything else*) -> assert false
<def`> (you can also use a set of combinators to express that in a "lighter" fashion)
<sdegutis> def`: that would be nice except I want to throw a Lua exception for each specific argument
<sdegutis> I was actually planning on doing this:
<def`> then combinators are the way to go
<sdegutis> let my_lua_fn = make_lua_function [check_string; check_integer] (fun (String s); (Integer i) -> do_something s i)
<sdegutis> The first argument is a list of assertion functions that return Some <expected type> or None (i.e. valid arg)
blandflakes has joined #ocaml
<sdegutis> my make_lua_function then makes an anonymous OCaml function that checks all the args given to me by Lua first, before calling the second argument given to it (a fun)
<sdegutis> def`: what do you mean by combinator?
<def`> sdegutis: I finish some work, I'll give you an example in ~20minutes
<sdegutis> def`: is it possible you could just explain in a handful of words?
<sdegutis> def`: im pretty literate with complicated computer concepts, just not their common terms/names
<sdegutis> (like "combinator")
<sdegutis> Drup: do you have experience with ctypes?
<def`> sdegutis: the int, string, @->, return from ctypes are an example of combinators
<def`> you just build atomic components that you compose to process your input.
<sdegutis> def`: i dont know how ctypes works, i just know i cant get it to work
<def`> as you have observed, the resulting values are stronly typed
thegameg has quit [Quit: Bye :D]
thegameg has joined #ocaml
avsm has joined #ocaml
thegameg has quit [Quit: Bye :D]
<companion_cube> gah, utop is so annoying when it comes to copy/pasting its output
rgrinberg has quit [Quit: Leaving.]
<companion_cube> whitequark: http://vrac.cedeela.fr/truc
reem has joined #ocaml
<rks`_> companion_cube: why?
<companion_cube> it doesn't have \n between the prompt and the output
Submarine has joined #ocaml
rgrinberg has joined #ocaml
<rks`_> right
n1ftyn8 has quit []
n1ftyn8 has joined #ocaml
pgas` is now known as pgas
<companion_cube> I have to add many \n bu hand
<companion_cube> by hand*
<sdegutis> Why do you prefer OCaml to Haskell?
<companion_cube> predictable performance, for once
<vanila> the community is better
Submarine has quit [Remote host closed the connection]
<vanila> haskl people are really mean
<sdegutis> Language-wise
<companion_cube> I don't like much lazyness
<flux> vanila, really? I haven't quite seen that on #haskell, perhaps I haven't followed enough.
<sdegutis> flux: I've seen it in a few people, not many.
uris77 has joined #ocaml
<octachron> less optional language extension in the main compiler
<def`> (some combinators… those are really ugly but you should grasp the idea)
<flux> ocaml has: proper module system, object system/row types, strict-by-default, ability to perform side effects (ie: id-generators), opam (my understanding it's nicer than cabal), blindingly fast compilation times, experimental compiler forks for different purposes (ocaml java, ocaml-js, jocaml, metaocaml, ocapic), doesn't have a boatload of extensions that might lead into undecidable compilation ;)
<sdegutis> I can't even get the basic time_t example of ctypes working: https://github.com/ocamllabs/ocaml-ctypes/wiki/ctypes-tutorial
<flux> how does it not work?
<sdegutis> This prints nothing, it should print something.
<def`> works here
<whitequark> companion_cube: can you file a bug?
<def`> add %! to Printf.printf "%f\n"
<def`> Printf.printf "%f\n%!"
<def`> forces flushing
<companion_cube> whitequark: sure
<sdegutis> oops
<sdegutis> i didnt call this functino
<flux> :)
<sdegutis> and i dont know how to either
<sdegutis> oh i have an idea
<sdegutis> ill remove the param
<sdegutis> YAY!
<companion_cube> whitequark: can you confirm [@ord.compare] should also work with [@@deriving ord] ?
<companion_cube> (so I can provide a simpler example for you)
<sdegutis> in Oasis where do you pass -lncurses ?
pyon has quit [Ping timeout: 276 seconds]
darkf has quit [Quit: Leaving]
BitPuffin has quit [Ping timeout: 240 seconds]
IbnFirnas has quit [Read error: Connection reset by peer]
hellofunk has joined #ocaml
kapil__ has quit [Quit: Connection closed for inactivity]
rgrinberg has quit [Quit: Leaving.]
divyanshu has quit []
divyanshu has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
badkins has quit []
Denommus has joined #ocaml
ygrek has joined #ocaml
rgrinberg has joined #ocaml
Denommus` has joined #ocaml
Denommus has quit [Ping timeout: 246 seconds]
slash^ has joined #ocaml
Denommus` has quit [Ping timeout: 272 seconds]
Denommus has joined #ocaml
jonludlam has quit [Ping timeout: 264 seconds]
badkins has joined #ocaml
ivan\ has quit [Remote host closed the connection]
ivan\ has joined #ocaml
lambdahands has joined #ocaml
<ygrek> hi, I am following the manual on module aliases
<ygrek> last 4 points about compiling mylib
ontologiae has quit [Ping timeout: 255 seconds]
<ygrek> at step 3 when compiling mylib.ml with `ocamlc -c -no-alias-deps Mylib.ml` I get warnings
<ygrek> File "_none_", line 1:
<ygrek> Warning 49: no cmi file was found in path for module Mylib_A
<ygrek> File "_none_", line 1:
<ygrek> Warning 49: no cmi file was found in path for module Mylib_B
sdegutis has quit [Quit: Leaving...]
IbnFirnas has joined #ocaml
<ygrek> is that normal?
destrius has quit [Quit: Leaving.]
<ygrek> after that I can compile everything in topological order of dependencies
<ygrek> but if I do `ocamlc -c -no-alias-deps Mylib.ml` again I get a different Mylib.cmi
<ygrek> so I guess something is wrong
ygrek has left #ocaml [#ocaml]
ygrek has joined #ocaml
<whitequark> companion_cube: yes it should
hekmek has quit [Quit: Verlassend]
octachron has quit [Quit: Leaving]
BitPuffin has joined #ocaml
lambdaha1ds has joined #ocaml
jonludlam has joined #ocaml
lambdahands has quit [Ping timeout: 264 seconds]
ebzzry has quit [Remote host closed the connection]
<companion_cube> whitequark: bug report filed
thegameg has joined #ocaml
axiles has quit [Ping timeout: 245 seconds]
badkins has quit []
Rc43 has joined #ocaml
Rc43 has quit [Client Quit]
ebzzry has joined #ocaml
rock_neurotiko has joined #ocaml
rock_neurotiko has quit [Remote host closed the connection]
Rc43 has joined #ocaml
Haudegen has quit [Ping timeout: 264 seconds]
<ygrek> judging from http://caml.inria.fr/mantis/view.php?id=6063 it is kinda ok
valis_ has joined #ocaml
<companion_cube> so, I'm sad, I can't use type 'a set = WrapSet : (module Set with type t = 't and type elt = 'a) * 't -> 'a set
<companion_cube> because when I match the GADT, there is no way to unpack the module
<companion_cube> :(
Haudegen has joined #ocaml
lambdaha1ds has quit [Quit: leaving]
axiles has joined #ocaml
<whitequark> there isn't?
<companion_cube> let add set x = let WrapSet ((module S), set) = set in WrapSet((module S), S.add x set);;
<companion_cube> Error: The type of this packed module contains variables: (module Set.S with type elt = 'b and type t = t#0)
uris77 has quit [Ping timeout: 264 seconds]
uris77 has joined #ocaml
mcclurmc_ has joined #ocaml
chinglish has joined #ocaml
oscar_toro has joined #ocaml
mcclurmc has quit [Ping timeout: 265 seconds]
oscar_toro has quit [Ping timeout: 252 seconds]
oscar_toro has joined #ocaml
axiles has quit [Ping timeout: 255 seconds]
fraggle_ has joined #ocaml
thomasga has quit [Quit: Leaving.]
ollehar has quit [Ping timeout: 240 seconds]
mort___ has quit [Ping timeout: 272 seconds]
laalko has joined #ocaml
ontologiae has joined #ocaml
mobajm has joined #ocaml
mobajm has quit [Remote host closed the connection]
badkins has joined #ocaml
jwatzman|work has joined #ocaml
Rc43 has quit [Quit: Page closed]
MrScout_ has joined #ocaml
axiles has joined #ocaml
MrScout_ is now known as MrScout
IbnFirnas has quit [Read error: Connection reset by peer]
msch has quit []
msch has joined #ocaml
sdegutis has joined #ocaml
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
Kakadu has quit [Remote host closed the connection]
Hannibal_Smith has joined #ocaml
rfv has quit []
rfv has joined #ocaml
thomasga has joined #ocaml
Denommus has quit [Read error: Connection reset by peer]
valis_ has quit [Quit: Page closed]
jonludlam has quit [Ping timeout: 264 seconds]
q66 has joined #ocaml
psy has quit [Disconnected by services]
chinglish has quit [Quit: Nettalk6 - www.ntalk.de]
psy_ has joined #ocaml
ontologiae has quit [Ping timeout: 264 seconds]
jave has quit [Ping timeout: 256 seconds]
flhs has joined #ocaml
ollehar has joined #ocaml
Denommus has joined #ocaml
jave has joined #ocaml
BitPuffin has quit [Ping timeout: 276 seconds]
ygrek has quit [Ping timeout: 276 seconds]
leowzukw has joined #ocaml
mort___ has joined #ocaml
IbnFirnas has joined #ocaml
larhat has quit [Quit: Leaving.]
<sdegutis> Is there a function to print a general thing if I don't know what type it is, for debugging purposes?
<Drup> no
<chouser> huh! how does the repl do it?
<whitequark> REPL knows what the type is.
<whitequark> (since it runs the typechecker and remembers the result)
moei has quit [Quit: Leaving...]
<sdegutis> dang
<sdegutis> thats gonna make it tricksy
Submarine has joined #ocaml
Submarine has joined #ocaml
<laalko> I have a (key, value) list of tuples and a list of "key"s to get the corresponding values of (assumably by List.assoc), but I'm a bit stuck on how to List.map this correctly.
<jeroud> sdegutis: I generally write a formatter for every type and use that for debugging.
<sdegutis> ok
MrScout has quit [Ping timeout: 245 seconds]
<laalko> Any tips?
MrScout_ has joined #ocaml
avsm has quit [Ping timeout: 246 seconds]
<companion_cube> laalko: you mean find the value for each key?
<laalko> companion_cube, Yeah. If I run List.assoc key tuple_list it returns the desired result. I'm just not sure how to do that for each element in a list of keys to be checked
<companion_cube> List.map (fun key -> List.assoc key tuple_list) my_key_list
<companion_cube> 
<companion_cube> sorry
<companion_cube> lag
uris77 has quit [Quit: leaving]
<laalko> That returns the error "The function applied to this argument has type 'a list -> 'b list This argument cannot be applied with label ~f"
<laalko> Which is... odd
skinkitten is now known as INeedWork
<companion_cube> oh, you must be using Core
<companion_cube> then it's List.map ~f:(fun key -> ....) my_key_list
<laalko> Actually no, I'm a complete moron
<laalko> I _wasn't_ using core, but was using ~f:
<companion_cube> oh! :)
<laalko> It took me a min to see the diff between the two vers of that :)
manizzle has quit [Ping timeout: 252 seconds]
<laalko> I actually originally used Core for this for List.init but that ended up causing a bunch of confusion
<laalko> First program in OCaml
<companion_cube> don't be harsh on yourself :)
<jeroud> laalko: Seems more successful than my first program in OCaml. :-)
Haudegen has quit [Ping timeout: 256 seconds]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
thomasga has quit [Ping timeout: 265 seconds]
Haudegen has joined #ocaml
michatotol has joined #ocaml
<sdegutis> So far, the most confusing thing to me about OCaml is modules.
oriba has joined #ocaml
<sdegutis> I was on the Real World OCaml book's chapter on modules (chapter 3 or 4, I think?) and I just couldn't see why the author started creating modules with type "t" in it, instead of just creating a type in the current module.
<sdegutis> Please help me understand?
INeedWork is now known as HauntedC0de
<jeroud> sdegutis: That's so things that operate on modules can work more easily.
<smondet> sdegutis: it's a convention used by a bunch of people, if all types are called `t` in their module it makes it more practical to use functors
<sdegutis> So I'll learn about this more in the functors chapter?
<jeroud> Yes.
<sdegutis> Because, I started reading the Functors chapter, and was confused and thought I had missed some context in the original Modules chapter.
<sdegutis> So I went back and was still confused.
<jeroud> The functors chapter is a bit confusing.
<sdegutis> :'(
<sdegutis> All of RWO has been so far, except chapter 1 which was awesome
bezirg has joined #ocaml
<Drup> arguably, functors are a complicated feature.
MrScout_ has quit [Remote host closed the connection]
<jeroud> Basically, it's useful to have your modules match the input signature of a bunch of common functors.
<laalko> I actually have this program working in the REPL, woo. Now to figure out how to run it normally.
<jeroud> I can't remember any examples offhand, though.
<Drup> jeroud: the ones for Set.Make/Map.Make ;)
thomasga has joined #ocaml
reem has quit [Remote host closed the connection]
<laalko> Wait... what.
ivan\ has quit [Read error: Connection reset by peer]
<laalko> >Unknown directive `require'
ivan\ has joined #ocaml
<companion_cube> #use "topfind";; first? check you have ocamlfind installed
<jeroud> Drup: Yup. I should have remembered Set.Make considering I used it yesterday.
wwilly has joined #ocaml
<laalko> Hm... opam says I've got ocamlfind but #use can't find topfind
<sdegutis> I don't understand what the different syntaxes of "module" are specified as.. I saw "module type X = sig ... end" and "module N : X = struct ... end" and some others.
<laalko> companion_cube, This program works in the REPL, I'm trying to get it to run as a file now
<jeroud> I was surprised by how comfortable OCaml felt coming back to it several months after I first learned it.
MrScout has joined #ocaml
uris77 has joined #ocaml
<laalko> I really like OCaml so far, it's just completely different from anything I'm used to
<jeroud> sdegutis: The first is a module type, the second is an actual module.
<sdegutis> oh
<sdegutis> Are there any other syntaxes for modules besides these two, jeroud?
<Drup> sdegutis: it's the same as "type t = ...." and "let x : t = ..."
<companion_cube> laalko: ok, you need to tell your build system (ocamlbuild?) to link against libraries you use
<Drup> modules are like values : they have (module) types and (module) values, and the two live in different worlds.
<sdegutis> Drup: but "sig/end" and "struct/end" are special, and this is their only use, right?
<Drup> well, they are not really special, it's just the way you define them
<Drup> sig is for module types, struct is for module values
<sdegutis> ok
<laalko> companion_cube, I'm just running ocaml ./file
<companion_cube> laalko: I see
<companion_cube> it can be useful for scripts, but it's not a long-term solution :)
<companion_cube> the proper solution is compiling
<laalko> Oh I know, I just wanna make sure it works
Kakadu has joined #ocaml
<sdegutis> "We can use Increment to define new modules:" --- oooh, so functors are for creating new modules programmatically
<sdegutis> right?
<Drup> sort of
<ggole> They are pretty much functions over modules.
<sdegutis> um ok
<sdegutis> So I can create a list of modules?
<jeroud> sdegutis: More or less.
<sdegutis> Wait, does this mean you can have an anonymous module?
<Drup> sdegutis: you'll see that in the next chapter.
<jeroud> sdegutis: Look at the chapter about first-class modules.
jabesed has joined #ocaml
<jeroud> You need to turn them into named modules to use them, but you can pass them around and such.
<sdegutis> So a module is like a Java class and a module type is like a Java interface.
<sdegutis> (in terms of role)
<Drup> that's an acceptable analogy
<sdegutis> and functor is just another name for the fact that modules can act like functions?
<Drup> modules can't act like functions
<Drup> in your analogy, functor would be Java's generics
<sdegutis> uhh
<Drup> (except more awesome)
<jeroud> A functor is to a function as a module is to a value.
Kakadu has quit []
matason has quit [Ping timeout: 246 seconds]
<laalko> Hm, interesting
<laalko> I'm using corebuild and it can't find Str
<Drup> you are not loosing anything by not being able to use Str
<Drup> :D
<Drup> (you need to add --package str)
Kakadu has joined #ocaml
<struk|work> companion_cube: did Containers_misc.Hashset move elsewhere recently?
<laalko> Drup, thanks
<laalko> Oh my god this actually works.
<laalko> I'm shocked.
<companion_cube> struk|work: yes, I removed it
<adrien> pffft, breaking API!
<companion_cube> it's explicitely stated that containers_misc is unstable :p
<jeroud> Break all the APIs!
<struk|work> companion_cube: doh..so whats my alternative then?
<jeroud> (Except the ones I use.)
<companion_cube> struk|work: do you really need a polymorphic set? :/
rgrinberg has quit [Quit: Leaving.]
<struk|work> companion_cube: yep!
<companion_cube> hmmmmm
<struk|work> companion_cube: I could use a map of course but its much uglier
<companion_cube> ok, maybe I can put it back :D
<companion_cube> I removed really bad stuff, but HashSet was actually ok
<struk|work> companion_cube: ok works for me.
manizzle has joined #ocaml
<companion_cube> I'll put it back and release asap
<struk|work> companion_cube: much appreciated
<companion_cube> :)
<laalko> Hmm... This program is supposed to generate random numbers and it's using the same numbers each time I run it
<laalko> Something's very wrong :D
<Drup> did you initialized the PRNG ? :]
<laalko> yes
<laalko> Random.self_init ()
<Drup> arg !
<Drup> (I almost felt like my teacher when I was learning programming in OCaml)
<laalko> heh
<laalko> Drup, That's in my main function which ends up calling the function that uses Random
<Drup> can you show the whole code ?
<laalko> Drup, It's real ugly, you've been warned: http://pastebin.com/X1zDbRRe
<laalko> Line 8 is just the best :)
<Drup> Ah!
<Drup> you did initialized Random
<Drup> but after using it !
<Drup> a file is executed sequentially
leowzukw has quit [Quit: Lost terminal]
<Drup> in your case, it will compute dw_gen first
<Drup> which uses Random
<Drup> and Random.self_init is executed much later
<nicoo> Drup: Actually, I feel like Random shouldn't expose state in any way (i.e. self-init when the module is loaded, and re-init whenever fork() is called, or every N bytes being output), and force annoying people like C³ to use Random.State :>
<Tekk_> laalko: dw_gen and all the other stuff are variables, not functions
<Tekk_> I believe we talkd about this last night :)
<Drup> nicoo: go back writing your hash combinators.
<laalko> right right
flhs has quit [Ping timeout: 265 seconds]
<laalko> Tekk_, It was like 1am
<Tekk_> fair enough
<companion_cube> nicoo: I always use Random.State
<nicoo> Drup: They are on the other laptop, but I have them working
<companion_cube> so it's pure diffamation
<nicoo> companion_cube: Mmmh, I remember you saying that enforcing Random being properly initialized would break (your) things
<laalko> yaaaay
<nicoo> Might be mistaken
<companion_cube> no, randomized Hashtables would
<nicoo> laalko: Yaaay for IRC drama ?
<nicoo> companion_cube: Ah, yes indeed
<nicoo> My bad.
IbnFirnas has quit [Read error: Connection reset by peer]
<laalko> Drup, I originally had that line right after the opens, but the interpreter had complained
* nicoo hugs companion_cube
<laalko> which is why I had thought to move it to main
<Drup> nicoo: "yay" for randomly random.
<Drup> I think.
<laalko> Because I don't know what I'm doing :)
<Drup> laalko: that's fine, we all went through that.
<laalko> It works now tho
<companion_cube> nicoo: :p
<nicoo> laalko: Doing when you don't know what you are doing is usually good for learning :)
<MercurialAlchemi> what's wrong with Random.State anyway?
<companion_cube> nothing's wrong
<MercurialAlchemi> it looks like the proper way to do it
<nicoo> MercurialAlchemi: Nothing. We weren't complaining about Random.State
<nicoo> (Was that royal we or schizophrenic we?)
BitPuffin has joined #ocaml
<Tekk_> nicoo: who's to say that royals weren't schizophrenic?
<nicoo> Tekk_: Or is inclusive :þ
<Tekk_> .....interesting
<Tekk_> nicoo: what character did you use there?
<Tekk_> it didn't render properly in my terminal
<nicoo> This one: þ
<nicoo> It is an icelandic letter, and :þ looks like :P, but nicer
<Tekk_> yeah
<nicoo> (Yay for unicode emoji)
<companion_cube> struk|work: release in progress
<companion_cube> (it was about time)
<Tekk_> oh, thorn?
<Tekk_> þ
<Tekk_> hmm
<Tekk_> interesting
<Tekk_> seems like an emacs issue rather than a terminal one. weird since I've never seen another unicode char render badly.
<struk|work> companion_cube: its ok I already pinned
<whitequark> companion_cube: lol "fast"
<whitequark> i used to push fixes in fifteen minutes on my ruby parser thing, *that* was fast
<companion_cube> would "fast" be only "5 minutes later at most" for you?
slash^ has quit [Read error: Connection reset by peer]
<Drup> nicoo:
<Tekk_> yeah, that one renders..
* Tekk_ shrugs
matason has joined #ocaml
<whitequark> Drup: actually the former renders for me and yours does not
<companion_cube> same
<Drup> Tekk_: you mean,
<companion_cube> ÞÞÞþþÞÞþÞþ
<nicoo> Drup: ?
<Tekk_> Drup: yep
<Tekk_> Drup's
<Tekk_> not*
<MercurialAlchemi> neither of your emojis work in my terminal, but I think I don't have the right font
<Tekk_> MercurialAlchemi: what terminal are you using?
<whitequark> those are not emojis.
<MercurialAlchemi> irssi + urxvt
<whitequark> none of them.
<whitequark> it's just unicode characters
<Tekk_> MercurialAlchemi: URxvt*unicode: true
<Tekk_> URxvt.locale: en_US.UTF-8
<Tekk_> URxvt.imLocale: en_US.UTF-8
<Tekk_> in your ~/.Xresources :)
<Tekk_> (change the en_US as appropriate)
<MercurialAlchemi> but thorn works...
<Tekk_> oh
<Tekk_> I dunno then
yomimono has quit [Ping timeout: 244 seconds]
zwer_c has joined #ocaml
<MercurialAlchemi> whitequark: you have emojis in the unicode standard nowadays
<nicoo> Drup: Ok, this one doesn't appear here. On the other hand, xfce4-terminal is stupid sometimes
zwer has quit [Ping timeout: 250 seconds]
zwer_c_w has joined #ocaml
matason has quit [Quit: leaving]
<MercurialAlchemi> I think I'd rather have thorn work than have emojis
<Drup> you guys are not ~unicode~aware~ yet.
<whitequark> MercurialAlchemi: I'm aware
<MercurialAlchemi> Drup: whitequark is aware, see
<MercurialAlchemi> :D
<Drup> :D
<Drup> (especially about unicode, event in ocaml code)
<MercurialAlchemi> s/event/even/ ?
<Drup> even*
<sdegutis> Is there shorthand for creating an anonymous function to pass as the last argument to another function?
zwer_c has quit [Ping timeout: 250 seconds]
<MercurialAlchemi> that's one area where I remain blissfully unaware, on my US-ASCII cloud
<Tekk_> http://pastebin.com/zgYiGxaq ascii compatible rendition for the poor unicode-unawares :)
<whitequark> ASCII needs to die.
<sdegutis> It's butt ugly to type (func a b c -> c a b) with all those parens and stuff (what is this, Lisp?)
<Tekk_> sdegutis: I'll have you know that lisp is a perfectly fine language once you have an editor to automatically handle parens for you :)
<Drup> sdegutis: strategic use of @@ avoids many parentheses.
<Drup> (or |>)
<MercurialAlchemi> sdegutis: well, we leave the $ sign to Haskell, it's too capitalistic for the OCaml crowd
rgrinberg has joined #ocaml
* MercurialAlchemi holds with |>, it's one of the best things about OCaml
<MercurialAlchemi> Tekk_: what if you suffer from paren blindness?
<Tekk_> MercurialAlchemi: then you probably should't be writing lisp. I am not paren blind :P
<sdegutis> Tekk_: I use Clojure for my day job in emacs with paredit.el, and you're wrong, it's still awful.
<sdegutis> Drup: @@ ?
reem has joined #ocaml
<Tekk_> sdegutis: try scheme some time. I can't speak for clojure *shrugs*
<Drup> defined as "let (@@) f x = f x"
<Tekk_> Drup: could you give me an example of a line with @@?
<Tekk_> that seems a bit useless
<sdegutis> Tekk_: lisp's dynamic typing is the main problem
_andre has quit [Quit: leaving]
<Tekk_> sdegutis: it certainly does cause some annoyance
<Tekk_> I've wanted to write a statically typed lisp for a long time
<sdegutis> racket has one
<Tekk_> but macros and stuff certainly make that more interesting I'd imagine
<struk|work> companion_cube: containers master worked fine for me, thanks
<Drup> Tekk_: foo @@ bar @@ very_long_multiline_argument
reem has quit [Remote host closed the connection]
<Drup> instead of "foo ( bar ( very_long_multiline_argument ))"
<Tekk_> ah
<sdegutis> oh thats kinda nice
reem has joined #ocaml
ggole has quit []
<sdegutis> let make_person = make_lua_fn [check_string; check_int] @@ fun [ String name; Integer age ] -> ...
<sdegutis> much nicer.
<mrvn> Bah, don't use lists as args
<sdegutis> mrvn: I have to have a function signature that can take any combination of types
<mrvn> sdegutis: cps or gadts
<sdegutis> mrvn: it has to allow for functions that take 3 strings and an int, or 2 ints and 1 stirng and 1 int, etc
<sdegutis> mrvn: whats that?
<Drup> mrvn: no seriously, stop
<Tekk_> oh, anyone familiar with playing with ctypes? I can't figure out for the life of me where this is going wrong
<Drup> he started ocaml 4 days ago
<Drup> don't tell him about gadts
<Tekk_> having color values corrupted somewhere in text rendering for my sdl2 binding
<sdegutis> Drup: im clearly an ocaml epert by now
<mrvn> Then he shouldn't be writing lua bindings
<Drup> mrvn: I agree, but that's out of my hands
<sdegutis> mrvn: im fully qualified to write lua bindings in anything i choose
<Drup> but you don't have to terrify him already
<mrvn> sdegutis: The basic idea is that you pass in functions for the check things and build the expected type of the actual function with that.
<sdegutis> mrvn: thats fine, but then can i write a function (like "make_lua_fn") that takes a function matching any of these generated function types?
<mrvn> sdegutis: you then get a type like this for example: val make_lua_fn : ('a -> 'b) checks -> 'a -> 'b
IbnFirnas has joined #ocaml
<Drup> at least, I warned.
<laalko> Drup, companion_cube: Thanks you two: https://github.com/dewbasaur/ocaml-diceware
<sdegutis> Drup: do you consider me to be totally incompetent?
<mrvn> sdegutis: In the above you would have (string -> int -> something) checks as first type.
<sdegutis> Drup: i dont take offense if you do
aluuu has quit [Ping timeout: 276 seconds]
<Drup> sdegutis: no, just not competent enough for gadts
<flux> sdegutis, what are you writing btw? just wondering if you knew about the ocaml lua bindings :). (I haven't tried them)
<sdegutis> Drup: yeah huh, called it, no call-backs
<flux> or are you even using them
<mrvn> sdegutis: Another (uglier way) is to use format strings: make_lua_fn "%s%d" fn
<Drup> sdegutis: also, I've been here enough to know about mrvn's explanations
<sdegutis> flux: i am writing lua bindings to learn ocaml; thus i want to avoid looking at ocaml-lua as much as possible
<flux> sdegutis, nice :)
<mrvn> sdegutis: but format strings are limited to basic types and use compiler magic.
<sdegutis> flux: i did the same thing to learn swift: https://github.com/sdegutis/DIY-Window-Manager/tree/master/Lua/Lua
<sdegutis> its also part of my osx window manager
<sdegutis> which i hope to rewrite in ocaml
<sdegutis> Drup: hahahahhaa
<sdegutis> mrvn: ewwww
MrScout has quit [Remote host closed the connection]
<mrvn> sdegutis: google for the cps based printf / scanf code for an example. That is probably the nicest way for this kind of functions.
<mrvn> sdegutis: with lists you always get stupid warnings that your pattern matching isn't exhaustive.
<sdegutis> mrvn: i rather liked my version
<sdegutis> oh
<sdegutis> i could do what someone else suggested and use function with _ -> assert false
<sdegutis> but thats ugly too
<mrvn> sdegutis: and what happens when I call: let make_person = make_lua_fn [check_string; check_int] @@ fun [ Integer age; String name ] -> ...?
<sdegutis> oh wait, idea
<laalko> Next, shall I clean up, replace / compress functions, or implement user arguments... hm...
<sdegutis> i could have function with | _ -> wrong_types [ check_string ; check_int ]
<mrvn> sdegutis: runtime checks suck when you can do compiletime checks instead
<sdegutis> mrvn: you don't call this function yourself, Lua calls it
<sdegutis> mrvn: i agree
MrScout has joined #ocaml
Denommus` has joined #ocaml
<sdegutis> mrvn: so whats that way you said that builds up a new type?
<sdegutis> functors or something?
<sdegutis> mrvn: actually no you're totally and completely and utterly wrong here
Denommus has quit [Ping timeout: 245 seconds]
<sdegutis> mrvn: the user can call this function from lua, so there is absolutely no chance that i can catch mismatched types at compile-time, ever.
MrScout has quit [Read error: Connection reset by peer]
MrScout has joined #ocaml
<MercurialAlchemi> hmm, the drawbacks of having the current opam switch in your zsh prompt is that it makes zsh unhappy when installing a new switch
Denommus` has quit [Ping timeout: 255 seconds]
<sdegutis> hahaha
<mrvn> sdegutis: but at least you can make sure the given checks match the function args.
<sdegutis> I'm seriously considering learning Haskell, but I don't know what the crap a monad is and it sounds scary. Does OCaml have them?
<mrvn> sdegutis: not all of it
moei has joined #ocaml
<mrvn> sdegutis: monads are verry powerfull things that lets you hide the side effects of input/output just so you can claim your language is clean and doesn't have any.
<Drup> the appear occasionally, but let's say it's not an usual idiom like it is in haskell.
<sdegutis> mrvn: I essentially can build up a "lua_value list" (i.e. Integer 3 :: String "foo" :: Nil :: Integer 2) in my intermediate function when handling a Lua function call to call OCaml with.
<S11001001> mrvn: monads are not about side effects.
<Drup> what S11001001 said.
<sdegutis> mrvn: thus I can just do the function pattern matching and have a _ case that asserts a list of expected types
<mrvn> S11001001: they still are used for it
<MercurialAlchemi> monads are not scary, but they can be a bit painful
<S11001001> mrvn: Yes. But that is a totally different relationship than the one you just suggested.
<MercurialAlchemi> definitely not an integral part of the language like in Haskell
<Drup> mrvn: that's an unfortunate decision by haskell people, not a fact about monads
<MercurialAlchemi> (the really unfortunate decision is the monad transformer tower, IMHO...)
<Drup> it's like saying "gadts are for printers" because Format/Printf are inplemented with them ...
<mrvn> anyway, ocaml can only build a subset of the monads haskell can do.
<Drup> not really ...
<MercurialAlchemi> monads are like alcohol, use too many of them at once and you're going to get a bad headache
<Drup> it's just monads are a pita to use in OCaml
<sdegutis> so it turns out i was right all along
<sdegutis> lua_value list is the best way to go
<companion_cube> Drup: they just aren't as convenient, but come on, not a "pita"
<Drup> companion_cube: parametrized over a monad takes much more code than in Haskell, so, yes, pita.
<mrvn> sdegutis: it's the simplest but not the safest
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
<mrvn> sdegutis: and every function needs a _ -> raise Wrong_args
<sdegutis> mrvn: it is the safest because lua
<sdegutis> mrvn: yes but they all would have had arg-checking anyway
<sdegutis> mrvn: otherwise let me ask you this:
<mrvn> sdegutis: it's unsafe because it lets you give different checks than the function needs
<sdegutis> mrvn: is there a way to inspect, at runtime, a variable list of types given to a function, and do something based on them?
<Drup> given your knowledge of statically typed languages and OCaml, I find your very presumptuous to think that you already know the best way to do things :D
<sdegutis> mrvn: oh also this allows me to have a function that takes both [string;string;int] and [string;int] and do two different things afaik
<mrvn> sdegutis: I expect lua has runtime type infos and you convert them to a variant type in ocaml in some way, right?
<sdegutis> Drup: why sir or madam, i have been using statically typed languages since before you were born
<Drup> Java doesn't count.
<sdegutis> Drup: assuming you're no more than 8 years old
<mrvn> sdegutis: overloading makes it a lot more complex.
<sdegutis> mrvn: hardly!
<Drup> (and I'm only judging by what I see ;) )
<sdegutis> function | [ String s ] -> do_something s | [ Integer i ] -> do_something_else i | _ -> wrong_args
<sdegutis> or some crap
<mrvn> sdegutis: but how do you give the checks list for that?
<MercurialAlchemi> opam install github
<sdegutis> wrong_args [ [check_string];[check_int] ]
<mrvn> see, more complex
<sdegutis> your face is more complex
swgillespie has joined #ocaml
Denommus has joined #ocaml
<sdegutis> Drup, et al: best explanation ive seen so far on functors: "functors are like functions, but they operate on modules. To understand why they can't just be functions, you need to understand why modules can't just be normal data."
<mrvn> except modules in ocaml are first class now
<Drup> we should do a serie of blog post about functors
<Drup> culminating by "functors are buritos"
<mrvn> functors do static dispatch and first class modules do dynamic dispatch, right?
<Drup> and, to put a cherry on the top, A paper "functors are not functors nor applicative functors."
<Drup> (In order to settle the matter, you know)
<Drup> rgrinberg: for next Christmas, on the 24, special edition ? :D
<mrvn> lets write a functor factory.
<Drup> mrvn: that's easy, you can totally do high order functors
<MercurialAlchemi> I wrote a module factory recently
<mrvn> MercurialAlchemi: common construct to generate unique keys/types.
<MercurialAlchemi> well, not in my case
<MercurialAlchemi> it was an experiment to see how easy it would be hide request-level variables from the service layer in a classic MVC-with-service pattern
<MercurialAlchemi> -> it's cumbersome
AlexRussia has joined #ocaml
<Drup> (as long as you can't put Y in functors, we are safe)
<mrvn> Why? (play on words :)
icicled has joined #ocaml
<Drup> for termination purposes :<
<Drup> (ok, you can encode Ackermann, so practical termination is already screwed)
<mrvn> ack 9 9;;
<icicled> Is there an easy way to reuse the functions in Yojson.Basic.Utils with Yojson.Safe.json?
vanila has quit [Quit: Leaving]
<Drup> MercurialAlchemi: you do realize eliom sort of do that ?
<Drup> oh, it's not really properly hidden, you are right
<Drup> yes, it's annoying.
<MercurialAlchemi> Drup: no, unfortunately my free time largely vanished, and along with it my let's-study-eliom-time :(
<Drup> :(
<MercurialAlchemi> Drup: well, I'm not too satisfied with my solution, either, first-class modules are syntax-heavy
<Drup> yes
<Drup> when I tried something like that, I ended up simply creating a function returning None if outside a request and Some ... if inside a request
<Drup> by not-so-carefully applied side effects
<MercurialAlchemi> so you had some kind of thread-level request object?
<Drup> it's not thread level, but yes
<MercurialAlchemi> right
<Drup> basically, you have some form of scoped references, you decide the scope (the request, the user, the website, ..). The headers are, for example, a request-specific reference
<Drup> and eliom takes care of not screwing up the side effects machinery to handle that.
<Drup> it works, but I never looked at how it's implemented n__n
<MercurialAlchemi> Drup: well, like they say, anybody can write Java in OCaml: http://paste.debian.net/142415/
<Drup> weee :D
<Drup> ahah, that's not pretty
<Drup> (this is a typical example of why I think purity is not always such a great idea)
avsm has joined #ocaml
blandflakes has quit [Quit: Page closed]
ontologiae has joined #ocaml
jcloud has quit [Remote host closed the connection]
mariusae has quit [Remote host closed the connection]
andreypopp__ has quit [Remote host closed the connection]
jeroud has quit [Remote host closed the connection]
eventualbuddha has quit [Remote host closed the connection]
S11001001 has quit [Remote host closed the connection]
bobpoekert has quit [Remote host closed the connection]
Submarine has quit [Remote host closed the connection]
<MercurialAlchemi> Drup: no, it isn't
thomasga has quit [Quit: Leaving.]
ollehar has quit [Ping timeout: 276 seconds]
<MercurialAlchemi> on the other hand you can guarantee that everything is transactional very easily
<MercurialAlchemi> without cases of transactions-within-transactions
<MercurialAlchemi> it's not so much an issue of purity as of encapsulation
eventualbuddha has joined #ocaml
badon has joined #ocaml
flhs has joined #ocaml
Denommus` has joined #ocaml
jeroud has joined #ocaml
Denommus has quit [Ping timeout: 246 seconds]
AlexRussia has quit [Ping timeout: 245 seconds]
rgrinberg has quit [Quit: Leaving.]
osa1 has joined #ocaml
<osa1> any ideas where can I find print_code mentioned here http://okmij.org/ftp/ML/MetaOCaml.html ?
Denommus` has quit [Ping timeout: 240 seconds]
<pippijn> osa1: in metaocaml
Anarchos has joined #ocaml
<osa1> I'm already using metaocaml
<osa1> I mean which module/package/whatever
<osa1> Print_code.print_code
<osa1> found it
thomasga has joined #ocaml
<pippijn> right
andreypopp__ has joined #ocaml
<osa1> what is a formatter though
<pippijn> a Format.formatter
AlexRussia has joined #ocaml
pyon has joined #ocaml
mariusae has joined #ocaml
IbnFirnas has quit [Read error: Connection reset by peer]
S11001001 has joined #ocaml
osa1 has quit [Quit: Konversation terminated!]
osa1_ has joined #ocaml
bobpoekert has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
rgrinberg has joined #ocaml
<sdegutis> Haskell is suddenly appealing to me.
psy_ has quit [Read error: No route to host]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<rgrinberg> Drup: better start writing it now :D
<companion_cube> :D
<companion_cube> o/ rgrinberg
<Drup> sdegutis: something something greener grass something :D
<sdegutis> I'm mostly drawn by the ecosystem and the lack of this confusing module stuff.
<Drup> (not to say haskell is bad, to each his own :p)
<laalko> So while ocaml-diceware in its current state was useful for learning, it's pretty much as inefficient as it could possibly be :D
<rgrinberg> Drup: we need a vouillon reminder to merge a simple PR and we can finally make a release :D
<Drup> hum
<Drup> I can do that tomorrow, I think.
<scythe-> all ecosystems look better from a distance
<scythe-> (including natural ones, it looks pretty until it tries to eat you)
<scythe-> e.g. opam looks awesome but then it's a pain because everything is the wrong version or whatever
<MercurialAlchemi> *cough* cabal *cough*
MrScout has quit [Ping timeout: 245 seconds]
<sdegutis> MercurialAlchemi: what about cabal?
<tcpc> *cough* *cough*
<Drup> scythe-: everything is the wrong version ?
<MercurialAlchemi> and don't you reinstall something
<Drup> MercurialAlchemi: it warns you if you want to reinstall :D
<Drup> "reinstalling is dangerous !"
<MercurialAlchemi> yes, it tells you how many kittens it's going to chew
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
<MercurialAlchemi> except it's schrodingger kittens, so you only got to find out if they're going to be eaten when you say "yes"
<Drup> or rather, half an hour later
MrScout has joined #ocaml
<struktured> ugh worst commute ever. I had to way for 5 subways to go by to get home. damn "historic" blizzard
<struktured> *wait
<pippijn> nyc?
<smondet> MercurialAlchemi: sdegutis if you know of a package manager somewhere on earth dealing with opam's problems better than opam, i'd be very curious
<struktured> pippijn: yeah, time for same ocaml though, now that I escaped the office
<smondet> struktured: 4,5,6 lines that bad?
<struktured> smondet: if you aren't a jerk you aint getting home any time soon
<MercurialAlchemi> smondet: opam works for me (most of the time)
<smondet> struktured: boss made us work from home today and tomorrow
<struktured> smondet: it would have been fine if I left around 2 pm
Haudegen has quit [Ping timeout: 246 seconds]
<struktured> smondet: but yeah, WFH tommorow, which means more ocaml
<smondet> cool :)
Denommus has joined #ocaml
Haudegen has joined #ocaml
IbnFirnas has joined #ocaml
pyx has joined #ocaml
pyx has quit [Client Quit]
ontologiae has quit [Ping timeout: 246 seconds]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
osa1_ has quit [Read error: Connection reset by peer]
blandflakes has joined #ocaml
ollehar has joined #ocaml
<sdegutis> Does OCaml have functions like take and drop from Haskell?
shinnya has quit [Quit: ZNC - http://znc.in]
antkong has joined #ocaml
<thizanne> (it tells you "not in standard lib")
shinnya has joined #ocaml
badkins has quit []
<struktured> sdegutis: on the plus side, core, containers, batteries, etc. have them
<sdegutis> ok
<struktured> sdegutis: or gen and sequence, in particular
Denommus` has joined #ocaml
<sdegutis> thnks
<sdegutis> haskell it is
sdegutis has left #ocaml ["Leaving..."]
<struktured> your welcome?
<struktured> :|
Denommus has quit [Ping timeout: 255 seconds]
AlexRussia has quit [Ping timeout: 264 seconds]
Denommus` has quit [Ping timeout: 255 seconds]
<whitequark> don't worry, he'll return in a hour after trying to use cabal
<struktured> yeah I was about to take an over/under on his return time after haskell annoys him again in some capacity
mort___ has quit [Quit: Leaving.]
osa1_ has joined #ocaml
claudiuc has joined #ocaml
AlexRussia has joined #ocaml
uris77 has quit [Quit: leaving]
tane has quit [Quit: Verlassend]
rgrinberg has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
blandflakes has quit [Ping timeout: 246 seconds]
mcclurmc_ has quit [Remote host closed the connection]
MrScout has quit [Remote host closed the connection]
badon has quit [Quit: Leaving]
bezirg has left #ocaml [#ocaml]
ollehar has quit [Quit: ollehar]
MrScout has joined #ocaml
mcclurmc has joined #ocaml
c74d3 is now known as c74d
ivan\ has quit [Read error: Connection reset by peer]
ivan\ has joined #ocaml
chinglish has joined #ocaml
relrod has quit [Quit: ZNC - http://znc.in]
relrod_ has joined #ocaml
swgillespie has joined #ocaml
Thooms has quit [Quit: WeeChat 1.0.1]
jonludlam has joined #ocaml
relrod_ is now known as relrod
IbnFirnas has quit [Read error: Connection reset by peer]
reem has quit [Remote host closed the connection]
jwatzman|work has quit [Quit: jwatzman|work]
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
Kakadu has quit []
badon has joined #ocaml