psacrifice has quit [Remote host closed the connection]
freusque has joined #ocaml
psacrifice has joined #ocaml
maattdd has quit [Ping timeout: 256 seconds]
bernardo1pc has quit [Ping timeout: 268 seconds]
bernardofpc has joined #ocaml
ocalm has quit [Remote host closed the connection]
hydrocat has joined #ocaml
<hydrocat>
Hello, is here the right place to ask a few questions ?
<thizanne>
go for it hydrocat
<hydrocat>
How can I match a type that I wrote ?
<Drup>
what do you mean by "watch a type" ?
<Drup>
match
<hydrocat>
In Ocaml Learn they provide a type called "pair_of_ints" and I'm not shure how to match it's contents
<hydrocat>
sure*
<rgrinberg>
knowing the type name isn't enough to pattern match on it. You should incnlude it's definition
<rgrinberg>
Althugh in this case it's probably that it's just type pair_of_ints = int * int
<hydrocat>
you got it ;)
<rgrinberg>
s/probably/probable/
<rgrinberg>
let (x, y) = some_value_of_the_type
<rgrinberg>
Will pattern match
<hydrocat>
sorry, the actual type definition is type pair_of_ints = { a : int; b : int }
<def`>
(hydrocat: I think the confusion of Drup came from the fact that in OCaml we match values, not types; types are indeed used to classify values, but matching on a type could be understood as answering the question "is this type a 'pair_of_ints' or something else?", which is not possible in OCaml)
<def`>
hydrocat: you can do
<rgrinberg>
let {a ; b} = some_value_of_the_type should work
<hydrocat>
Oh, so I actually meant matching the values
<def`>
too late...
<def`>
as rgrinberg said :) (or in a function: let sum_pair {a; b} = a + b)
psacrifice has quit [Ping timeout: 256 seconds]
<hydrocat>
but, inside a match statement, can I write something like |{1,3} -> 10 ?
<hydrocat>
or even |{_,50} -> 0
<rgrinberg>
Sure. But match statements aren't very useful for records or tuples
<rgrinberg>
match some_int_pair with { a ; b } -> a + b
<def`>
hydrocat: the syntax is actually { a = 1; b = 3 }
<hydrocat>
so how should I go for the wildcard ?
<def`>
{ a = 1 }, { a = 1; _ }, { a = 1; b = _ }, { a = 1; b }
<hydrocat>
Thank you !
mengu_ has joined #ocaml
<hydrocat>
that should do :)
<def`>
(1- only match a, 2- match a ignore the rest, 3- match a, willfully ignore b, 4- match a, bind b)
<def`>
depending on the robustness you want to give to your code (e.g, if I want to be warned when the record definition changes, for instance if it is important to not discard a field that has been added, 3 and 4 are better style)
<hydrocat>
because 3 and 4 more explicit ?
mengu has quit [Ping timeout: 264 seconds]
shinnya has joined #ocaml
<def`>
yes
<def`>
you can get a warning to tell you when a record is not matched explicitly
<hydrocat>
Understood ! My goal with this is to build a linked list for an assignment
<reynir>
hydrocat: you can also do a match where you use new names for the fields: let sum_pair { a = x; b = y } = x + y
<reynir>
um, "new names for the fields" is maybe a bit confusing, let me rephrase...
<reynir>
"You can bind the values to other names than the name of the field", maybe better
sh0t has joined #ocaml
mengu has joined #ocaml
<hydrocat>
Sweet ! Thank you Reynir !
<hydrocat>
But, I can't match with other names
<hydrocat>
I'll give an example
mengu_ has quit [Ping timeout: 268 seconds]
<hydrocat>
with this in mind type pair = { a:int; b:int}, can I match like match pair with { x = _; y = 10 } ?
<hydrocat>
.. can I match it like...
<reynir>
No, you have to use the actual field names on the left hand side. So, { a = _; b = _ }
<hydrocat>
Understood !
snowcrshd has joined #ocaml
al-damiri has joined #ocaml
marsam has joined #ocaml
jabroney has joined #ocaml
marsam has quit [Remote host closed the connection]
Mercuria1Alchemi has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 260 seconds]
ryanartecona has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
kakadu has joined #ocaml
kakadu has quit [Client Quit]
argent_smith has quit [Quit: Leaving.]
marsam has joined #ocaml
argent_smith has joined #ocaml
rpg has joined #ocaml
cbot has joined #ocaml
mengu has quit [Quit: Leaving...]
freusque has quit [Read error: Connection reset by peer]
freusque has joined #ocaml
freusque has quit [Quit: WeeChat 1.7]
jnavila has quit [Quit: It was time]
mfp has quit [Ping timeout: 240 seconds]
hydrocat has quit [Ping timeout: 260 seconds]
argent_smith has quit [Quit: Leaving.]
freusque has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
AlexDenisov has quit [Remote host closed the connection]
djellemah has quit [Read error: Connection reset by peer]
ryanartecona has joined #ocaml
marsam has left #ocaml ["Killed buffer"]
shinnya has quit [Ping timeout: 240 seconds]
d0nn1e has quit [Ping timeout: 246 seconds]
d0nn1e has joined #ocaml
marsam has joined #ocaml
marsam has quit [Remote host closed the connection]
marsam has joined #ocaml
octachron has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
argent_smith has joined #ocaml
rawra has quit [Quit: Connection closed for inactivity]
sh0t has quit [Ping timeout: 260 seconds]
joncfoo has joined #ocaml
AltGr has left #ocaml [#ocaml]
sh0t has joined #ocaml
mfp has joined #ocaml
ygrek has joined #ocaml
spew has joined #ocaml
malc_ has joined #ocaml
marsam has quit [Remote host closed the connection]
Network_Eng has joined #ocaml
<Network_Eng>
Hello. I was wondering if anyone could help me by explaining how to remove OCaml 4.04.0 when it is installed from source.
marsam has quit [Remote host closed the connection]
Anarchos has joined #ocaml
marsam has joined #ocaml
mengu has joined #ocaml
TheLemonMan has joined #ocaml
Mercuria1Alchemi has quit [Ping timeout: 260 seconds]
Muzer has quit [Ping timeout: 256 seconds]
orbifx has joined #ocaml
mychris has joined #ocaml
freechips has quit [Ping timeout: 256 seconds]
argent_smith has quit [Quit: Leaving.]
freechips has joined #ocaml
Muzer has joined #ocaml
argent_smith has joined #ocaml
argent_smith has quit [Client Quit]
MercurialAlchemi has joined #ocaml
manizzle has quit [Ping timeout: 258 seconds]
manizzle has joined #ocaml
snowcrshd has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
malc_ has quit [Ping timeout: 264 seconds]
<orbifx>
i got a Fatal: out of memory exception with some C interface code
<orbifx>
what could be the culripit here? CAMLparams are automatically deallocated, right?
<orbifx>
anything else other than caml_alloc_*?
pilne has joined #ocaml
mychris has quit [Quit: WeeChat 1.7]
_andre has quit [Quit: leaving]
trapz has joined #ocaml
trapz has quit [Quit: trapz]
troydm has quit [Ping timeout: 260 seconds]
hydrocat has joined #ocaml
wtetzner has joined #ocaml
<kakadu>
TT
<kakadu>
Only thing that I can say is that spacetime doesn't take care about what is happening in C code.
ollehar has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
octachron has quit [Quit: Leaving]
hydrocat has quit [Ping timeout: 260 seconds]
<orbifx>
thanks kakadu
kakadu has quit [Remote host closed the connection]
<gjaldon__>
what's your favorite operating systems book?
larhat has quit [Quit: Leaving.]
jabroney has quit [Quit: Leaving.]
ollehar has quit [Quit: ollehar]
Simn has quit [Quit: Leaving]
ygrek has quit [Ping timeout: 260 seconds]
argent_smith has joined #ocaml
argent_smith has quit [Quit: Leaving.]
marsam has quit [Remote host closed the connection]
lapinot has joined #ocaml
<lapinot>
hi, i'm currently using menhir in a project builded using oasis+ocamlbuild and I would like to specify some menhir flags for specific files, i think this is doable using ocamlbuild tags but I can only find infos about how to tag files and not how to use these tags to modify their building.. any advice?
<lapinot>
to be a bit more specific, I would like to pass `--only-tokens` on `tokens.mly` and `--external-tokens Tokens` on `parser.mly`
cdidd has quit [Ping timeout: 268 seconds]
<Drup>
you'll have to write a bit of code inside myocamlbuild.ml to do that
<Drup>
(to declare the new options)
<Drup>
there are no builtin tags that does it directly
orbifx has quit [Ping timeout: 264 seconds]
<lapinot>
indeed, I will have do write something in myocamlbuild.ml, i'll rephrase my question to be a bit more clear :) how do i specify "every file tagged with <tag> should be built with <cmd>"
sh0t has quit [Remote host closed the connection]
<lapinot>
this seems like basic behavior to me (something that make does) but I can't see any doc about it
<Drup>
that's not how ocamlbuild works, though
<Drup>
and you shouldn't need it to add your two options
sillyotter has joined #ocaml
<lapinot>
mmh, i don't follow you! How can I then specify some build instruction for specific files to ocamlbuild then?
<Drup>
flags can add new options to the command line quite easily
<Drup>
let () = flag ["menhir"; "only-tokens"] (A "--only-tokens")
<Drup>
that will make it so that all files flag with "menhir" and "only-tokens" will have the extra option
sillyotter has quit [Client Quit]
<lapinot>
oh cool, that's exactely what i'm after
<Drup>
you should consult the manual for the precise details
<Drup>
(also, complain on the bugtracker about the absence of these flags)
<lapinot>
hm i'm not sure how ocamlbuild (or menhir) could infer that these files need specific flags without me saying so (regarding the bugtracker)
<Drup>
you would still specify it, you just shouldn't have to implement the flags yourself in your myocamlbuild
<Drup>
they should already be built in
cdidd has joined #ocaml
<lapinot>
i see, that would indeed be practical
mengu has quit [Ping timeout: 260 seconds]
wtetzner has quit [Remote host closed the connection]
<lapinot>
although i'm not sure how `--external-tokens <Mod>` could be implemented with tags as this flag takes an argument that is going to change between projects (and tags can't carry a value)
<lapinot>
s/with tags/generically/
<Drup>
you can have parametrized flags, the function is called pflag
al-damiri has quit [Quit: Connection closed for inactivity]