<flux>
but I think there was another one but I cannot remember its name..
<oriba>
flux, the problem with hidden information is what I mean: it needs many clicks, and maybe with the wrong click, things will not be found... maybe mli-file is really better, hmhhh
lgm has joined #ocaml
<lgm>
Hello, Good Folks!
zpe has joined #ocaml
<oriba>
flux, "There is no app configured at that hostname" hmhh
<samebchase>
adrien: does `tracepath6 google.com` not working mean anything?
<lgm>
What's the standard way to refer to the type of the module generated by calling Hashtbl.Make( SomeModuleDefiningAKey )
<flux>
I think the search is not very useful with Netclient
rgrinberg has joined #ocaml
<oriba>
flux, aha, that link works. thx
slash^1 has quit [Read error: Connection reset by peer]
<ggole>
lgm: module type of <module-expr>
andie has joined #ocaml
rand000 has quit [Ping timeout: 272 seconds]
rand000 has joined #ocaml
eugene_klm has joined #ocaml
<Drup>
lgm: Hashtble.S
andie has quit [Client Quit]
<Drup>
you need a "with type ..." annotation too
q66[lap] has quit [Ping timeout: 250 seconds]
<lgm>
ggole: i don't think i understood your suggestion. Here's a pastebin indicating my attempt to use your suggestion: http://pastebin.com/RtuZMyFK
q66 has joined #ocaml
lordkryss has joined #ocaml
<Drup>
lgm: it's not a good suggestion anyway, module type of ... is sort of a last resort. In this case, the output signature of the functor is exported as type S
q66[lap] has joined #ocaml
<lgm>
Drup: i don't think i've understood your suggestion. Here's a pastebin indicating my attempt to use your suggestion: http://pastebin.com/48QfYuQs
<Drup>
lgm: but in your attempt, the problem is simply that you should put "module type FOO = ..." before
hhugo has quit [Quit: Leaving.]
<Drup>
What are you trying to achieve with that ?
<lgm>
Drup: # module type StrTblType = Hashtbl.Make( StrKey );;
<lgm>
Characters 47-49:
<lgm>
Error: Syntax error
<lgm>
module type StrTblType = Hashtbl.Make( StrKey );;
<lgm>
^^
<lgm>
#
<Drup>
No ...
<Drup>
module type Foo = module type of Hashtbl.Make( StrKey );;
rand000 has quit [Ping timeout: 272 seconds]
rand000 has joined #ocaml
avsm has joined #ocaml
<Drup>
You can't put a signature as top level item, it can only be a signature *declaration*
<lgm>
Drup: thanks! that incantation is just what i needed.
<Drup>
and about the S signature, I told you it was *Hashtbl.S*, not just (a randomly generated module).S
<ggole>
Hashtbl.S only exists as a workaround that predates 'module type of', doesn't it?
<companion_cube>
not really
<Drup>
ggole: no, it's the only way around
<Drup>
module type of exists as a workaround for people that don't export the output signature
<ggole>
Hmm :/
<companion_cube>
module type of Hashtbl and module type of Hashtbl.Make(Foo) aren't related at all
<companion_cube>
because the type has respectively one and two type args
<ggole>
Well no, you'd use module type of Hashtbl (Something)
<Drup>
companion_cube: read again, that's not what he was saying
avsm has quit [Client Quit]
<ggole>
Er, Hashtbl.Make (Something)
<companion_cube>
ok
<companion_cube>
that's more accurate than Hashtbl.S now
<ggole>
More accurate?
<Drup>
you need a "with type ..."
<ggole>
Oh, it has the concrete type. Yes.
siddharthv is now known as siddharthv_away
Kakadu has joined #ocaml
Kakadu_ has joined #ocaml
tnguyen has quit [Quit: tnguyen]
sinelaw has joined #ocaml
<sinelaw>
does ocaml have something equivalent to haskell's ST monad?
<sinelaw>
does ocaml need rank-2 types to implement the same feature?
<Denommus>
sinelaw: the module system may be used to implement rank-2 types
<Drup>
but it's not because you can that you should :3
<sinelaw>
but do you need rank 2 types to achieve the same functionality?
<sinelaw>
e.g. a pair of getter/setter operating on a hidden ref
Hannibal_Smith has quit [Read error: No route to host]
<Denommus>
Drup: how would you implement instead?
rgrinberg has joined #ocaml
<Denommus>
Drup: I'm honestly unaware of how OCaml solves this specific problem, and I thought we'd use modules and functors anywhere we'd use rank-2 types in Haskell
eugene_klm has left #ocaml ["Once you know what it is you want to be true, instinct is a very useful device for enabling you to know that it is"]
<Drup>
depends of the problem. Basically you use something adhoc
<sinelaw>
Drup, what do you do for the get/put example?
<Drup>
Just use a ref ?
<sinelaw>
the assumption is that you're not just using a ref instead
<sinelaw>
(e.g. if the get/put do more than just set a ref)
<Kakadu>
structure with mutable fields?
larhat has joined #ocaml
octachron has joined #ocaml
<Drup>
sinelaw: give me a sec, to refresh my memory about ST
eugene_klm has joined #ocaml
<sinelaw>
kakadu, example?
rand000 has quit [Ping timeout: 245 seconds]
shinnya has quit [Ping timeout: 260 seconds]
dsheets has quit [Ping timeout: 272 seconds]
rand000 has joined #ocaml
<Drup>
sinelaw: do you really need to be polymorphic over the content ?
<Drup>
or is it just the case of "I would do that in haskell, how do I do the exact same thing in OCaml ?"
rgrinberg has quit [Quit: Leaving.]
<sinelaw>
Drup, I'm trying to understand how type inference can work here without rank-2 types, and was hoping that ocaml does it
Kakadu_ has quit [Quit: Konversation terminated!]
thomasga has joined #ocaml
<Drup>
I'm affraid I don't even see the issue. Look at the library linked by tane for a functorized version. You will have applied operators for a specific monad (instead of using type classes and hkt) but that's all
<octachron>
Naive question looking at runST type, what about something like type 'a st = { runST : 's. 's -> 'a } ?
oriba has quit [Quit: oriba]
SethTIsue has quit [Read error: Connection reset by peer]
<sinelaw>
octachron, runST is supposed to take an ST action as its argument
<mrvn>
octachron: how would you ever use that? You won't know the right type.
<sinelaw>
type 's 'a st = { runST : 'a. ('s -> 's 'a st) -> 'a }
<sinelaw>
approximately.
<mrvn>
the 'a. makes no sense there
<sinelaw>
type 's 'a st = { runST : 'a. ('s. 's 'a st) -> 'a }
<Drup>
( octachron : the only inhabitant of your type are function that don't use their input)
<sinelaw>
sorry.
<mrvn>
type ('s, 'a) st = { runST : 's -> 's 'a st -> 'a
<mrvn>
}
<sinelaw>
honestly, i haven't grasped rank-2 types enough yet
<sinelaw>
what I'm trying to find out is if there's an alternative
<mrvn>
I have no idea what you are trying to do
<sinelaw>
mrvn, runST takes a single argument
<sinelaw>
not two
<mrvn>
sinelaw: that isn't the point
<sinelaw>
mrvn, it should take a single value of type: ('s. 's -> 'a )
<sinelaw>
argh.
<sinelaw>
i meant: ('s. 's 'a st)
<sinelaw>
anyway, my actual question is how to implement a pair of functions that operate on a hidden reference cell
<ggole>
Are you implementing Univ or something?
<Drup>
sinelaw: "let create r0 = let r = ref r0 in (fun x -> r := x , fun () -> !r)" ?
<Drup>
It's hidden :D
<Drup>
(I still don't understand what you want, though)
<thomasga>
(c'est cassé les exemples avec Graphics)
<Drup>
During my last discussion with vincent, he presented me a new thing is working on, and said "I maintain a cache on client side, but I have some issues with keeping consistency with the server" ... :]
<thomasga>
haha
<sinelaw>
Drup, you were missing some parens
<sinelaw>
let create r0 = let r = ref r0 in ((fun x -> r := x) , (fun () -> !r));;
<Drup>
sinelaw: indeed
<Drup>
thomasga: So, hum, we will need to work on that :p
<Drup>
yep, but versionned, hosted on ocsigen.org and with auto-recompilation using the dev version of tyxml, so that I can really make it grow with new features and all that
<thomasga>
about the consistency issue: could maybe work on that together, I'm looking on new Irmin users (I working on making it more easily usable)
<Drup>
as always, :time: is the issue :p
<Drup>
thomasga: we clearly need an easy to use eliomized irmin
<Drup>
like, you declare a cache in a shared section, and it creates the server part, the client, and auto update between the two
Hannibal_Smith has joined #ocaml
<thomasga>
yea, would be nice
<thomasga>
really need to finish my core_kernel removal patches then ...
<Drup>
we have things like that already, sort of. Like Eliom_React.Up and Down, but it's not bi-directional
<companion_cube>
:>
zpe has quit [Remote host closed the connection]
jzelinskie has quit [Ping timeout: 260 seconds]
rfv has quit [Ping timeout: 260 seconds]
jeroud has quit [Ping timeout: 260 seconds]
<Drup>
thomasga: no online API ?
jeroud has joined #ocaml
rfv has joined #ocaml
jzelinskie has joined #ocaml
<thomasga>
Drup: give me 5min, I'll do it
igstan has joined #ocaml
ygrek has quit [Ping timeout: 260 seconds]
<Drup>
:D
<Drup>
maybe it's on the opam doc website, but I can't find the address again :x
<Drup>
replace "create" by "create ()" to make it a function (and be able to create multiple references) and you won't have the issue
<sinelaw>
ok
<Drup>
here, in your example, you create a reference to something of a defined type
<Drup>
The typechecker just don't know what yet, it will depends of what you are trying to do with it
<Drup>
but you obviously can't put things of different type in it, so it's not polymorphic
araujo has quit [Ping timeout: 272 seconds]
<sinelaw>
ok, that rule is what I was after.
<Drup>
sinelaw: you can see it too if you do "let ref_list = ref []"
<sinelaw>
hmm
<Drup>
(my first affirmation was wrong, it's not value restriction, just normal monomorphic type)
yomimono has joined #ocaml
<sinelaw>
Drup, note the underscored type variables in the first type of create
<sinelaw>
'_a
<Drup>
Yes, that's the typechecker way of telling you "I can't make this variable polymorphic, so it will be specialized"
<sinelaw>
ok
<sinelaw>
so what is "real" value restriction then?
<Drup>
let f = List.map2 (:=) ;;
<Drup>
compared to : "let f l1 l2 = List.map2 (:=) l1 l2"
<octachron>
or consider the function: let id s x = x which is polymorphic of type 'a->'b -> 'b
ollehar has quit [Ping timeout: 250 seconds]
<octachron>
then if you define let f = id () its type is '_a -> '_a
<Drup>
octachron's example is simpler than mine, yes :p
<octachron>
the idea is that the compiler cannot trust a function return to be truly polymorphic
<sinelaw>
because it may be hiding a reference?
<mrvn>
for the right value of it
<maurer>
What's the best way to represent a block of binary data in ocaml?
<maurer>
string?
<Drup>
bytes* :3
<mrvn>
or Bigarray
<madroach>
why not string?
<Drup>
ask gasche about the difference between string and bytes
<mrvn>
limited to below 16MiB on 32bit.
<ggole>
You have to do silly casts between char and int with String
<octachron>
sinelaw : yes, for instance : let false_id = let store =ref None in fun x -> match !store with None -> (store:= Some x; x) | Some y -> store:=Some x; y
<maurer>
Drup: I don't see a bytes type, other than a library called ocaml-bytes which appears to be literally just string
<maurer>
mrvn: And on 64-bit? I anticiapte needing more than 16MB
<ggole>
bytes is new in 4.02
<mrvn>
maurer: a billion times more or so
<madroach>
ggole: val Bytes.get : bytes -> int -> char
mawuli_ has joined #ocaml
<Drup>
maurer: please read the 4.02 changelog
<maurer>
Drup: Oh, uh, awkward. I don't think any of our target environments have 4.02 yet :(
<maurer>
What did people use before 4.02?
<Drup>
maurer: or look at xavier's slides
<ggole>
String
<ggole>
:(
<sinelaw>
octachron, nice
<maurer>
Oh :/
<sinelaw>
I'm beginning to appreciate Haskell's IO monad :)
<ggole>
Things may have progressed since then though.
SethTIsue has quit [Quit: SethTisue]
<dblhelix>
ggole: thanks
<ggole>
Did you want to compare OCaml versions or something?
IbnFirnas has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
<dblhelix>
that’s one use case, indeed
<dblhelix>
another is to add some instrumentation to for example the byte-code compiler and interpreter to keep track of how often some construct is used
axiles has quit [Remote host closed the connection]
<Denommus>
what's the idiomatic way of handling a single match case with multiple guards?
dblhelix has quit [Quit: Bye!]
<companion_cube>
match foo with | a when b && c -> ... ?
<ggole>
Multiple as in match ... with X when foo -> ... | X when bar -> ..., or as in match ... with X when foo && bar && baz?
elfring has quit [Quit: Konversation terminated!]
marchdown has joined #ocaml
avsm has quit [Quit: Leaving.]
olauzon has quit [Quit: olauzon]
<Denommus>
ggole: sorry, my connection went down
<Denommus>
ggole: the former
<ggole>
I would typically rewrite that as an if nested inside the clause
<Drup>
It's not really the same
<ggole>
Sure: if you need the difference, then leave the guards in
<Denommus>
Drup: why?
thomasga has quit [Quit: Leaving.]
thomasga has joined #ocaml
<Denommus>
Drup: I personally dislike writing the same case multiple times because of maintainability
<ggole>
You might have different bindings: Foo (x, _) when a -> ... | Foo (_, y) -> when b -> ...
Hannibal_Smith has quit [Quit: Sto andando via]
<Drup>
what ggole said.
marchdown has quit [Quit: marchdown]
<Drup>
you may want to fall back to a case where the bindings are different, and in this case, an embeded if won't do
<Denommus>
in my case, the bindings are identical. Everything is identical except the guards
tane has quit [Quit: Verlassend]
<Drup>
then why are you using a match to begin with, if you only need boolean tests , :D
<Drup>
just do an if then else if else if else
<Denommus>
Drup: there's two match cases. The second has multiple guards
<ggole>
Seems reasonable to rewrite that as an if inside the clause then.
<Denommus>
just did it, it looks nice
<Drup>
I would say it's a matter of taste and will depends on the side of the pattern, the number of branches and the thing I hate in my breakfast
<Drup>
size*
<Drup>
:]
<Drup>
ate* too ~~
<Denommus>
I often use match by default
igstan has quit [Quit: igstan]
<Denommus>
unless it's a really, really simple boolean check
<ggole>
I just go by gut feeling and then make up justifications after the fact.
* ggole
coughs
<ggole>
It's nice to tend to do things the same way though, even if the differences aren't important
<nicoo>
Drup: What do you hate in your breakfast ? :>
WraithM has quit [Quit: Lost terminal]
thomasga has quit [Quit: Leaving.]
octachron has quit [Quit: Leaving]
badkins has quit [Remote host closed the connection]
cesar has joined #ocaml
cesar is now known as Guest63457
FatDarrel has quit [Quit: FatDarrel]
marchdown has joined #ocaml
Guest63457 has quit [Ping timeout: 246 seconds]
Unhammer has quit [Remote host closed the connection]