tobiasBora__ has quit [Quit: Konversation terminated!]
FreeArtMan has quit [Ping timeout: 264 seconds]
philtor has quit [Ping timeout: 240 seconds]
jwatzman|work has quit [Quit: jwatzman|work]
dsturnbull has joined #ocaml
mcclurmc has joined #ocaml
racycle has quit [Quit: ZZZzzz…]
mcclurmc has quit [Ping timeout: 250 seconds]
malo has quit [Remote host closed the connection]
philtor_ has joined #ocaml
philtor_ has quit [Ping timeout: 240 seconds]
philtor_ has joined #ocaml
Algebr` has joined #ocaml
dotfelix has joined #ocaml
dotfelix has quit [Read error: Connection reset by peer]
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 240 seconds]
<Algebr`>
so if we do type foo = {bar:string}, this {} doesn't have a name, but the type system will still know that items of {bar:string} are of type foo?
<Drup>
what do you mean by "this {} doesn't have a name" ?
<Algebr`>
there isn't a handle on it
<Algebr`>
how can I refer to it?
<Drup>
"{}" doesn't exist, and it existed, it would be exactly equivalent to ()
<Drup>
if it*
<Drup>
so, not sure what you want here
alpounet has quit [Remote host closed the connection]
<Drup>
Algebr`: do you mean "this record", by chance ? =')
<Algebr`>
Drup: type is strange to me. I could do type foo = Bar | Car, or I can do type foo = {first:string;second:int}, but given the latter I can't do type foo = {first:string} | {second:int}
<Drup>
imagine you had a foo element
<Drup>
(as you defined it just now)
<Drup>
let's take x of type foo, what would x.string do ?
<Drup>
x.first*
<Algebr`>
it would give back the string that first was initialized with
<Drup>
but what if it's on the right side of "{first:string} | {second:int}" ?
<Algebr`>
you mean like {first:string} | {first:int}?
<Drup>
"|" is a disjunction, either a foo is of the left kind or the right kind
<Algebr`>
but the accessors are all unique
<Drup>
and ?
<Drup>
the issue is not the uniquness
<Drup>
the issue is that having something like "{first:string} | {second:int}" is unsafe
<Algebr`>
y
<Algebr`>
I'm not seeing how that's unsafe.
<Drup>
because you can do "let x = {second = 3} in x.first"
<Drup>
it is, according to type system, correct
<Drup>
but it will obviously fail at runtime, there is no field "first" in x
<Algebr`>
oh shit, yes I see now
<Drup>
note that haskell people did this mistake, and are still biting their fingers at it.
q66 has quit [Quit: Leaving]
<Drup>
if you want a record inside a sum type, you can do it like that :
<Drup>
type foo = { foo : string }
<Algebr`>
ah, I just thought of what I was trying to say earlier. in haskell, I also have record types, i.e. data Person = Male {name::String}, but in ocaml, I just have type person = {name:string}, so I don't need a constructor to refer to the {name:string}? the type system just sees that this record is of this type?
<Drup>
type bar = Bar of foo
<Drup>
yes
<Drup>
the compiler will try to disambiguate if there is an ambiguity in the field
<Algebr`>
but this wouldn't make sense, right? Bar of {foo:string}
<Drup>
no, it doesn't
<Drup>
for example, if you have "type person = {name : string ; age : int} and building = {name:string; heigh : int}"
<Drup>
{name = "Martin" ; age = 2 } is not ambiguous
<Drup>
but "let f x = x.name" is ambiguous
<Drup>
the compiler will infer the first one (but emit a warning that it disambiguated something) and yell at you on the second case
<Drup>
actually, in the straighforward case, it will not yell, it will just take the last defined
<Drup>
(you can make it yell on more involved examples)
dotfelix has joined #ocaml
dotfelix has quit [Read error: Connection reset by peer]
dotfelix has joined #ocaml
dotfelix has quit [Read error: Connection reset by peer]
nirvdrum has quit [Remote host closed the connection]
badon has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
tidren has joined #ocaml
Algebr` has quit [Ping timeout: 240 seconds]
tidren has quit [Remote host closed the connection]
tidren has joined #ocaml
mcclurmc has joined #ocaml
manizzle has quit [Ping timeout: 250 seconds]
mcclurmc has quit [Ping timeout: 264 seconds]
tidren has quit [Remote host closed the connection]
tidren has joined #ocaml
philtor_ has quit [Ping timeout: 240 seconds]
tidren has quit [Remote host closed the connection]
ygrek has joined #ocaml
<bernardofpc>
tobiasBor> And in something like Printf.sprintf "%5d" 5, is it possible to fill with 0 instead of spaces ? -> "%05d"
mcclurmc has joined #ocaml
johnnydiabetic has joined #ocaml
mcclurmc has quit [Ping timeout: 256 seconds]
fold has quit [Ping timeout: 250 seconds]
alpounet has joined #ocaml
alpounet has quit [Ping timeout: 245 seconds]
jao has quit [Ping timeout: 240 seconds]
tidren has joined #ocaml
shinnya has quit [Ping timeout: 255 seconds]
johnnydiabetic has quit [Quit: Goodbye]
tidren has quit [Remote host closed the connection]
axiles has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 245 seconds]
Simn has joined #ocaml
waneck_ has quit [Ping timeout: 264 seconds]
ebzzry has joined #ocaml
pgomes has joined #ocaml
michael_lee has joined #ocaml
tidren has joined #ocaml
alpounet has joined #ocaml
hhugo has joined #ocaml
alpounet has quit [Ping timeout: 255 seconds]
tidren has quit [Remote host closed the connection]
ollehar has joined #ocaml
slash^ has joined #ocaml
Hannibal_Smith has joined #ocaml
Kakadu has joined #ocaml
pjdelport has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 250 seconds]
slash^ has quit [Read error: Connection reset by peer]
parcs has quit [Ping timeout: 240 seconds]
parcs has joined #ocaml
rand000 has joined #ocaml
tidren has joined #ocaml
<whitequark>
Drup: ping
rand000 has quit [Quit: leaving]
tane has joined #ocaml
pgomes has quit [Quit: Leaving]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
tidren has quit [Remote host closed the connection]
mcclurmc has quit [Ping timeout: 255 seconds]
martintrojer has quit [Ping timeout: 240 seconds]
martintrojer has joined #ocaml
pgomes has joined #ocaml
def-lkb has joined #ocaml
def-lkb is now known as def`
zpe has joined #ocaml
pminten has joined #ocaml
pgomes has quit [Ping timeout: 245 seconds]
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 255 seconds]
CcxCZ has quit [Read error: No route to host]
zpe_ has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
zpe_ has quit [Remote host closed the connection]
helino has joined #ocaml
slash^ has joined #ocaml
<helino>
Hi, I'm learning OCaml and was wondering if there is a way to use a string as out_channel?
<Kakadu>
Printf.sprintf?
<helino>
so I can pass a string_channel (or something similar) to a function when testing, and then pass out_channel when in production
<def`>
helino: not with channels, but with Format you can
<helino>
def`: thanks! (reading the doc right now for Format)
<axiles>
helino: you can use the type Format.formatter
<orbitz>
I take it you'er trying to seamleslsy make I/O go to a user OR to a string, right helino ?
<def`>
(Format.formatter is a higher-level abstraction, it allows for instance to specify the layout of messages, but it is only suitable for text data)
<helino>
orbitz: yes, so I can pass something (a channel? formatter?) to a function that does not care about what kind of channel it is printing on
<orbitz>
helino: IMO, it's better to always work with strings, and then move the decision of what to do with that string up a level.
<helino>
btw, I'm fine with using things from Core as well (I'm reading the Real World Ocaml book and managed to get Core installed correctly)
<orbitz>
the cost semantics become much clearer there. Which may or may not be important to you
<helino>
orbitz: yeah, that is a good idea!
<helino>
the cost semantics are not that important right now, I'm just learning the language and the tools atm :)
<helino>
thanks everyone for your help, really appreciate it!
<helino>
btw, is there a way in utop to get the documentation for a function?
ygrek has quit [Ping timeout: 240 seconds]
Hannibal_Smith has quit [Quit: Sto andando via]
pgomes has joined #ocaml
<orbitz>
helino: i don't think so. I think Merlin can somehow. Genearlly the type is sufficient to know what a function does once you start to understandthe type system
<def`>
orbitz: no, sadly Merlin can't at that time. the situation with documentation annotations in ocaml is a bit messy right now
<helino>
ok, thanks
<Unhammer>
:/
<Unhammer>
do packages sometimes install some offline docs anywhere though?
slash^ has quit [Ping timeout: 255 seconds]
<Unhammer>
to answer myself: seems menhir puts a manual in ~/.opam/system/doc, but e.g. core installs no docs there
<Unhammer>
… which needs a rerun of bibtex …
slash^ has joined #ocaml
alpounet has joined #ocaml
shinnya has joined #ocaml
BitPuffin has quit [Ping timeout: 250 seconds]
zpe has joined #ocaml
ssbr has quit [Read error: Connection reset by peer]
zpe has quit [Ping timeout: 240 seconds]
hhugo has quit [Quit: Leaving.]
ygrek has joined #ocaml
helino has quit [Quit: leaving]
q66 has joined #ocaml
Eyyub has quit [Ping timeout: 260 seconds]
alpounet has quit [Remote host closed the connection]
alpounet has joined #ocaml
tobiasBora has joined #ocaml
alpounet_ has joined #ocaml
<tobiasBora>
I've two question about cmdliner : first is it possible to define a non optional positional argument ? In the doc I can read :
<tobiasBora>
*Hello
alpounet has quit [Read error: Connection reset by peer]
<whitequark>
Drup: I'm thinking on possible design options for deriving and don't really like either of them
<whitequark>
thought 1: do you think I should split [@@deriving] into separate annotations?
<whitequark>
there's certain elegance in being able to write [@@deriving Show, Eq { opt=true }, Compare], but I'm not sure if it's that important
<Drup>
No
<whitequark>
ok
<whitequark>
good, one less thing to bikeshed about. bikeshedding absolutely kills my productivity.
<Drup>
:D
<tobiasBora>
Cmdliner is really amazing...
hexo has joined #ocaml
<whitequark>
thought 2: maybe I could use something like a front pass by ppx_deriving that converts "type a [@@deriving X, Y]" into "type a;;[%%deriving.X type a];;[%%deriving.Y type a];;"
<Drup>
one consistent deriving mechanism across the whole ocaml ecosystem would really be a fantastic thing, let's not fragment it before even beginning :p
<whitequark>
which would make them independent and yet keep the property that they error out if not included
<whitequark>
well
<whitequark>
Drup: structuring the mechanism in a way that forces the plugin authors to present a consistent user interface was something I had in mind
<whitequark>
but I'm not sure how accepting the OCaml ecosystem is of such measures
<Drup>
yeah, I noticed
<whitequark>
seeing e.g. the absurd abundance of buildsystems
<Drup>
I think it's a good thing
<whitequark>
ok
<whitequark>
then I probably should proceed with my original design unchanged
<whitequark>
btw, regarding dynlinking, all the files required to make custom combined rewriters are already available
<whitequark>
you have the .cmx of ppx_deriving and .cmx of the plugins
<whitequark>
just need to link them together
<Drup>
regarding the idea to transform @@ into multiple %%
<Drup>
I'm not completly sure we want them to error-out if not included, actually
<whitequark>
oh?
<whitequark>
why?
<whitequark>
I find it extremely unhelpful, a message saying that a method show_a doesn't exist
<whitequark>
and there is no let show_a = ... anywhere
hexo is now known as shallow
<Drup>
You can put a warning
<whitequark>
hm, in principle
<Drup>
let's say I define a datatype Foo, and I would like to allow people to derive it in Json (because I know my use base like Json) but I don't want the hard dependency on YoJson
<tobiasBora>
I've something I can't manage to do with cmdliner, do you know if it's possible to deal with named argument ? (my function has many argument)
<Drup>
tobiasBora: in wich way ?
<Drup>
whitequark: I could say "ok, if ppx_deriving_yojson" is here, I derive, otherwise, I do not, and just ignore this deriving
<whitequark>
Drup: oh, so, conditional compilation
<Drup>
It's also consistent with the fact that unknown @@ are ignored
<whitequark>
I think it's a good thing to have
<whitequark>
the latter I don't really like
<whitequark>
it means that it is easier to misplace an annotation than not
<Drup>
misplace ?
<whitequark>
especially on records; both { foo [@bar] : int } and { foo : int [@bar] } are valid
darkf has quit [Quit: Leaving]
<whitequark>
(in deriving it usually makes sense to look for the latter, but not always)
<whitequark>
and if an accidentally omitted @bar doesn't immediately lead to an error... you're in a world of pain
<tobiasBora>
Drup: In this example : let chorus_t = Term.(pure chorus $ msg1 $ msg2);; the chorus function is supposed to be like this : "let chorus msg1 msg2 = ...". Can I do a similar thing with named arguments if chorus is defined like this : "let chorus ~msg1 ~msg2 = ..." and be like this independant of the order of the arguments ?
<Drup>
tobiasBora: a type is not the same with named arguments, so no
<Drup>
whitequark: by the latter, you mean "otherwise, I do not, and just ignore this deriving " ?
<mrvn>
can one write the $ so it takes a function as first aregument and a named argument as second and applies that?
<Drup>
no
<mrvn>
(~a:'a -> 'b) -> ~a:'a -> 'b
<whitequark>
Drup: well yes
<Drup>
mrvn: that works only for the named argument a
<whitequark>
1) the annotation may belong to other library (this mostly affects typos)
<whitequark>
2) it's just not practical to look at *every* node's annotations
<mrvn>
Drup: yeah. it needs a meta name
<tobiasBora>
Yes, but I can modify Term, it's not a problem, for example with something like Term.(pure chorus $ ("name_arg1", msg1) $ ("name_arg2", msg2)...) ). But I really don't know if it's possible (I think no)
<Drup>
tobiasBora: no, you can't
<tobiasBora>
Ok thank you.
<Drup>
whitequark: I'm not sure to see the issue
<whitequark>
Drup: say in Protobuf, I have a [@encoding] annotation
<whitequark>
which affects public API of the application and therefore is very important
<Drup>
oh, lightweight annotation, not in the "deriving" name scope
<whitequark>
a [@encdoing] annotation or [@encoding] annotation in wrong place will be silently ignored
<whitequark>
and the code will still likely build
<Drup>
huuum
<Drup>
isn't there a compiler warning about that anyway ?
<whitequark>
no.
<Drup>
eeehh
<whitequark>
there should be.
<whitequark>
brb mantis
<Drup>
yes there should, clearly
<Drup>
and I would argue it should be enabled by default
thomasga has quit [Ping timeout: 245 seconds]
q66 has quit [Quit: Leaving]
q66 has joined #ocaml
<Drup>
If we have a enable by default warning, I think it's almost a non-issue
<Drup>
hence yesterday's question about providing them
<whitequark>
right
<Drup>
whitequark: the only way I found to specialize them is : "let eq typ = [%expr let f (x : [%e typ]) (y : [%e typ]) = x = y in f ] in"
<Drup>
(that's mostly the only thing I did for the Eq deriving, I figured that out but didn't go further :p
slash^ has quit [Read error: Connection reset by peer]
<ggole>
Can't you use String.compare?
<ggole>
Same with Int{32,64}
<Drup>
seems like a unnecessary additional test.
<ggole>
Compared to what?
<Drup>
compare to equal
<ggole>
Seems like the same amount of work to me
<Drup>
the compiler do have a dedicated equality function for all each basic type, we should has well used it
<Drup>
-d
<ggole>
Can't disagree
<Drup>
meh, can't english this morning :(
<ggole>
Did you mean the extra test is Foo.compare == 0?
<Drup>
yes
<ggole>
You have to do that anyway to map from bool to condition code
<whitequark>
hmm, right
<whitequark>
so I think I'll use compare
zpe has joined #ocaml
<whitequark>
hm, for deriving Compare I need something like a short-circuiting fold
<ggole>
Hand-rolled recursive func?
<ggole>
...minus the hands, I guess
<Drup>
I fear you will have to write it your self :p
zpe has quit [Ping timeout: 264 seconds]
<whitequark>
maybe just a tree of match statements
hhugo has joined #ocaml
<ggole>
By the way, what do you do for function values? Die with an error message?
<Drup>
Do you have any other sensible proposition ?
<ggole>
Sensible, no. :)
<Drup>
:p
<whitequark>
you could say [@eq.compare (==)]
q66 has quit [Quit: Leaving]
<ggole>
Thorny subject, really
<Drup>
the eq.compare annotation might be nice anyway, to handle external abstract types
<whitequark>
yes. it will defer comparison of F.t to F.compare_t by default
gal_bolle has joined #ocaml
<Drup>
shame we can't test by introspection if compare_t or compare is available
<Drup>
(because in a good amount of library, the function is simply "compare")
<whitequark>
I think I'll simply make a heuristic
<whitequark>
if the type is called "t", the function will have no suffix
<whitequark>
otherwise, it's _typename
<Drup>
ahah :D
<whitequark>
as long as this convention is not *forced* on you, I think it's very helpful
<Drup>
same for the generated compare function ?
<ggole>
That does seem close to what people would actually do.
<Drup>
yep
_0xAX has joined #ocaml
<def`>
t -> compare, other -> compare_other is ± what Core's with compare does
thomasga has joined #ocaml
racycle has joined #ocaml
racycle has quit [Ping timeout: 240 seconds]
numeo is now known as Anon736
<ggole>
Hmm, strings do seem to be specialised (in 4.02)
Anon736 is now known as numeo
<ggole>
And Int32
gal_bolle has quit [Quit: Konversation terminated!]
q66 has joined #ocaml
q66 has quit [Remote host closed the connection]
q66 has joined #ocaml
<mrvn>
Anyone want to help me write an freeciv AI in ocaml from scratch?
pgomes has joined #ocaml
avsm has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 250 seconds]
michael_lee has quit [Ping timeout: 240 seconds]
racycle has joined #ocaml
michael_lee has joined #ocaml
racycle has quit [Ping timeout: 245 seconds]
_0xAX has quit [Remote host closed the connection]
fold has joined #ocaml
rand000 has quit [Quit: leaving]
hhugo has quit [Quit: Leaving.]
gal_bolle has joined #ocaml
tobiasBora has quit [Ping timeout: 240 seconds]
philtor_ has joined #ocaml
gal_bolle has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
tobiasBora has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
tobiasBora has quit [Read error: No route to host]
tobiasBora has joined #ocaml
NoNNaN has joined #ocaml
philtor_ has quit [Ping timeout: 240 seconds]
hhugo has joined #ocaml
tobiasBora has quit [Ping timeout: 240 seconds]
avsm has quit [Quit: Leaving.]
thomasga has quit [Ping timeout: 240 seconds]
shinnya has quit [Ping timeout: 240 seconds]
gal_bolle has joined #ocaml
zpe has joined #ocaml
demonimin has quit [Ping timeout: 240 seconds]
pminten has joined #ocaml
zpe has quit [Ping timeout: 256 seconds]
tobiasBora has joined #ocaml
Hannibal_Smith has joined #ocaml
testcocoon has quit [Quit: Coyote finally caught me]
shallow is now known as wao`
slash^ has joined #ocaml
testcocoon has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
thomasga has joined #ocaml
BitPuffin has quit [Ping timeout: 255 seconds]
tidren has joined #ocaml
tobiasBora has quit [Ping timeout: 240 seconds]
dapz has joined #ocaml
dapz has quit [Max SendQ exceeded]
q66 has quit [Remote host closed the connection]
q66 has joined #ocaml
pminten has quit [Remote host closed the connection]
Anarchos has joined #ocaml
alpounet has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
tidren has quit [Remote host closed the connection]
tidren has joined #ocaml
_0xAX has joined #ocaml
alpounet has joined #ocaml
<Drup>
ocp-build is annoying =__=
divyanshu has joined #ocaml
racycle has joined #ocaml
zapu has joined #ocaml
thomasga has quit [Read error: Connection reset by peer]
tani has joined #ocaml
thomasga has joined #ocaml
tane has quit [Ping timeout: 260 seconds]
<whitequark>
yes.
hhugo has quit [Quit: Leaving.]
dapz has joined #ocaml
thomasga has quit [Ping timeout: 250 seconds]
thomasga has joined #ocaml
thomasga1 has joined #ocaml
thomasga has quit [Read error: Connection reset by peer]
racycle has quit [Quit: ZZZzzz…]
pjdelport has quit [Quit: Connection closed for inactivity]
tani has quit [Quit: Verlassend]
<jpdeplaix>
Drup: nobody use it anyway :D
<Drup>
except I'm developing something in ocp-index :/
dapz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
dapz has joined #ocaml
Nahra has quit [Remote host closed the connection]
pgomes has quit [Ping timeout: 260 seconds]
tidren has quit [Remote host closed the connection]
zpe has joined #ocaml
hhugo has joined #ocaml
hhugo has quit [Client Quit]
dapz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zpe has quit [Ping timeout: 240 seconds]
fold has quit [Ping timeout: 264 seconds]
<whitequark>
Drup: just use my fork
<whitequark>
with OASIS
michael_lee has quit [Quit: Ex-Chat]
<Drup>
bah, it works, it's just annoying
Gonzih has quit [Ping timeout: 264 seconds]
bo1 has joined #ocaml
BitPuffin has joined #ocaml
_0xAX has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 260 seconds]
dapz has joined #ocaml
gal_bolle has quit [Ping timeout: 240 seconds]
<algoriddle>
by the way: ocp-build, ocamlbuild, obuild, oasis... is it some sort of rite of passage for a budding ocaml hacker to devise a new build system?
dapz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<algoriddle>
which one is preferred by the experts here?
dapz has joined #ocaml
<Drup>
you actually forgot a numerous amount of build systems :]
<Drup>
and oasis isn't really a build system, it's using ocamlbuild for the building part