malina has quit [Remote host closed the connection]
ShalokShalom has joined #ocaml
<ShalokShalom>
hi there :)
dedgrant_ has quit [Read error: Connection reset by peer]
<ShalokShalom>
what was the pipe looking in ocaml before its redesign?
kakadu has joined #ocaml
<ShalokShalom>
hi kakadu
<kakadu>
hi
<ShalokShalom>
do you remember how the pipe looked like in ocaml originally?
<kakadu>
let (|>) x f = f x ?
<M-ErkkiSeppl>
what do you mean by 'redesign'? from caml light to caml?
<M-ErkkiSeppl>
+o
<ShalokShalom>
ocaml invited it
MercurialAlchemi has quit [Quit: Lost terminal]
<ShalokShalom>
then, it changed to the pipe character used in fsharp, which is todays |>
<ShalokShalom>
Yaron mentions it in one of his talks
<kakadu>
I remember something with % but I don't remember for sure
<ShalokShalom>
I think something like $> or so?
zpe has quit [Remote host closed the connection]
<ShalokShalom>
yeah, something like this
<ShalokShalom>
thy anyway
<M-ErkkiSeppl>
well it wasn't really part of ocaml before |>, individual programs and libraries implemented it themselves
<ShalokShalom>
might be
<ShalokShalom>
sure?
<M-ErkkiSeppl>
yes
<ShalokShalom>
thy
kark has quit [Ping timeout: 265 seconds]
malina has joined #ocaml
Kalpatitoo has joined #ocaml
<Kalpatitoo>
with first class modules, I can make a function that takes a value and a module, and outputs a module, then use the output as a top-level module
<Kalpatitoo>
is it possible to achieve a similar result with functors
<Kalpatitoo>
?
<Kalpatitoo>
(functors that depend on values)
Haudegen has quit [Remote host closed the connection]
<Drup>
Kalpatitoo: module Make (M : sig val v : thetype end) (...) = struct .. end
<Drup>
simply take a module with only a value inside. :)
<Kalpatitoo>
syntactically heavy though
<Drup>
yes
<Kalpatitoo>
are top-level modules optimized away? I don't know much about optimizations, but I imagine functors are better than first-class-modules there
<Kalpatitoo>
(at my level, i don't think i care, but it'd be nice to know if there is a cost, for what are two equivalent operations)
<Drup>
Kalpatitoo: as far as optimization goes, functors are just like functions, but with more biais towards inlining
<Drup>
functions inside statically known modules tend to not have any indirections.
<Kalpatitoo>
oh.
FareTower has joined #ocaml
<Drup>
(like, the symbol for Foo.bar is accessed directly, instead of search for the n-th fields of Foo)
<Drup>
s/search/access/
<Kalpatitoo>
how is "statically known" decided? I guess the result of a statically known module going through a pure-total function isn't statically known, even for basic functions?
<Drup>
except if that function is inlined
<Drup>
if you have a pure total function annotated with [@inline], then it should be fine. You can easily look at the output of -dlambda to check
<Drup>
(everything I'm talking about is with flambda, btw)
<Kalpatitoo>
oh.
xaimus has quit [Ping timeout: 256 seconds]
xaimus has joined #ocaml
zolk3ri has quit [Ping timeout: 264 seconds]
xaimus has quit [Ping timeout: 256 seconds]
pierpa has quit [Read error: Connection reset by peer]
<companion_cube>
it means the same function might be called on many kinds of values
<companion_cube>
(so, you can't specialise)
<kakadu>
Polymorphic recursion sounds like very rarely used feature, but okay
<GreyFaceNoSpace>
hello... i have a question. are there any rules of equivalence for applying the result of Lits.map to the same function used in the map : example: f (map f l) where f is a function and l is a list)
<GreyFaceNoSpace>
?
<GreyFaceNoSpace>
can this be rewritten in another way?
<kakadu>
Which type do you expect f to have?
<companion_cube>
kakadu: well have you heard of GADTs? ^^
<kakadu>
companion_cube: yes?
<GreyFaceNoSpace>
kakadu, nvm....i was trying to solve a problem and complicated things more than they actually were.
jao has joined #ocaml
<kakadu>
companion_cube: do you want to say that it is useful not only when non-regular types apppear?
<companion_cube>
kakadu: any actual usage of GADTs is going to involve polymorphic recursion
<mrvn>
# let id x = x;;
<mrvn>
val x : int list = [1; 2; 3]
<mrvn>
# let x = id (List.map id [1;2;3]);;
<mrvn>
val id : 'a -> 'a = <fun>
GreyFaceNoSpace has quit [Quit: Ex-Chat]
<mrvn>
One can do it.
<kakadu>
'a list -> 'a seems to be more general case
* kakadu
by some weird reason was expected `as 'a` annotations somewhere... but nvm
zpe has joined #ocaml
dedgrant has joined #ocaml
catern has quit [Quit: catern]
zpe has quit [Ping timeout: 260 seconds]
Kalpatitoo has joined #ocaml
zpe has joined #ocaml
mengu has quit [Remote host closed the connection]
<Drup>
dom96: don't use the system switch. Create a new switch by doing "opam switch 4.06.1"
<zolk3ri>
↑
<Drup>
(it'll compile the last version of the compiler)
<dom96>
it's complaining that's not a valid compiler
<Drup>
Do "opam update" to get the latest package list
<zolk3ri>
Drup: Wouldn't you recommend also using opam 2.0.0-rc instead of 1.2.2?
<Drup>
zolk3ri: doesn't matter for this
<zolk3ri>
Not for this particular issue, just in general.
<Drup>
ah, yeah, sure
<dom96>
[ERROR] frama-c-base is not available because your system doesn't comply with ocaml-version >= "4.02.3" & ocaml-version < "4.06".
<dom96>
D:
<Drup>
oups, sorry
<dom96>
I guess I can do: opam switch 4.02.3?
<Drup>
well, "opam switch 4.05.0" then :)
<Drup>
or older, yes
FreeBirdLjj has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 264 seconds]
zpe has joined #ocaml
jnavila has joined #ocaml
spew has joined #ocaml
gareppa has quit [Quit: Leaving]
<dom96>
Awesome, that worked. Thanks!
muelleme has joined #ocaml
pierpa has joined #ocaml
pierpa has quit [Read error: Connection reset by peer]
pierpa has joined #ocaml
tarptaeya has quit [Ping timeout: 240 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
muelleme has quit [Ping timeout: 264 seconds]
opios has quit [Ping timeout: 264 seconds]
zpe has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
Haudegen has joined #ocaml
huglovefan has quit [Quit: huglovefan]
<bartholin>
I have a question: what is the complexity cost of dynamic function generation, and how is it actually implemented (in the compiled binary)? For instance let update f x fx = fun y -> if y = x then fx else f y generates a new function everytime it is called.
jbrown has quit [Ping timeout: 240 seconds]
<companion_cube>
it's constant time
<companion_cube>
well, ocaml doesn't really create a new function
<companion_cube>
instead it has something like `let real_update f x fx y = if y=x then … else …`
<companion_cube>
then it's just partial application
<companion_cube>
(@ bartholin)
<bartholin>
but if I do something like let f = update (update (update (fun x -> 0) 1 2) 2 3) 3 4, it simply creates a closure?
spew has quit [Ping timeout: 256 seconds]
pierpa has quit [Read error: Connection reset by peer]
<companion_cube>
each `update` will probably make a closure
<companion_cube>
same for `fun x -> 0`, it becomes `let fun_357 x = 0` and then `fun_357` is given as parameter to update
pierpal has joined #ocaml
pierpal has quit [Client Quit]
FreeBirdLjj has quit [Ping timeout: 264 seconds]
pierpal has joined #ocaml
pierpal has quit [Client Quit]
pierpal has joined #ocaml
pierpal has quit [Quit: Poof]
jnavila has quit [Ping timeout: 240 seconds]
pierpal has joined #ocaml
<Kalpatitoo>
is there a way to have some kind of "module-type-of ModuleName", where this would be the inferred type of a static module?
pierpal has quit [Read error: Connection reset by peer]
<Kalpatitoo>
(basically, i'm doing mutually recursive modules, and i'm in the prototype phase, so the definitions change a lot, and I can't copy-paste them everytime)
pierpa has joined #ocaml
pierpa has quit [Client Quit]
pierpa has joined #ocaml
pierpa has quit [Client Quit]
kakadu has quit [Quit: Konversation terminated!]
pierpa has joined #ocaml
<smondet[m]>
Kalpatitoo: there is such a thing: `module L : module type of List = List;;` but it maybe tricky to use with recursive modules
<Kalpatitoo>
yep, i actually want the type of the resulting module, not the functor
<Kalpatitoo>
and, it actually only works in merlin, hahaha :'(
jbrown has joined #ocaml
<Kalpatitoo>
I don't understand why when I use the "include", it doesn't work, but that when I copy all the types by hand, it does
<octachron>
Kalpatitoo, your code example somehow works for me, but you should note that include also copies values
<octachron>
and you should really copy by hand rather than rely on the behavior of recursive modules that include themselves
<Kalpatitoo>
copy-pasting is quite a flow breaker. -is there a an include that only copies type? -is there a ppx or something dealing with this? -"you should really copy by hand": do you have a pointer / an explanation ? i don't see it
jnavila has joined #ocaml
dom96 has left #ocaml ["Leaving"]
mengu has quit [Remote host closed the connection]
zpe has joined #ocaml
kakadu has joined #ocaml
tane has joined #ocaml
gtrak has quit [Ping timeout: 265 seconds]
gtrak has joined #ocaml
<octachron>
Kalpatitoo, do you need recursive modules in your prototype phase? Recursive modules are a complex features with a lot of gotchas; it is probably best to avoid them in the prototype phase or at least restrain the recursive part as much as possible
<octachron>
There are no includes that includes only types, but you can isolate types from your values (and recursive modules require that there is at least one safe module in any dependency cycles)
<Kalpatitoo>
octachron, i'm making two interdependent calculus, so recursive modules are fundamentals
<Kalpatitoo>
i tried isolating types from values earlier, it didn't work. do you know of a functional example somewhere?
FreeBirdLjj has quit [Ping timeout: 276 seconds]
pierpa_ has joined #ocaml
<octachron>
The idea is simply to have n type/core recursive modules followed by the rest of the recursive modules `module rec TypeA: sig ... end = TypeA and TypeB: sig ... end = TypeB and ...`
<Kalpatitoo>
Ooooh.
<Kalpatitoo>
thanks!!
mk9 has joined #ocaml
pierpa has quit [Ping timeout: 264 seconds]
FreeBirdLjj has joined #ocaml
zpe has quit [Remote host closed the connection]
Anarchos has joined #ocaml
spew has joined #ocaml
pierpa_ is now known as pierpa
pierpal has joined #ocaml
gtrak has quit [Ping timeout: 240 seconds]
gtrak has joined #ocaml
spew has quit [Read error: Connection reset by peer]
Anarchos has quit [Quit: Vision[0.10.2]: i've been blurred!]
mk9 has quit [Quit: mk9]
mk9 has joined #ocaml
lfish has joined #ocaml
spew has joined #ocaml
mk9 has quit [Quit: mk9]
FreeBirdLjj has quit [Ping timeout: 264 seconds]
zolk3ri has quit [Remote host closed the connection]
<tsani>
I'm using extlib in a project, but something odd is happening: I can access functions from its Std module with no problem, but I can't seem to use the UTF8 module. Any idea what's going on?
argent_smith has quit [Quit: Leaving.]
mk9 has joined #ocaml
<tsani>
(My actual goal to simply to count the number of code points in a UTF-8 encoded string; if there's an easier way to this, then I'm all ears. My solution was to use UTF8.length)
jnavila has quit [Remote host closed the connection]
<tsani>
Ah, another method, since my project is also using ulex: I can construct a Ulexing.lexbuf from a utf8 string and then get the length of that buffer.
spew has quit [Read error: Connection reset by peer]
cmichelRYFFW4 has joined #ocaml
<FareTower>
# Int64.abs Int64.min_int;;
<FareTower>
- : int64 = -9223372036854775808L
cmichelRYFFW4 has quit [Remote host closed the connection]
<pierpa>
as a minimum, the documentation of Int64.abs is incomplete.
<octachron>
pierpa, maybe. But the documentation does say that Int64 implements ℤ/2^64ℤ and not ℤ
<pierpa>
still, the doc is inexact, to be generous.
<octachron>
it is too succinct, but to be inexact would require an exact specification of abs on ℤ/nℤ
_andre has quit [Quit: leaving]
isd has joined #ocaml
malina has joined #ocaml
<pierpa>
since there's no common mathematically accepted definition for this function in Z/n, AFAIK, the manual should say what ocaml does in this case, instead of relying on external knowledge one must have about machine arithmetic. Just MHO.
<bartholin>
it's two's complement
<pierpa>
we know
al-damiri has quit [Quit: Connection closed for inactivity]
Kalpatitoo has quit [Ping timeout: 264 seconds]
<FareTower>
I think that's a reasonable implementation choice. I also think it needs to be better documented.
jbrown has quit [Ping timeout: 265 seconds]
<pierpa>
yes
<FareTower>
other reasonable option, but more annoying: raise an exception.
tane has quit [Quit: Leaving]
<pierpa>
perhaps better would be to keep the function as it is, with better documentation, and add a safe_abs which raises the exception
<pierpa>
then if one gets burned, it's completely their fault :)
Haudegen has quit [Remote host closed the connection]
<octachron>
It seems quite hard to be burned by this specific problem without meeting other overflow errors on the way
<octachron>
pierpa, I agree updating the documentation would be nice
<FareTower>
octachron, in some adversarial situations, the one who writes the safety and the one who tries to break it are not the same
zpe has joined #ocaml
<FareTower>
(I'm reminded of a recent Ethereum contract overflow bug)
jbrown has joined #ocaml
FareTower has quit [Ping timeout: 276 seconds]
letoh has quit [Ping timeout: 260 seconds]
FreeBirdLjj has joined #ocaml
sh0t has quit [Remote host closed the connection]
lfish has quit [Ping timeout: 260 seconds]
FareTower has joined #ocaml
cbot has joined #ocaml
Kalpatitoo has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 265 seconds]
kakadu has quit [Remote host closed the connection]
jbrown has quit [Ping timeout: 260 seconds]
jimmyrcom_ has joined #ocaml
pierpal has quit [Ping timeout: 240 seconds]
cbot has quit [Quit: Leaving]
Kalpatitoo has quit [Read error: Connection reset by peer]