Yoric has quit [Remote host closed the connection]
oriba has joined #ocaml
ontologiae_ has quit [Ping timeout: 258 seconds]
Thooms has quit [Quit: WeeChat 1.0.1]
rgrinberg has joined #ocaml
<struktured>
Leonidas: heres one quick and dirty function for it.."let take_up_to n l = LazyList.take_while (let cnt = ref 0 in fun _ -> if (!cnt) >= n then false else (cnt := !cnt + 1;true)) l"
yomimono has quit [Ping timeout: 250 seconds]
<Leonidas>
struktured: thanks, I'm wondering if this is a bug or I am misunderstanding something.
oriba has quit [Quit: Verlassend]
<struktured>
Leonidas: has to be misunderstanding...I'm assuming they want you you to use peek, or implicit approaches like fold, map, etc.
<Leonidas>
struktured: no, I have a (possibly) infinite sequence and want to take n elements from it, if available.
<Leonidas>
which is pretty much what Batteries' docs for take say.
Arsenik has quit [Remote host closed the connection]
<struktured>
Leonidas: eh it says "alpha3" not a great sign. but yeah, there are some exceptionless ways to play with the list, I suggest using those over take, or as a guard before taking.
<Leonidas>
struktured: thanks for the effort but no. I'll probably either take your approach with the ref or open a bug.
thomasga has quit [Quit: Leaving.]
<struktured>
Leonidas: and theres always containers, if you want to dump batteries (/shamelessplug)
Puffin has joined #ocaml
<Leonidas>
I know containers, but I use a number of other things from batteries and don't really want to mix
<struktured>
Leonidas: got it, good luck sir!
<Leonidas>
(though the BatEnum.t and list duality is kinda annoying already)
<Leonidas>
struktured: thanks! :-)
rgrinberg has quit [Quit: Leaving.]
joncfoo has quit [Ping timeout: 250 seconds]
madroach has quit [Ping timeout: 250 seconds]
madroach has joined #ocaml
kakadu has quit [Remote host closed the connection]
mgzk has quit [Ping timeout: 250 seconds]
nojb has quit [Quit: nojb]
badon has quit [Quit: Leaving]
NoNNaN has quit [Remote host closed the connection]
NoNNaN has joined #ocaml
seangrove has joined #ocaml
yomimono has joined #ocaml
hugomg has quit [Ping timeout: 255 seconds]
HrafnA has quit [Quit: HrafnA]
shinnya has quit [Ping timeout: 250 seconds]
struktured has quit [Quit: Konversation terminated!]
struktured has joined #ocaml
srcerer has quit [Ping timeout: 265 seconds]
srcerer has joined #ocaml
srcerer has quit [Client Quit]
srcerer has joined #ocaml
waneck has quit [Ping timeout: 240 seconds]
waneck has joined #ocaml
rgrinberg has joined #ocaml
seangrove has quit [Ping timeout: 244 seconds]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
manud has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
yomimono has quit [Ping timeout: 244 seconds]
Puffin has quit [Ping timeout: 244 seconds]
MrScout_ has joined #ocaml
MrScout has quit [Ping timeout: 240 seconds]
MrScout_ has quit [Ping timeout: 258 seconds]
ontologiae_ has joined #ocaml
manud has quit [Quit: Be back later ...]
badkins has joined #ocaml
ygrek has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
rgrinberg has quit [Quit: Leaving.]
manud has joined #ocaml
emery has joined #ocaml
q66 has quit [Quit: Leaving]
badkins has quit []
bytbox has quit [Remote host closed the connection]
bytbox has joined #ocaml
ontologiae_ has quit [Ping timeout: 250 seconds]
waneck_ has joined #ocaml
waneck has quit [Ping timeout: 256 seconds]
nojb has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
Yoric has quit [Remote host closed the connection]
thomasga has joined #ocaml
davine has joined #ocaml
davine has left #ocaml [#ocaml]
Anarchos has joined #ocaml
Yoric has joined #ocaml
nojb has quit [Quit: nojb]
Thooms has joined #ocaml
maurer has quit [Ping timeout: 245 seconds]
maurer has joined #ocaml
<hugomg>
Is there a way in Ocaml to write an "early return" statement without using if-then-else and indenting the whole rest of the function?
<adrien>
definitely!
<adrien>
exceptions :D
<Drup>
exit too
<Drup>
it returns.
<mrvn>
quite deeply
<whitequark>
you can also segfault
<whitequark>
or system("halt -p")
<mrvn>
whitequark: only with extern or Qobj
<mrvn>
Obj
<Drup>
I would even say that it returns definitely :D
<whitequark>
mrvn: or you can allocate all memory!
<mrvn>
Drup: the ultimate return
<whitequark>
mrvn: or you can mmap a Bigarray and truncate it!
<mrvn>
whitequark: does the GC then segfault or throw an exception?
<ggole>
Plenty of ways to segfault without extern or Obj
<whitequark>
(although that would be SIGBUS)
<mrvn>
whitequark: see, not segfault
maurer has quit [Ping timeout: 258 seconds]
<whitequark>
mrvn: that would still exit
<whitequark>
or you can send SIGSEGV to yourself.
<whitequark>
it's still technically a segfault.
<mrvn>
whitequark: now that is cheating. :)
<whitequark>
it's a defined API!
<Drup>
give a 1 tuple to the compiler
<hugomg>
The thing that worries me about exceptions is that I don't want to swallow other exceptions by accident or propagate any exceptions out of my function. Do I create a custom exception type for every function I want to use an "early reutrn" pattern on?
maurer has joined #ocaml
<Drup>
it will returns very early.
<Drup>
(okay, it was fixed)
<mrvn>
Drup: like ref 1?
<hugomg>
also, how efficient are exceptions in Ocaml? We are talking about replacing an if statement here :)
<Drup>
mrvn: no no, a 1 tuple, really
<Drup>
(you need a ppx)
<ggole>
hugomg: they're fastish
<mrvn>
hugomg: don't do it to avoid an if. You do it to e.g. escape an List.fold_left early.
<ggole>
I'd just live with the if.
<hugomg>
but my function gets ugly if I indent it too much :/
<mrvn>
hugomg: if the indentation becomes too much consider splitting the function
<ggole>
If you find yourself indenting a lot, you probably need to break some parts out
chambart has joined #ocaml
<mrvn>
hugomg: if foo then 42 else rest_of_function ()
<mrvn>
Although that has the drawback of making the code flow kind of backwards. rest_of_function has to be declared first.
<whitequark>
hugomg: exceptions are equivalent to a longjmp, essentially
<whitequark>
it's like a dozen instructions.
<MercurialAlchemi>
It's quite easy to create custom exceptions
shinnya has joined #ocaml
<mrvn>
whitequark: aren't they a constructor + simple function call?
<MercurialAlchemi>
Unfortunately, it's just as easy to forget to catch them
AlexRussia has joined #ocaml
AlexRussia has quit [Changing host]
AlexRussia has joined #ocaml
<mrvn>
hugomg: batteries and core afaik both have constructs for early returns that internally use exceptions for you.
<whitequark>
mrvn: I was talking about the insides of raise
<hugomg>
mrvn: yeah, I'm not a big fan of splitting functions for presentation/length purposes and I also don'tlike the backwards flow much... but I think I can live with it
<hugomg>
what constructins in batteries/core are you talking about? never heard of them
<MercurialAlchemi>
Core has also Option/Result monadic approaches to this issue
<hugomg>
the monadic version still fights against ocp-indent though, unless you use one of those do-notation syntax extensions
<hugomg>
I had some code that I kep needing to go back and reindent by hand whenever I accidentally told vim to indent the whole file :)
<MercurialAlchemi>
:)
fraggle_laptop has joined #ocaml
<Drup>
MercurialAlchemi: I don't understand the remark about "/projects/$id_of_type_A_project/foo/$foo_i" and I feel like a indirect reddit discussion will not be sufficient so, explain please.
thomasga has quit [Quit: Leaving.]
<MercurialAlchemi>
Drup: :)
bezirg has quit [Ping timeout: 255 seconds]
bezirg has joined #ocaml
<MercurialAlchemi>
Drup: I was wondering how you'd do something like Jersey with this system
thomasga has joined #ocaml
<Drup>
what's jersey ? it's not exactly googlable :p
<MercurialAlchemi>
mostly, it's about nested resources
<MercurialAlchemi>
a resource class (eg, ProjectResource) knows how to find a project in a database, and return nested resources
samrat has joined #ocaml
<MercurialAlchemi>
it makes it easy to plug the same resource at multiple endpoints, which sometimes makes sense
avsm has quit [Quit: Leaving.]
<Drup>
Can you gives me a croncrete example ?
avsm has joined #ocaml
<MercurialAlchemi>
Drup: in a moment, I need to wrap up a CR
<Drup>
because to me, this whole thing is still static. Annoying to define and could be helped by a deriver, but static
joncfoo has quit [Ping timeout: 240 seconds]
<MercurialAlchemi>
hm
<MercurialAlchemi>
I think you're right, framing it in terms of dynamic vs static was a mistake
<MercurialAlchemi>
the thing is, a resource acts both as a parser (in the sense that it consumes part of the path) and as a non-final handler (since it performs a side effect by retrieving data in the DB and creating a child resource with this data)
<Drup>
that's one way to look at it
<MercurialAlchemi>
with some more code, it could also let you do something like Django's mountable apps
<Drup>
the other way is just that the path is the same and the handler is (fun v k = let v' get_from_database v in get_value v' k)
darkf has quit [Quit: Leaving]
samrat has quit [Quit: Computer has gone to sleep.]
axiles has quit [Quit: Quitte]
<MercurialAlchemi>
well, the advantage with the path-consuming thing is that the resource knows what it can answer to, but it is blissfully unaware of wherever it is plugged to
<MercurialAlchemi>
as opposed to a global routing table for the whole app
<Drup>
why is that an advantage ?
<Drup>
you could also say that you have global routing and only ask the resource about what it could know, it would still not know about the rest
<MercurialAlchemi>
yes, but if you want to, say, offer the same sub-hierarchy from two endpoints, you end up duplicating your routes
lordkryss has quit [Quit: Connection closed for inactivity]
<MercurialAlchemi>
and no pluggable apps for you
mcclurmc has joined #ocaml
<MercurialAlchemi>
(I found them a really good idea, back when I was doing a bit of Django)
<Drup>
I think I would need to try for real
<Drup>
the way you talk about it is a bit too "hands in the air" for me to really get the point of it
Thooms has quit [Quit: WeeChat 1.0.1]
samrat has joined #ocaml
<MercurialAlchemi>
I'll try to make an example in a pastebin and link it on reddit
ocp has quit [Ping timeout: 250 seconds]
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
bezirg has quit [Quit: Leaving.]
travisbrady has quit [Quit: travisbrady]
arj has quit [Quit: Leaving.]
struktured has quit [Ping timeout: 258 seconds]
mcclurmc has joined #ocaml
nojb has joined #ocaml
kapil__ has quit [Quit: Connection closed for inactivity]
<MercurialAlchemi>
It has a bit of Pyramid-specific jargon, but nothing terrible
axiles has joined #ocaml
thomasga has quit [Ping timeout: 265 seconds]
badkins has quit [Read error: Connection reset by peer]
<Drup>
MercurialAlchemi: ok, read
<Drup>
1) The way it's done in this framework sounds extremely duck-type-y (as expected from python). Especially the "view lookup" part
<Drup>
2) you can encode that in url matching by providing a "suffix list" combinator, and it will be quite trivial.
<Drup>
3) It seems quite useless most of the time :p
tane has joined #ocaml
travisbrady has joined #ocaml
travisbrady has quit [Client Quit]
WraithM has joined #ocaml
rgrinberg has joined #ocaml
mort___ has quit [Ping timeout: 265 seconds]
avsm has quit [Quit: Leaving.]
arj has joined #ocaml
badkins has joined #ocaml
badkins has quit [Client Quit]
thomasga has joined #ocaml
ontologiae_ has quit [Quit: WeeChat 1.0]
ontologiae has joined #ocaml
arj has quit [Quit: Leaving.]
ollehar has quit [Ping timeout: 265 seconds]
fraggle_laptop has quit [Ping timeout: 265 seconds]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
<Drup>
rgrinberg: you are not ready for multi-lingual conversation :D
Yoric has quit [Ping timeout: 258 seconds]
ygrek has joined #ocaml
travisbrady has joined #ocaml
thomasga has quit [Quit: Leaving.]
tharugrim has quit [Ping timeout: 240 seconds]
thomasga has joined #ocaml
tharugrim has joined #ocaml
<rgrinberg>
:D
<rgrinberg>
so what about this regex compat thing?
<Drup>
I think we can drop backward references and other silly things like that, as long as, on the set of feature that we keep, the syntax is the same
<mrvn>
Anyone using menhir with oasis?
<Drup>
mrvn: yeah
<mrvn>
what do I put into the _oasis file?
<Drup>
nothing
<Drup>
you put "true: use_menhir, explain" in the _tags
q66 has joined #ocaml
<Drup>
rgrinberg: also, on the feature we drop, we have an error message if the feature is used
<Drup>
not silent spaghetti
<mrvn>
Drup: thx
<mrvn>
Drup: any idea how to make _tags git friendly? I don't want the generated stuff in git.
<rgrinberg>
Drup: what is the regex used for again? i.e. does it even make sense for it to have capturing groups
<Drup>
now, you could do a wrapper to get you closer to this concept of traversal, but I don't think you really need
travisbrady has joined #ocaml
rgrinberg has joined #ocaml
lostman_ has quit [Quit: Connection closed for inactivity]
ygrek has quit [Ping timeout: 255 seconds]
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
kakadu has joined #ocaml
yomimono has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
matason has joined #ocaml
chambart has joined #ocaml
matason has quit [Ping timeout: 245 seconds]
Arsenik has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
samrat has quit [Ping timeout: 264 seconds]
samrat has joined #ocaml
olauzon has joined #ocaml
samrat has quit [Ping timeout: 258 seconds]
samrat has joined #ocaml
slash^ has joined #ocaml
samrat has quit [Ping timeout: 245 seconds]
samrat has joined #ocaml
rgrinberg has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
<MercurialAlchemi>
yeah
<MercurialAlchemi>
though with the interface I have, you could do typesafe resource traversal and inject whatever you need in the child resource
<MercurialAlchemi>
you'd probably want a full-blown HTTP request data structure instead of a list of strings, and return an HTTP response instead of Done, but it would work
tani has joined #ocaml
tane has quit [Killed (cameron.freenode.net (Nickname regained by services))]
tani is now known as tane
mearnsh has quit [Quit: git tae fuck]
mearnsh has joined #ocaml
samrat has quit [Ping timeout: 244 seconds]
samrat has joined #ocaml
matason has joined #ocaml
Thooms has joined #ocaml
ggole has quit []
samrat has quit [Ping timeout: 256 seconds]
<pippijn>
the menhir post looks promising
<Drup>
yep
slash^ has quit [Read error: Connection reset by peer]
<mrvn>
Warning: one state has shift/reduce conflicts.
<mrvn>
Warning: 5 shift/reduce conflicts were arbitrarily resolved.
<mrvn>
Is there a way to see which?
<pippijn>
yes
<pippijn>
there are a bunch of flags that help, I forgot which
<pippijn>
menhir --help
<Drup>
mrvn: you will find a find parser.conflicts that explains everything
<Drup>
a file*
<pippijn>
oh right, you already did --explain
rgrinberg1 has joined #ocaml
rgrinberg has quit [Read error: Connection reset by peer]
<Drup>
always use merlin with --explain :)
<mrvn>
ahh, overlooked that
tov has quit [Remote host closed the connection]
<thomasga>
"Warning: the tag "tests" is not used in any flag declaration, so it will have no effect; it may be a typo. Otherwise use `mark_tag_used` in your myocamlbuild.ml to disable this warning."
<mrvn>
How come ! and ~ and ?++ are prefix operators but ? alone is not?
thomasga1 has joined #ocaml
<Drup>
mrvn: ~ is not either
<mrvn>
right. but ! is for some reason
<Drup>
probably because it was used for ref first, then the operator system was figured out after, but it was kept
<Drup>
or something like that
matason has quit [Ping timeout: 250 seconds]
<mrvn>
? and ~ are listed as keywords but ! is not.
kgzm_ has quit [Quit: leaving]
thomasga1 has quit [Client Quit]
thomasga has quit [Ping timeout: 264 seconds]
thomasga has joined #ocaml
eyyub has quit [Ping timeout: 272 seconds]
Lmry2 has joined #ocaml
Lmry2 has left #ocaml [#ocaml]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
WraithM has quit [Remote host closed the connection]
badkins has quit []
davine has joined #ocaml
davine has left #ocaml [#ocaml]
rgrinberg1 has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
ontologiae has quit [Ping timeout: 256 seconds]
Arsenik has quit [Remote host closed the connection]
rand000 has joined #ocaml
jpdeplaix has joined #ocaml
matason has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
MercurialAlchemi has quit [Ping timeout: 245 seconds]
<travisbrady>
Anyone have a tip on how to express the C type “void* mats[]” in a call to ocaml-ctypes’ Foreign.foreign? ptr (ptr void) ?
matason has quit [Ping timeout: 256 seconds]
oscar_toro has joined #ocaml
tane has quit [Quit: Verlassend]
dav has quit [Read error: No route to host]
<companion_cube>
struk|work: probably friday
<Drup>
travisbrady: yes
<travisbrady>
Drup: thank you.
ingsoc has joined #ocaml
chambart has quit [Ping timeout: 264 seconds]
jao has quit [Ping timeout: 240 seconds]
chambart has joined #ocaml
<Drup>
travisbrady: you will probably want to make use of the module Ctypes.CArray
yomimono has quit [Ping timeout: 245 seconds]
dav has joined #ocaml
ingsoc has quit [Quit: Leaving.]
ohama has quit [Remote host closed the connection]
WraithM has joined #ocaml
struk|work has quit [Ping timeout: 246 seconds]
nicoo has quit [Ping timeout: 250 seconds]
lordkryss has joined #ocaml
nojb has quit [Quit: nojb]
nicoo has joined #ocaml
nojb has joined #ocaml
NoNNaN has quit [Remote host closed the connection]
chambart has quit [Ping timeout: 256 seconds]
lu324___ is now known as lu324
ohama has joined #ocaml
kakadu has quit [Remote host closed the connection]
nojb has quit [Quit: nojb]
Hannibal_Smith has quit [Read error: Connection reset by peer]