<Drup>
invalid_argument is to signal that the code is violating some invariants about the function you are using (here, Array.get). It should not be raised and caught, you are supposed to check the invariant to avoid it (and use options)
<freehck>
def`: heathen! :)
<def`>
and beware of -unsafe compiler flag
oscar_toro has quit [Ping timeout: 250 seconds]
ely-se has joined #ocaml
<freehck>
Drup: I dont know why Array.get raises specifically Invalid_argument instead of some Out_of_bounds exception. It should be raised and catched this way, because (obviously) it's a normal situation when a programmer's trying to get a value out of bound of some array.
<freehck>
Drup: So I think Invalid_argument is not a quite good decision for exception in this case.
<freehck>
But the standard library uses it, so we must to follow the rules.
<freehck>
*must follow
<octachron>
freehck: the out of bound check can be disabled by a compiler option, so any out of bound exception would be unreliable
Bluddy has joined #ocaml
<freehck>
octachron: oh, really?
<freehck>
okay, so I am completely wrong.
<apache2>
ew, imperative
<freehck>
apache2: don't use the 1st example.
<flux>
it affects .(x) only though?
<flux>
Array/String.get is always checked?
<ggole>
It's checked unless you compile with -unsafe
<flux>
or maybe not
<ggole>
Array/String.unsafe_get/set are always unchecked.
<flux>
it seems that .(0) is converted to .unsafe_xxx as expected
<flux>
with -unsafe
<flux>
whereas regularly it's of course compiled to .get/.set
<flux>
so I imagine -unsafe does not affect the functionality of the functions
<ggole>
I guess you could module Array = CheatingArray at the top of the file and intercept the rewrite
<freehck>
Wait-wait-wait. Do I ubderstabd right that .(x) is Array.get if -unsafe is not enabled, and otherwise it's Array.unsafe_get?
<ggole>
Yep.
<freehck>
*understand
<freehck>
cool. thx.
<octachron>
beware that the rewriting from .() to Array.get/set is not here anymore in the dev version of the compiler
ely-se has quit [Quit: leaving]
<flux>
hmm, so I wonder how the -unsafe switch works there?
cball has quit [Ping timeout: 246 seconds]
<freehck>
octachron: what does mean 'is not here'?
<freehck>
here is where?
<flux>
'there'
<flux>
.(x) uses some other mechanism than rewriting
<flux>
currently .(x) is literally rewritten to Array.xxx
<flux>
you can define your own Array module and it gets called
<octachron>
flux, there are new compiler primitives whose behavior is controled by -unsafe
<ggole>
Is this part of flambda?
<hcarty>
ggole: Separate
<ggole>
Hmm, interesting.
<flux>
flambda is not integrated yet to master is it?
<ggole>
Guess I should stop suggesting that awful hack
<flux>
..you've been suggesting that awful hack?-)
ely-se has joined #ocaml
<ggole>
Mostly because it is intriguingly disgusting.
<ggole>
And no, not as a serious development practice.
<apache2>
are there any plans to port the bitstring module to the new immutable string paradigm?
nullcatxxx_ has joined #ocaml
cball has joined #ocaml
ely-se has quit [Quit: leaving]
<nicoo>
apache2: bitstring was written by Richard WM Jones, so you are better off asking him. In any case, porting it to use ppx rather than camlp4 would be more pressing.
* nicoo
also doesn't see what is so new or paradigm-y about immutable strings.
<apache2>
ah, perhaps that's what I meant. I'm not so well-versed in the ocaml ecosystem yet
<nicoo>
No, the ppx vs. camlp4 issue is completely different. Basically, both are mechanisms for implementing language extensions; camlp4 is more powerful, but not-so-nice to work with and camlp4 extensions do not compose well.
ollehar has joined #ocaml
thmslld has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kakadu has quit [Ping timeout: 246 seconds]
nullcatxxx_ has joined #ocaml
tg has quit [Ping timeout: 255 seconds]
yomimono has quit [Ping timeout: 240 seconds]
orbifx has quit [Quit: WeeChat 1.3]
ollehar has quit [Ping timeout: 256 seconds]
<tibor_>
How can I compare two strings?
<tibor_>
match s1 with
<tibor_>
match s1 with s2 -> true | _ -> false;;
<tibor_>
?
<Drup>
s1 = s2 ?
<ggole>
String.compare?
<tibor_>
let eq s1 s2 = if s1 = s2 then true else false;;
<tibor_>
let eq s1 s2 = if 0 = String.compare s1 s2 then true else false;;
<Drup>
tibor_: think very hard about this if expression,then simplify it
tg has joined #ocaml
<tibor_>
I have a simple bug and I can't manage to fix it
<tibor_>
if something || String.compare s1 s2 then x1 else x2;; something is always false and s1 <> s2 but then how can x1 execute?
ofzyh has joined #ocaml
<ggole>
Well, String.compare returns an int, so I suppose that should be String.compare s1 s2 = 0 (which indicates they are equal)
<tibor_>
yes
<ggole>
If you've got that right, then x1 should not execute indeed
^elyse^ has joined #ocaml
<tibor_>
if something || 0 = String.compare s1 s2 then x1 else x2;;
<tibor_>
Yes :( I'm very confused
<octachron>
tibor_, is the prevously line *exactly* your code?
<ggole>
Pastebin the code, maybe
<ggole>
By the way, if you have adopted the 0 = expr test trick from C, that isn't necessary in OCaml - the error it is intended to avoid isn't possible
Tekilla has joined #ocaml
<tibor_>
no : let strcmp = match s1 "some string"-> true | _ -> false;
<Drup>
ggole: I don't even know that thing, what is it ?
<ggole>
Writing if (0 == expr) instead of if (expr == 0) to avoid the = vs == mistake
<tibor_>
if something || 0 = strcmp s1 then x1 else x2;;
<ggole>
That is, if you typo == as = it will fail to compile instead of just doing something wacky
<ggole>
I've heard them called "Yoda conditions"
<Drup>
ggole: ah, I see, that is ... C
shinnya has joined #ocaml
<jerith>
In Java and friends, "foo".equals(thing) allows one to avoid a null check.
<jerith>
(That's where I got into the habit of putting the constant first when comparing.)
<octachron>
tibor_, a possibility, if x1 and x2 have side-effect and you have them defined as "let x1=.. in", then the side effect have already been executed before the if _ else _
<octachron>
otherwise, you should probably pastebin your code. Predicting misunderstanding is hard.
HoloIRCUser1 has joined #ocaml
<tibor_>
let isC str = match str with | "%#sdfdf$%" -> true | _ ->false;;
<tibor_>
f = if !flag || Sess.is c then x1 else x2;; and found x1 in my f but flag is false and c <> "%#sdfdf$%"
jwatzman|work has joined #ocaml
HoloIRCUser1 has quit [Remote host closed the connection]
tane has quit [Quit: Verlassend]
HoloIRCUser1 has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Haudegen has quit [Ping timeout: 250 seconds]
HoloIRCUser1 has quit [Remote host closed the connection]
<octachron>
tibor_, how did you deduce that your error is in this code fragment and not somewhere before?
HoloIRCUser has joined #ocaml
jonludlam has quit [Ping timeout: 252 seconds]
HoloIRCUser has quit [Remote host closed the connection]
tane has joined #ocaml
<SomeDamnBody>
I am using ocamlgraph, and I'm having difficulty with the fact that the module functors that I pass in that define operations and types of nodes and edges respectively don't expose type equality outside of the module itself
<SomeDamnBody>
so I have module NodeAreInts = struct type t = int;; let compare = max end
Haudegen has joined #ocaml
<SomeDamnBody>
but later, I try and manipulate nodes with regular functions that take ints and the compiler is not having any of it because int != G.NodesAreInts.t
toomuchtvrotsurb has joined #ocaml
tani has joined #ocaml
<Drup>
compare = max ???
tane has quit [Ping timeout: 244 seconds]
<Drup>
(also, please pastebin the whole code)
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
blueperson1102 has joined #ocaml
psy_ has joined #ocaml
nullcatxxx_ has joined #ocaml
mserpent has joined #ocaml
kushal has quit [Ping timeout: 246 seconds]
blueperson1102 has quit [Remote host closed the connection]
<mrhmouse>
SomeDamnBody: could you pastebin an example? is NodesAreInts.t an int or is it an abstract type?
mserpent has quit [Remote host closed the connection]
blueperson1102 has joined #ocaml
TheLemonMan has joined #ocaml
__rlp_ is now known as __rlp
rgrinberg has joined #ocaml
slash^ has joined #ocaml
jeffmo has quit [Ping timeout: 255 seconds]
j0sh__ is now known as j0sh
native_killer has quit [Ping timeout: 246 seconds]
tristero has quit [Quit: tristero]
systmkor has joined #ocaml
systmkor has quit [Remote host closed the connection]
systmkor has joined #ocaml
yomimono has joined #ocaml
blueperson1102 has quit [Remote host closed the connection]
jeffmo has joined #ocaml
<struk|desk>
companion_cube: do you have any plans to add a result or or_error type to containers, or do you want users to consider using rresult, core's or_error, or argarwal/future instead?
lwlvlpl has quit [Quit: Updating details, brb]
strmpnk has joined #ocaml
yomimono has quit [Ping timeout: 250 seconds]
yomimono has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
yomimono has quit [Ping timeout: 260 seconds]
yomimono has joined #ocaml
ril has joined #ocaml
kushal has quit [Ping timeout: 255 seconds]
thmslld has quit [Ping timeout: 264 seconds]
Tekilla has quit [Quit: Quitte]
darkf has quit [Quit: Leaving]
tmtwd has joined #ocaml
<companion_cube>
struk|desk: there is CCError for this, using poly variants
<companion_cube>
once the stdlib result arrives, I will probably add CCResult
kushal has joined #ocaml
<adrien>
"there is a CC* for everything"
NingaLeaf123 has quit [Quit: Leaving]
<zozozo>
companion_cube: with the stdlib result type, will CCError use it, or keep the same type with poly variants ?
tmtwd has quit [Remote host closed the connection]
sh0t has joined #ocaml
<companion_cube>
I think I will keep the poly variant, for retrocompat
yomimono has quit [Ping timeout: 268 seconds]
yomimono has joined #ocaml
<Drup>
meh
<Drup>
don't
<companion_cube>
don't preserve retrocompat ?
yomimono has quit [Ping timeout: 255 seconds]
<Drup>
In this case, yes. It's better to be compatible with the rest of the ecosystem
<companion_cube>
well I'm not sure the ecosystem will move instantly toward the result type
<companion_cube>
e.g. will Bunzli break all his libraries?
<Drup>
Bunzli already made Rresult, which will be compatible with the stdlib thing, and is moving towards using it instead
<companion_cube>
so he's breaking his libraries?
<companion_cube>
well I will have a transition period, I guess
thmslld has joined #ocaml
<companion_cube>
or I could break everything and put labels and stuff, sure
BitPuffin has quit [Ping timeout: 268 seconds]
<Drup>
I think the first step is to tell everyone to use function constructor and avoid manual pattern matching, then the transition is painless
<companion_cube>
yeah
<hcarty>
Drup: 'R.ok v' vs 'Ok v'?
<companion_cube>
CCError.catch
<Drup>
yes
<companion_cube>
sometimes I really want labels in containers, btw
<companion_cube>
like, today
<adrien>
it's a good thing you can add them :P
<companion_cube>
well not without breaking compat or duplicating a lot of code, sadly :/
<adrien>
you should have made the API label-only :P
<companion_cube>
I was young and foolish
<companion_cube>
;)
<hcarty>
If we're wishing, I want a way to cleanly mix rresult with lwt!
<ggole>
Having users is the worst thing for a library other than not having any users.
<hcarty>
And implicit modules. I'm hoping I get all of my wishes within the next year.
<companion_cube>
yeah
<companion_cube>
and flambda
<Drup>
and .... and .... and ...
<Drup>
oh fuck, I created C++
<companion_cube>
and that's it :p
<Drup>
:D
<companion_cube>
and remove objects :p
<companion_cube>
so that we don't have C++
slash^ has quit [Read error: Connection reset by peer]
<Drup>
objects are really not the most complicated things in OCaml
<ggole>
They sure are the thing you'd rip out first though.
<Drup>
I certainly hope we can rip Stream out first, but that's not a language thing
<companion_cube>
Drup: well, they are the most complicated to use imho
<hcarty>
companion_cube: ∅Caml?
<companion_cube>
just look at the error messages
<Drup>
companion_cube: eh, module much ? poly variants ?
shinnya has quit [Ping timeout: 255 seconds]
<companion_cube>
no
<companion_cube>
poly variants are so much easier
<companion_cube>
don't have self types, for one
<def`>
ok my wishes: I want erlang/smalltalk like introspection, and a high-quality GUI toolkit
* Drup
smiles devilishly as maintainer and user of tyxml.
<Drup>
companion_cube: actually, they do.
natrium1970 has joined #ocaml
<ggole>
Polymorphism makes introspection a bit tough
<def`>
I know :(
<companion_cube>
'a ty wouldn't satisfy you?
<def`>
it would surely be better than nothing
yomimono has joined #ocaml
<natrium1970>
When I run “opam show js_of_ocaml”, I see the line “version: 2.6” and under available versions, it shows “1.2, 1.3.1, 1.3.2, 1.4.0, 2.0, 2.1, 2.2, 2.3, 2.4, 2.4.1, 2.5, 2.6”. However, if I run “opam install js_of_ocaml”, it installs 2.5. I want 2.6.
<ggole>
You could try to associate an 'a ty with every top level binding and each element of each stack frame
<ggole>
I think you could do it with type-passing, but that has a real performance hit afaik
<Drup>
natrium1970: install aspcud
<natrium1970>
I tried it. I cannot figure out how.
<natrium1970>
It was an exercise in frustration.
<hcarty>
Drup: How would you avoid explicit pattern matching, and keep relatively clean code, when you have: match a_err, b_err with | Ok _, Error _ -> ... | Ok _, Ok _ -> ... | Error _, Ok _ -> ... | etc.
<def`>
ggole: if this feature has runtime cost, nobody will use it
<hcarty>
Drup: It's something I run into now and then but haven't come up with a satisfactory option to replace pattern matching.
<natrium1970>
Why can’t I just force it to install 2.6? There’s no way to do that?
<Drup>
jwatzman|work: do you have an HL on "infer" ? :D
<jwatzman|work>
Drup: nope, but I have one on "facebook" in this channel :)
oldmanistan_ has quit [Ping timeout: 256 seconds]
<jwatzman|work>
(I don't actually work on Infer, though I worked a tiny bit with the team to help them open source it)
<ollehar>
but what if we speak of books with faces in them?
<Drup>
I guess it works too. "infer" might be too noisy ^^ '
n1ftyn8_ has quit [Ping timeout: 256 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<ollehar>
jwatzman|work: btw, when you're here, any news about LLVM for HHVM?
<jwatzman|work>
ollehar: last I heard, it was still being worked on, perhaps on the back burner? I think they got it perf neutral? I don't know for sure
Bluddy has quit [Ping timeout: 264 seconds]
<ollehar>
jwatzman|work: hm ok, thanks!
NhanH has quit [Read error: Connection reset by peer]
<ollehar>
jwatzman|work: can I ping anyone who works on it? I have a question about php exceptions and llvm function attributes. but I guess that's a c++ team...
<jwatzman|work>
ollehar: yeah. you are best off going into #hhvm, bsimmers is a good person to try to poke
<jwatzman|work>
he's not in the channel nor at his desk right now though
<ollehar>
thanks again!
<ollehar>
hm ok
ygrek has quit [Ping timeout: 264 seconds]
<mfp>
Drup: I realized RList's make_from_s cannot be safely executed within an update step, and defining a correct one is surprisingly hard
hcarty has quit [Ping timeout: 240 seconds]
<mfp>
using make_from (make + using the handle is no good as it performs send x on an internal event, which musn't be done within an update step)
ril[away] has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<mfp>
it all amounts to this problem: given a 'a React.signal, how do you get an 'a React.event (with the initial value) without waiting for a change, using only combinatorial ops (no primitives like S.value or E.create)
<mfp>
so far I've been unable to, using the fixed point operator and/or higher-order signals :-/
xfighter1188 has joined #ocaml
<xfighter1188>
hello
<xfighter1188>
can someone explain why my first code works
<def`>
xfighter1188: your fist call to check_duplicates lacks eq argument
<def`>
(line 4)
<xfighter1188>
it does?
<xfighter1188>
oh it does hold on
<Algebr`>
Drup: Say I wanted to use jsoo with nodejs, or whatever, how can I make that happen?
<xfighter1188>
i don't think thats the issue tho?
<xfighter1188>
oh it is
<xfighter1188>
hmmm
<xfighter1188>
wow ty
<xfighter1188>
why does the error message
<Algebr`>
Drup: I'm also interested in using jsoo with Electron, that thing that lets you make cross platform GUI applications.
<xfighter1188>
not telkl me anything then
<def`>
it tells you that the type of check_duplicates is wront
<def`>
wrong*
ollehar has quit [Quit: ollehar]
<xfighter1188>
oh
<xfighter1188>
okay darn im really bad at reading
<xfighter1188>
these ocaml
<xfighter1188>
error messages
<bbc_>
doesn't it says that `a` is not of the expected type?
<def`>
but it can't tell why it is wrong :)
<xfighter1188>
Error: This expression has type 'a but an expression was expected of type 'a -> 'b -> bool The type variable 'a occurs inside 'a -> 'b -> bool
<xfighter1188>
i thought that it was trying to apply
<xfighter1188>
eq to
<xfighter1188>
h and t on line 7
<def`>
it said line 4
<xfighter1188>
i don't see a line number in the error message?
<xfighter1188>
unless im blind
<xfighter1188>
oh
<xfighter1188>
on the website
<xfighter1188>
hmmm how come ocaml on my computer doesn't give me the line number thats
<xfighter1188>
weird
<xfighter1188>
thanks anyawys didn't realize it was just me being dumb
<xfighter1188>
can you explain to me how ocaml knows not to apply the function but to pass it in stead?
<xfighter1188>
is it because i specified in the parameter?
NhanH has joined #ocaml
<def`>
what do you mean?
bbc_ is now known as bbc
<xfighter1188>
like
<xfighter1188>
if (check_duplicates eq h t)
<xfighter1188>
how does it know to not just pass
<xfighter1188>
(eq h t)
<xfighter1188>
does it do it by type?
<mrvn>
xfighter1188: precedence
oldmanistan_ has joined #ocaml
<xfighter1188>
can you elaborate a bit haha sory
cojy has joined #ocaml
<mrvn>
xfighter1188: in "x y z" x is an expression that gets arguments applied. Anything that comes after that are arguments. Arguments take precedence over any applications you might see in "y z".
<def`>
xfighter1188: it surely not do it by type, a property of ocaml is that type don't affect semantics
<def`>
yep as mrvn said, it is purely syntactic
<xfighter1188>
okay hold on
<xfighter1188>
i have some method defined like
<xfighter1188>
let something f x y
<mrvn>
You have to write if check_duplicates (eq h t)
<xfighter1188>
where f is a function
<xfighter1188>
oh
<xfighter1188>
okay so it dfeaults
<xfighter1188>
wait okay so lets say i have some function
<xfighter1188>
let something boolean x y
<mrvn>
A function is just another value. nothing special about it.
<xfighter1188>
and f is likle a' -> boolean
<xfighter1188>
if i do something f x y
<xfighter1188>
it won't work right>?
<xfighter1188>
because it would treat f like a function not
<xfighter1188>
a boolean?
<mrvn>
sure it works. It passes f, x and y to something.
<flux>
precedence means a b c d is interpreted exactly as: (a (b (c (d))))
<xfighter1188>
oh
<flux>
waaiit, no :-)
<mrvn>
flux: other way
<xfighter1188>
wait but
<flux>
I of course meant ((((a) b) c) d)
<mrvn>
((((a b) c) d) e)...
<xfighter1188>
okay sorry can we walk through this
<xfighter1188>
eq which is of type int -> int -> boolean
<xfighter1188>
and l which is a' list
<xfighter1188>
when i call remove_duplicates f a
<xfighter1188>
where f is some function int -> int -> boolean and a is a list
<xfighter1188>
how does it know to pass f as a fucntion, rather than apply a to f
<xfighter1188>
and pass it in as a boolean
<mrvn>
It doesn't and it never would
<xfighter1188>
well other than that doesn't work with those types
<xfighter1188>
what do you mean it doesn't
<mrvn>
remove_duplicates f a == ((remove_duplicates f) a)
<xfighter1188>
i thought the whole point of higher order functions is you can pass in fucntions
n1ftyn8_ has joined #ocaml
<xfighter1188>
oh youare saying
<xfighter1188>
it would never do the latter
<xfighter1188>
it would always pass in as a fucntion
<flux>
yes, it would never apply the argument
<xfighter1188>
i see
<mrvn>
It (at first) has no idea what f is. The grammar simply says that it is an argument that gets applied to a function.
<flux>
if you have a b c, b and c are not applied
<xfighter1188>
i see i see
<flux>
, it is a that is applied the arguments b and c
<xfighter1188>
so lets say i have some function boolean -> int
<flux>
of course, if you have a (b c), then you have 'b' in the first position, and c gets applied to it
ygrek has joined #ocaml
<xfighter1188>
wait okay let me rephrase
<xfighter1188>
if i wanted it to pass in whatever the value of the function was
<xfighter1188>
i would need to do (f a b)
<xfighter1188>
or something?>
<mrvn>
xfighter1188: then you must use ()
<xfighter1188>
oh
<xfighter1188>
makes so much more sense haha
<xfighter1188>
thank you guys
<xfighter1188>
i have a midterm tomorrow
<mrvn>
xfighter1188: ocaml works the other way than you think. It seed "x y z". So it figures x is a function taking y and z as arguments. It then figures out what types y and z could have and from that constructs the type of x.
<xfighter1188>
and i just hd some lingery questions
<xfighter1188>
yeah
<mrvn>
s/seed/sees/
<xfighter1188>
that makes more sense now
<xfighter1188>
i was thinking that
<xfighter1188>
it knew the type of y
<xfighter1188>
and operated under that notion
<mrvn>
Nope
<xfighter1188>
but it actually doesn't and just treats it like
<xfighter1188>
some dumb argument
<xfighter1188>
okay
<xfighter1188>
horrayyy
<mrvn>
as the saying goes: functions are first class
<xfighter1188>
yeah i can't say im taht familiar with funtional programming yet
<xfighter1188>
i did some over the summer but it was scala
<xfighter1188>
which is kinda different
<mrvn>
xfighter1188: a function is just like any other value. In ocaml you can even pass modules as areguments nowadays.
<xfighter1188>
yeah okay thank you
<xfighter1188>
i was so confused before
<xfighter1188>
wondering how it knew to do things
<mrvn>
anyway, the grammar says what gets applied where and the type system comes way later.
<xfighter1188>
but this also works if i just have 2 functions
<xfighter1188>
let me type out what im ean
<mrvn>
the check_duplicates is a local (or nested) function. Makes it unavailable from the outside. Doesn't pollute the global namespace.
<xfighter1188>
oh lol
nullcatxxx_ has joined #ocaml
<xfighter1188>
answered my question
<xfighter1188>
without me providing more info ty
sh0t has joined #ocaml
<mrvn>
Another way of looking at it is: check_duplicates is just a value you create inside the outer function. That it happens to be a function itself is no realy relevant (until you call it).
<xfighter1188>
yeah
<xfighter1188>
okay that makes sense once you said that
<mrvn>
It's like: let f x y = let t1 = x * y in let t2 = x + y in ...
<mrvn>
But the keeping it local and out of the global namespace is usualy the reason why you have nested functions.
<xfighter1188>
yeah then i can use
<xfighter1188>
t1 and t2 again
<xfighter1188>
as variable names
<xfighter1188>
but not as funcitons
<mrvn>
(makes little sense in your example though, check_duplicates sounds like a perfectly usefull global function)
<mrvn>
xfighter1188: you can use them as functions. But then you get a type error.
msch has joined #ocaml
<mrvn>
xfighter1188: you can also try using them as floats, lists or arrays and you just get a type error because they are int.
<xfighter1188>
oh okay
<xfighter1188>
wait but
<xfighter1188>
if i do something like what yousaid
<xfighter1188>
then aren't t1 and t2
<xfighter1188>
the scope is only without
<xfighter1188>
f right?
<mrvn>
being a function makes 0 difference. It's just another value with a certain type and types have to match their use.
rfv has joined #ocaml
<xfighter1188>
sorry i mis worded it
<xfighter1188>
but im eant
<xfighter1188>
the scope just lasts
<xfighter1188>
within f
<xfighter1188>
and outside of f
<xfighter1188>
the names are free again
<mrvn>
yes, t1 and t2 are purely local.
<xfighter1188>
okay
<xfighter1188>
time to go study my induction proofs
rpg has joined #ocaml
^elyse^ has quit [Quit: sleep]
icicled has quit [Quit: Leaving]
opal has joined #ocaml
<Drup>
Algebr`: I know some people used jsoo for node.js
<Drup>
so it works
<Drup>
about electron, nothing built in, so you'll have to create a binding, but no reason to expect any issue
Bluddy has joined #ocaml
<Algebr`>
Drup: I heard of that too, saw some murmuring on the mailing list, any code examples? I don't see anything on opam
<Drup>
Not that I know of
lobo has quit [Quit: leaving]
<Drup>
I wouldn't really be surprised if it "just worked"™
Algebr`` has joined #ocaml
<palomer>
does ocaml have a generic print function?
<mrvn>
yes
<mrvn>
it takes a pretty printer
Algebr` has quit [Ping timeout: 252 seconds]
mac10688_ has joined #ocaml
<SomeDamnBody>
How would I write a short circuiting iteration over a list?
<SomeDamnBody>
with the list apis... I don't see how I could tell the iteration to quit
<mrvn>
recursve or folding with exceptions
lambdahands has joined #ocaml
<SomeDamnBody>
oh I see core_kernel's for_all now, my bad
<SomeDamnBody>
I asked prematurely
<Drup>
SomeDamnBody: you should really be able to write that yourself, it's a good exercise
<Drup>
(the secret to exit the recursion prematurely is ... not to recurse, simply)
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
xfighter1188 has quit []
palomer has quit [Quit: palomer]
<SomeDamnBody>
oh psh, dude, I don't want to reinvent the wheel. I was looking at fold_left and was like... I don't think I can exit out of this until the list is exhausted
nullcatxxx_ has joined #ocaml
<Drup>
not for fold, no
<SomeDamnBody>
Drup, I write good code. Just sometimes when I'm addressing something complicated I get to where I'm like... "does the air I breathe have oxygen in it? What year is it really?" -> I question shit really hard and just get intensely focused
<SomeDamnBody>
:)
palomer has joined #ocaml
orbifx1 has joined #ocaml
<Algebr``>
Drup: just checking if you addressed me a message about node js code examples for jsoo, lost connection for a second.
Korhonen has joined #ocaml
orbifx has quit [Quit: WeeChat 1.3]
Kakadu has quit [Remote host closed the connection]
orbifx1 has quit [Ping timeout: 250 seconds]
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<apache2>
what's the best way to store a stack (first-in-last-out) structure of variable-size strings?
<apache2>
an array?
marsam has quit [Remote host closed the connection]
<Drup>
Stack ? :)
<mrvn>
best for what? space, time, ease of use? I would go with list.
<Drup>
(yes, there is a module stack in the stdlib)
<mrvn>
arrays are fixed size so you have to know how bit to make them and carry an index around too.
<mrvn>
# let x = Stack.create ();;
<mrvn>
val x : '_a Stack.t = <abstr>
<apache2>
sorry I'm stupid, first-in-first-out, not a stack