<ninjaaron>
what is a "type constructor" in this context?
<ninjaaron>
This isn't like a constructor in a variant, right?
<zozozo>
ninjaaron: list is a type constructor because it takes a type (for instance int), to create a type (e.eg; int list)
<zozozo>
though in the case of the manual page you listed, a typeconstr-name is typically just a type variable
<zozozo>
or rather a locally abstract type (which can be used in more places than a simple type variable)
<ninjaaron>
Thanks zozozo. The sentence I'm looking at is the first one: The expression [...] introduces a type constructor named `typeconstr-name` which is considered abstract in the scope of the sub-expression, but then replaced by a fresh type variable.
<ninjaaron>
However, in the example code, it doesn't look like it's dealing with a type constructor in the sense of `list`.
<zozozo>
indeed I slightly mispoke at first
<zozozo>
what's introduced is what the section title says: a locally abstract type
<ninjaaron>
I guess I don't know what that means. I just use it in ignorance to make my GADTs work.
<zozozo>
(which actually coincides with the notion of a type constructor such as list but with 0 arguments (whereas list takes 1 argument))
<zozozo>
well, in practice it's mainly used when using GADTs (or recursive functions), to specify a polymorphic type that would not be inferred
<ninjaaron>
What I don't get is how adding the locally abstracted type makes it inferable. I'm quite new to the algebra of types.
<ninjaaron>
and I don't understand when I should use `type a.` as opposed to `(type a)`
<zozozo>
well, it doesn't magically makes things inferrable but usually, you use the locally abstract type introduced to specify the type of arguments (or the function's return value), which contrains the inference, and then once the body of the function has been typed, and the function need to be assigned a type, the locally abstract types are turned into type variables, which makes the function polymorphic
<zozozo>
in thos type variables
<ninjaaron>
Ah!
<ninjaaron>
So, it forces a type to be "generic" instead of allowing the function to infer a concrete type?
<zozozo>
indeed
<zozozo>
that's one of the use of it
<ninjaaron>
Thanks so much!
<ninjaaron>
That makes sense.
nicoo has quit [Ping timeout: 240 seconds]
cgenie[m] has quit [Ping timeout: 260 seconds]
cgenie[m] has joined #ocaml
nicoo has joined #ocaml
troydm has quit [Ping timeout: 256 seconds]
ninjaaron has quit [Quit: WeeChat 2.8]
nullcone has quit [Quit: Connection closed for inactivity]
troydm has joined #ocaml
kandu has quit [Ping timeout: 256 seconds]
kandu has joined #ocaml
JSharp has quit [Ping timeout: 244 seconds]
kandu is now known as Guest85141
vodkaInferno has quit [Ping timeout: 272 seconds]
vodkaInferno has joined #ocaml
sepp2k has quit [Ping timeout: 260 seconds]
JSharp has joined #ocaml
l1x has quit [Ping timeout: 244 seconds]
higherorder has quit [Ping timeout: 244 seconds]
sepp2k has joined #ocaml
higherorder has joined #ocaml
l1x has joined #ocaml
malc_ has quit [Remote host closed the connection]
olle_ has quit [Ping timeout: 256 seconds]
olle has quit [Ping timeout: 272 seconds]
waleee-cl has joined #ocaml
bartholin has quit [Read error: Connection reset by peer]
bartholin_ has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
olle has joined #ocaml
olle_ has joined #ocaml
osa1 has quit [Ping timeout: 246 seconds]
<Leonidas>
companion_cube: haha, the test from your PR actually showed a change in behaviour in my PR.
<companion_cube>
:o
<companion_cube>
what's the change like?
<Leonidas>
companion_cube: a bug, I was outputting \0000 instead of \u0000. So that's very neat!
brown121407 has quit [Remote host closed the connection]
dhil has joined #ocaml
brown121407 has joined #ocaml
bitmapper has joined #ocaml
nullcone has joined #ocaml
olle has quit [Ping timeout: 246 seconds]
olle_ has quit [Ping timeout: 272 seconds]
Haudegen has quit [Quit: Bin weg.]
waleee-cl has quit [Quit: Connection closed for inactivity]
waleee-cl has joined #ocaml
malc_ has joined #ocaml
jco has joined #ocaml
<jco>
Hi! using cohttp i retrieved the body of a post request: id=good&filename=gg&...
<jco>
are there methods to parse the request and extract the fields?
<jco>
i was thinking of matching the string with regexps
<jco>
ah there's a to_string_list function for that
Haudegen has joined #ocaml
Anarchos has joined #ocaml
ggole has quit [Quit: Leaving]
Jesin has quit [Quit: Leaving]
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
tane has joined #ocaml
Jesin has joined #ocaml
_whitelogger has joined #ocaml
narimiran has joined #ocaml
mbuf has quit [Quit: Leaving]
malc_ has quit [Ping timeout: 272 seconds]
Hrundi_V_Bakshi has joined #ocaml
jco has quit [Quit: WeeChat 2.7]
jbrown has quit [Ping timeout: 272 seconds]
narimiran has quit [Ping timeout: 240 seconds]
<ollehar>
how about making mutability a subclass of immutability, so you can cast the first to the other (but not the other way around)?
<ollehar>
subtype*
tane has quit [Quit: Leaving]
brown121407 has quit [Ping timeout: 240 seconds]
<ziman>
hell, my program calls a C readLine function for each line in a file, puts the lines in a list, and when it tries to concate all those lines, it hits binary garbage. GDB says that the corrupted address was written to by GC so I suspect that the strings I read are not registered with GC properly somehow. However, my C function uses CAMLlocals1(ret_str) and CAMLreturn and everything. Are there other
<ziman>
common gotchas that could cause similar behaviour?
<ziman>
Apologies for the vagueness of the question; the code is generated via Malfunction so it's not easy to paste a MFE.
<ziman>
so i thought i'd ask anyway in case there's something that people hit frequently
<ziman>
s/hell/hello/ :D
<ziman>
the readLine function uses caml_copy_string()
<ziman>
oh, hang on, i found something
<ziman>
i'm probably mixing up (char *) and value somewhere
<ollehar>
heh, Hoar saying that references are as bad as goto
<ollehar>
1973
porchetta has quit [Ping timeout: 272 seconds]
porchetta has joined #ocaml
Hrundi_V_Bakshi has quit [Ping timeout: 240 seconds]
<ollehar>
"eferences are likejumps, leading wildly from one part of a data structure to another. Their introductioninto high level languages has been a step backward from whichwe may never recover"