pango has quit [Quit: video driver upgrade, rebooting]
toolslive has quit [Ping timeout: 246 seconds]
ollehar has quit [Ping timeout: 260 seconds]
pango has joined #ocaml
synod has joined #ocaml
travisbrady has quit [Quit: travisbrady]
<synod>
i have a type _ t = A : float -> float t | B : bool -> bool t | C : bool t * 'a t * 'a t -> 'a t. how can I put into a type k = F of float t | B of bool t?
<synod>
whenever I write the boxing function, I get a type error because the type variable can't be specialized via a recursive call to the boxing fn
ontologiae has quit [Ping timeout: 264 seconds]
toolslive has joined #ocaml
<synod>
Is there any way to lift the equality of 'a in the C constructor out to polymorphic matches?
<synod>
besides recursing down both branches, that is
wmeyer has joined #ocaml
ulfdoz has quit [Ping timeout: 252 seconds]
travisbrady has joined #ocaml
tane has quit [Quit: Verlassend]
q66 has quit [Remote host closed the connection]
xaimus_ is now known as xaimus
travisbrady has quit [Quit: travisbrady]
yacks has joined #ocaml
Yoric has joined #ocaml
yacks has quit [Remote host closed the connection]
Yoric has quit [Ping timeout: 251 seconds]
eikke has joined #ocaml
sysop_fb has joined #ocaml
paddymahoney has joined #ocaml
eikke has quit [Ping timeout: 264 seconds]
eikke has joined #ocaml
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
travisbrady has joined #ocaml
eikke has quit [Ping timeout: 256 seconds]
travisbrady has quit [Quit: travisbrady]
weie has joined #ocaml
yacks has joined #ocaml
leoncamel has quit [Quit: WeeChat 0.3.9.2]
derek_c has joined #ocaml
leoncamel has joined #ocaml
derek_c has quit [Ping timeout: 255 seconds]
asmanur has quit [Ping timeout: 245 seconds]
asmanur has joined #ocaml
derek_c has joined #ocaml
zzz_ has quit [Read error: Connection reset by peer]
<spanish>
that's more or less what I've been working with, but now I can't either parse argv, it complains, neither debug the contents of both
<spanish>
it gives me an "expected of type 'a ref" on line 32 (the argv parsing one)
<orbitz>
<3 u phantom types
<orbitz>
What type odes Arg.parse_argv have?
ollehar has joined #ocaml
<spanish>
the one given by List.partition? the thing is that
<spanish>
this is unit testing, I'm supossed to implement it with some existing appl. (mtasc), so need them to be global variables to be employed in another module
<spanish>
defines will be somehow given to Sys.command, together with `cpp -P -E -w ', so it calls cpp on each input file
<spanish>
and args to Sys.argv, also, I need to define the usual `-DHAVE_CONFIG_H' on the command-line, so I can use existing project's definitions on the resulting flash player
<orbitz>
spanish: hrm? NO, Arg.parse_argvis a avlue, what is it type
<orbitz>
err No*
<spanish>
didn't get that? but I was also wrong, `args' will be given to Arg.parse_argv
<orbitz>
huh?
<spanish>
`args' should have everything, but whatever begins with `-D' on the command-line
<orbitz>
you are having trouble compilng your program, right?
<spanish>
yes, well, I'm "patching" mtasc so it calls gnu cpp on each input file
<orbitz>
but your problem is it won't compile
<spanish>
it compiles, now I'm doing that unit-testing to add that feature
ottbot has joined #ocaml
<orbitz>
ok, so everything does compile?
<spanish>
yes, mtasc compiles fine, but not what I pasted after ggole's List.partition thing
<orbitz>
ok, so you're having compilation problems, right?
<spanish>
yes, my unit-test doesn't compile
<orbitz>
Ok, what is the full error and on what line of your paste (pleaes use ideone.com in the fturue, pastebin.com is shit) does it error on?
<spanish>
The program us currently using Arg.parse, so as -Dsomething can be anything (say HAVE_CONFIG_H instead of something), I'm trying to process any `-D' flags before Argv.parse sees them
|jbrown| has joined #ocaml
jbrown has quit [Ping timeout: 255 seconds]
<orbitz>
yes i undertand this
<spanish>
and so I'm splitting original's Sys.argv in `defines' and `args', and then calling Arg.parse_argv with `args'
<orbitz>
my point is you use 'args' like it is a reference, but on line 26 you redefine it to be a string list, so which one do you want to use?
<spanish>
I want `args' to be a global variable, containing the command-line less any `-D' flags seen on it
<orbitz>
so don't redefine it on lien 26
<spanish>
ok, that was after ggole's suggestion, because it's cleaner to use List.partition than what I had previously
<orbitz>
so what do you want to do with the variable you define on lien 26?
<spanish>
`args' will be given to Argv.parse_argv, and `defines' will be passed to Sys.command ("cpp -E -w -P " ^ !defines) or something like that, so cpp is called on each input file
<orbitz>
so what should be in the global 'args' variable?
<spanish>
but as it's done in different modules, I'd like them both to be global variables
<orbitz>
ok so you need to take args as input, partition it, then assign one of your partitions back to args, correct?
<spanish>
everything but any command-line option which starts with `-D'
<spanish>
yes, I just need `args' to be set to the command-line options, not including anything begining with `-D'
<orbitz>
ok, so do that
<spanish>
to be passed to Arg.parse_argv
<spanish>
yes, that's what I'm trying to
<orbitz>
wiat you still aren't making sense
<spanish>
what is it you don't understand?
<orbitz>
afte split_argv is run, how shoudl hte world be different?
<spanish>
ok, I'll put you an example, consider the following command-line:
<orbitz>
nono
<orbitz>
i don't want an example
<spanish>
so?
<orbitz>
split_argv is run, and args equals some value
<spanish>
yes
<orbitz>
shoudl args equal a dfiferent value after split_arv is done?
<spanish>
args is to be set some value in `split_argv', it is declared empty at the begining of the file
<orbitz>
which valuein split_argv should it beset to?
<spanish>
which is any command-line option not begining with `-D', and in order so you still have program's name as it's first argument
<orbitz>
i took your code and removed the result type incase that was it
<ggole>
That doesn't affect the type of t though
<ggole>
failwith will generalise with anything
<orbitz>
ok
<orbitz>
that code still fails though
ontologiae has quit [Ping timeout: 246 seconds]
<ggole>
Well, ocaml doesn't have any idea that the type is associated with the emptiness of the list
<ggole>
(or whatever property you happen to be interested in)
<orbitz>
so it works if I change the value
<orbitz>
hrm
<orbitz>
perhaps there is a better way to get what I want: In my API a GET can return a list of things but a PUT can only take 1 thing. But I want to use the same udnerlying strucutre for both since 99% of the API is the same for things you can GET and PUT.
damasu has joined #ocaml
<ggole>
And use phantom types to do all the checking?
<orbitz>
that would be ideal
<orbitz>
this function is supposed to take a value, and succeed if it is a PUTable value
eikke has joined #ocaml
<orbitz>
and give you back a value with a type you can use with PUT
<ggole>
I see
<ggole>
I don't think you can restrict types like that though, without creating a new value
<orbitz>
ggole: Ok, so I guess my best option is to avoid this function and use set_content for the conversion
<orbitz>
since that modifies the value
<orbitz>
ggole: which I think is the best way anyways
<ggole>
What the Connection example does differently
<ggole>
Is that it creates new values instead of stamping a new type on an existing one
<ggole>
Which is not sound (afaict)
<orbitz>
ok
<orbitz>
well, the set_content version I think is good enouhg
damasu has quit [Quit: leaving]
<ggole>
You can still get your checking if you create things with the type you want to start with
<cthuluh>
hi ; I'm curious about ocp-build that's used in opam and typerex: both distribute it using a .boot piece of bytecode, however this piece of bytecode does things that displease me (writing to $HOME, for example), so I was wondering if it was possible to modify / rebuild it
<ggole>
Although that may not be convenient
<orbitz>
yeah not conventient
<orbitz>
ggole: I think forcing the API to do it via set_content works best anyways
<orbitz>
ggole: thank you for the help
<ggole>
I didn't do much, but you're welcome anyway :)
walter has joined #ocaml
<spanish>
how do I convert a string list to a plain string I can pass to Sys.command? I can't seem to find the right way
<ggole>
String.concat
eikke has quit [Ping timeout: 264 seconds]
<ggole>
spanish: I find it helpful to have a key to bring up the ocaml stdlib documentation
<ggole>
Makes finding things a bit easier
<spanish>
well, I'm looking on the internet, String.concat " " !defines is what I've tried, but it doesn't seem to like it
<spanish>
oh, it seems to be working now, it might have been clobbered with another error
<orbitz>
mfp: I believe so, although I don't quite undersatnd yours
<mfp>
orbitz: the only real difference is the (t : [< `No_siblings | `Has_siblings] t :> [`No_siblings] t) annotation
<orbitz>
what is :> doingthere?
<cthuluh>
spanish: if your list elements are actual arguments, you may not want to munge them in a single string (I'd rather take a look at Unix.execvp)
<ggole>
It's a downcast
<mfp>
just turning the _ t you got into the required type
<spanish>
ah, thanks, I'll look at it
<orbitz>
mfp: thanks!
<mfp>
orbitz: it works because 'a t is (trivially) contravariant, and [ `No_siblings ] is a subtype of [ `No_siblings | `Has_siblings ]
<orbitz>
ok
travisbrady has joined #ocaml
eikke has joined #ocaml
olasd has quit [Quit: leaving]
olasd has joined #ocaml
ontologiae has joined #ocaml
eikke has quit [Ping timeout: 240 seconds]
eikke has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
tobiasBora has joined #ocaml
<tobiasBora>
Hello !
<tobiasBora>
I'd like to debug a function that I can't compile because of error of type. However I don't see where is the problem, so I'd like to run lines by lines my function. Is it possible ? Or do you have any advice to debug this kid of error ?
amaloz has joined #ocaml
amaloz has quit [Read error: Connection reset by peer]
amaloz has joined #ocaml
ulfdoz has quit [Ping timeout: 245 seconds]
travisbrady has quit [Quit: travisbrady]
<toolslive>
the compiler will tell you where the problem is situated.
ottbot has joined #ocaml
ttamttam has left #ocaml []
ttamttam has joined #ocaml
<ggole>
tobiasBora, you can't run your function until it can compile
<ggole>
If you can't figure out why not, you might find it useful to temporarily stick in some annotations
ulfdoz has joined #ocaml
<tobiasBora>
ggole: yes that's why I cannot debug it with a debugger. toolslive: yes but sometimes I don't see where is the problem... (I'm a beginner in ocaml so sometimes I don't see why it's wrong.
<tobiasBora>
ggole: what do you mean by "stick in some annotations" ?
<toolslive>
well, then start annotating the types.
<toolslive>
transform let x = .... into let (x: some_type) =
<toolslive>
and so on
<tobiasBora>
We can do it directly in let ? It's nice ! Thanks !
<ggole>
Keeps the type variables in check a bit
<toolslive>
the problem with the type inference is that the compiler exits quite late... in a location that is not the source of the problem
mathieui has quit [Ping timeout: 248 seconds]
<toolslive>
let f (x:int) : result_type = ....
<toolslive>
so also the return type can be annotated
<toolslive>
if you have ide support, your ide can show you the type of the expression as well
<tobiasBora>
toolslive: I use emacs
<toolslive>
with tuareg, It's <ctrl-c> <ctrl-t>
<ggole>
emacs can show types, but only if you compile with -dtypes (afaik)
<toolslive>
yes, you need to tell the compiler to generate the annotations -annot
<tobiasBora>
Yes it's indeed the error "you should compile with option -annot"
<ggole>
Which doesn't help, since you can't compile
<tobiasBora>
So it's usefull only when it compile
<tobiasBora>
s
<toolslive>
yes, you need to get bootstrapped there first.
<asmanur>
if you use merlin you don't need to compile your files anymore to get typing information
<asmanur>
(and merlin will try his best to ignore typing erros and still provide as much typing information as it can)
<toolslive>
yes that could help beginners a lot.
ottbot has quit [Ping timeout: 256 seconds]
<toolslive>
what I would really like is something like lighttable for ocaml.
<tobiasBora>
asmanur: I'll try to have a look at merlin, thanks !
<asmanur>
it's still in need of polishing but hopefully there's gonna be a release very soon
travisbrady has joined #ocaml
darkf has quit [Quit: Leaving]
notk0 has joined #ocaml
<tobiasBora>
and is there a way to display rapidly a list like in interactive mode ? I mean, I want to debug a function, (which compile now) and I would like to display a variable with somethink like "int list list list = [[[0; 0]]; [[1; 0]]; [[0; 1]]; [[1; 1]]]"
<notk0>
hello, && is used for booleans only?
<tobiasBora>
Is it possible or not ?
<orbitz>
notk0: yes
<notk0>
orbitz: I have code that seems to do && on a non boolean result, how is that possible?
<orbitz>
tobiasBora: if you are new to ocaml i woudln't usggest using a debugger, just play in the rep
<orbitz>
repl
<orbitz>
notk0: proove it?
<notk0>
orbitz: err?
<tobiasBora>
orbitz: rep ?
<orbitz>
notk0: prove it.
<orbitz>
tobiasBora: repl
<notk0>
orbitz: want me to show you code?
<notk0>
| TLet (x, b, t) -> bindable_term b && term t
<ggole>
ocaml can bind && just like any other symbol
<orbitz>
notk0: and what does 'binable_term' return?
<ggole>
let (&&) = 42 (* umm... *)
<orbitz>
sure, that too
<orbitz>
'binable_term' sounds like it returns a bool though
<notk0>
orbitz: in one case true so I assume a boolean
<orbitz>
notk0: if it returns 'true' in one case, how could it return anything other than a bool in other cases?
<notk0>
orbitz: term t, term doesn't return a boolean
<notk0>
term is a type
<notk0>
type term = AdministrativeCpsLam.term
<orbitz>
notk0: that is caerly not the same term being usedthere
<notk0>
orbitz: I can't find another term
<orbitz>
notk0: types aren't functions so in 'term t', term cannot be the name of a type
<ggole>
notk0: does that file open any modules?
<orbitz>
notk0: i suspect the code has opened a module
<ggole>
If so, look there
<orbitz>
(or doesn't compile)
<tobiasBora>
orbitz: How can I display it ? When I just type "varName;", I've "this expression should have type unit"
<notk0>
it opens a module that has a type term in it
<orbitz>
tobiasBora: varName;;
<orbitz>
notk0: it also opens a module with a 'let term' in it (or 'let rec term'
<notk0>
nevermind I found it. it's a function that is defined
<notk0>
I wasn't careful
<notk0>
it's an inner function
<notk0>
sorry guys, and thank you
<orbitz>
does it return a bool?
<tobiasBora>
orbitz: in a function ??? It will end the function !
<notk0>
yes
<notk0>
in one case it returns bool, in another it calls itself and something else
<notk0>
I didn't notice it since it was internal
<orbitz>
tobiasBora: i'm not sure what you'er asking me then
<orbitz>
tobiasBora: why would you do varName; in a function?
<tobiasBora>
orbitz: I'd like to display "varName" (which is a variable), and I don't know how I could do this easily, like when the interpreter gives me the return of a function, but this time inside the function.
<orbitz>
tobiasBora: run the REPL
<orbitz>
let varName = foo;; varName;; will show the value of varName (twice)
<orbitz>
tobiasBora: if you want something isnide the function you'll have to print it
<orbitz>
manually and painfully
<tobiasBora>
orbitz: grrr... Too bad...
<orbitz>
But then you have to ask yourself: why are you writing functions where if you know what the input should be and the output shoudl be the intermediate step are so hard to follow you can't figure it out in your head?
<ggole>
I've never found it particularly worthwhile
<tobiasBora>
ggole: Ok, I may do it if I don't find an other solution. Thanks !
<tobiasBora>
(I've to leave the internet for some time, so thank's a lot for your help !)
<orbitz>
tobiasBora: i'm still unclear on what you have vs what you want
<orbitz>
since your statemnt ofwhat you haev is not valid ocaml and can be interrpeted several ways
tobiasBora_ has joined #ocaml
<orbitz>
tobiasBora: it's still unclear what you're asking since your example list is not valid ocaml and can beinterpreted multiple ways
tobiasBora has quit [Ping timeout: 252 seconds]
<notk0>
is there a function to get the first element of a list?
<notk0>
like fst on tuples?
<adrien>
List.hd
<notk0>
thank you adrien
eikke has quit [Ping timeout: 260 seconds]
<ggole>
Pattern matching is usually a better idea
<notk0>
let ff = fun (_,b1) (_,b2) -> (&&) b1 b2 ;;
<notk0>
why can't I apply such a function to a list of int*boolean using Lost.fold_left ?
UncleVasya has left #ocaml []
<spanish>
nice, I'm done!
<spanish>
I also had to add the -I flag, so as to tell the preprocessor where to look for header files
<spanish>
It's noticeably slower mtasc with this stuff, though
<ggole>
notk0, returns the wrong type
<orbitz>
and why doign (&&) b1 b2?
<notk0>
orbitz: because I need to disregard the first member of the tuple, and return and of all
<orbitz>
i'm not sure how that answers my question
<notk0>
I could List.map first to remove it, with fun t -> snd(t) but that would be slower?
<ggole>
If you just want to accumulate a bool, (fun b1 (_, b2) -> b1 && b2) would be better. Or List.for_all.
<orbitz>
just 'snd', no needfor teh fun
<notk0>
orbitz: normally I would apply (&&) to a list of booleans, but I want to do the same on a list of tupples on the second element
<notk0>
oh I think I understand the problem, the result can't be reapplied to my function
<notk0>
thank you guys
<orbitz>
notk0: That isn't my question. I'm asking why you are doing (&&) b1 b2 isntead of b1 && b2
mathieui has joined #ocaml
<notk0>
oh that is good question orbitz guess I got confused
mye has joined #ocaml
<ggole>
So you just wanna know if every bool in the pair is true?
* ggole
didn't phrase that very well
<notk0>
I fixed it
<orbitz>
let's see
<notk0>
I got the function wrong and your example made me understand it ggole
<ggole>
OK
<ggole>
Although I think List.for_all snd is cleaner.
<notk0>
I realized that my function had the wrong type for the accumulator as I couldn't pass the result to it again
<notk0>
so I either had to return another type, or change the arguments
<notk0>
thank you for your help ggole and orbitz
<notk0>
ggole: isn't List.for_all slower? as it has to transform the list first then apply the function?
<notk0>
oh
<notk0>
ggole: nevermind I read the documentation I confused stuff again..
cdidd has quit [Read error: Connection reset by peer]
eikke has joined #ocaml
<tobiasBora_>
Hello again !
<orbitz>
hi
tobiasBora__ has joined #ocaml
tobiasBora_ has quit [Read error: Operation timed out]
<tobiasBora__>
I've a little question, but I'm affraid I know the answer : is there any way to test if a variable is an integer or a list ? For exemple I'd like to display a list of list of list... And I don't know the number a lists imbricated.
<companion_cube>
that's not possible :)
<companion_cube>
a variable has a unique type, determined at compile-time
<tobiasBora__>
Ok thanks... But it's strange that polymorphe function are impossible...
toolslive has quit [Quit: Leaving]
damasu has joined #ocaml
<companion_cube>
depends what you call "polymorphe functions"
<eikke>
ls
<tobiasBora__>
And if we know the number of lists imbricated but it's too big to create n differentes functions
<tobiasBora__>
companion_cube: for exemple to display differents results if the parametres are integers, string, float...
<orbitz>
tobiasBora__: polymorphic functions are possible, you just have a non-standard defintion of what a polymorphic function is
<companion_cube>
tobiasBora__: i'm afraid you'll have to use different functions for different base types
<companion_cube>
but then you can write string_of_list : ('a -> string) -> 'a list -> string
<companion_cube>
and then string_of_list string_of_int [1;2;3;4]
<tobiasBora__>
orbitz: you mean ? What's wrong with my definition ?
<orbitz>
tobiasBora__: a polymorphic functino shoudln't care waht type it's being given as long as it satisfies the operations perforemd on it
zbroyar has joined #ocaml
<ggole>
tobiasBora__, if you want to nest data structures arbitrarily you will need to use sum types
<tobiasBora__>
orbitz: oh ok sorry I gave this name because in C++ I think that function with same name but differents types of parameters are called polymorphic
<orbitz>
tobiasBora__: that is not polymorphism, that is overloading
<orbitz>
tobiasBora__: in C++ polymorphism is when you make use of dynamic dispatch
<tobiasBora__>
ggole: For exemple put List and Int in the same type ?
<orbitz>
type 'a foo = L of 'a list | Int of int
<orbitz>
something likt that
<orbitz>
or maybe you want type foo = L of int list | Int of int
<orbitz>
tobiasBora__: but I would argue you are Doing It Wrong here
<tobiasBora__>
orbitz: and with a recursive definition like type 'a foo = L of foo | Int of 'a ? Maybe it's the same think ?
Yoric has joined #ocaml
<orbitz>
tobiasBora__: there is no list there
<tobiasBora__>
Indeed ^^
<orbitz>
so they aren't the same
<tobiasBora__>
And why do you think it's not a good Idea ?
<orbitz>
tobiasBora__: you want an Int or a List of ints, correct?
<tobiasBora__>
orbitz: or lists of lists of int etc...
<orbitz>
how nested can it go?
<orbitz>
and why do you need such nesting?
<tobiasBora__>
orbitz: for training ^^
<orbitz>
your answer does not make sense to me
<tobiasBora__>
To make a generic function, like this I don't need to programm a new function every time I need to print a list
<ggole>
type nesty =
<ggole>
| Atom of int
<ggole>
| List of nesty list
<ggole>
Something like that
<ggole>
This allows tree structures and not just lists though
<tobiasBora__>
Um... I'll try !
<orbitz>
this will notwork for what tobiasBora__ wants
<orbitz>
since he'll haveto write a function to convert genericlist to nesty, which brings him back tosquare one
<ggole>
Oh, I see
<ggole>
He seems to want type classes or some other kind of automatic dispatch :/
<ggole>
OCaml doesn't provide much there
<orbitz>
yes
<tobiasBora__>
Um yes..
<orbitz>
at least, mainline ocaml doesn't
<ggole>
Is there a branch that includes type classes?
SpiceGuid has joined #ocaml
* ggole
suspects adding them would involve all kinds of type system shenanigans
<tobiasBora__>
Too bad... So for exemple how can the interpreter print differents kind of structures ? It's not written in ocaml ?
<orbitz>
No, but LexiFi has a branch that includes type info in the bytecode so you can writing genericprinters, at least they hada blog post about it a year or two ago
<ggole>
The interpreter has type level knowledge about the program which it can dispatch on
<ggole>
(Assuming that by "intepreter", you mean toplevel)
* companion_cube
wishes typeclasses would be added to OCaml
<ggole>
It sure would be nice
<orbitz>
I'm not so sure I agree
<orbitz>
I'm not a type theorist thouhg
<companion_cube>
orbitz: typeclasses are a really clean way to deal with polymorphic (==, hash, compare, printing, serializing....
<SpiceGuid>
Ptival : Could gasche complete it ? Is he even aware ?
<orbitz>
I like let open Foo.bar in ... in my code, it is clearwhere I'm getting those operators from, I think type classe sobfuscate that a bit
<companion_cube>
orbitz: but sometimes you shouldn't know where
<ggole>
And sometimes it's a horrible mess
<companion_cube>
if you deal with polymorphic types, with the guarantee that they comply to a typeclass
<orbitz>
companion_cube: that sounds bad to me
<orbitz>
companion_cube: sure
<orbitz>
companion_cube: so far that hasn't been a problem for me
<orbitz>
I'm hesitant to say type classes would be benficial to Ocaml
<orbitz>
but as I said, i'm not a typetheorist
<damasu>
Hi. May I ask some entry-level questions? I'm considering Ocaml for a future project.
<companion_cube>
orbitz: for instance, you can write group : (Equal 'a) -> 'a list -> 'a list list
gnuvince has quit [Ping timeout: 245 seconds]
<companion_cube>
orbitz: it's not a matter of being a type theorist, typeclasses are useful in practice
<companion_cube>
damasu: sure
<ggole>
They do permit considerable type hackery though
<damasu>
What editor/IDE is usually recommended? what dependencies does a compiled binary have?
<companion_cube>
orbitz: it's a bit of a problem for pretty-printing, I find
<orbitz>
companion_cube: I am saying that based on my experience I disagree with the claim that type classes would be a beneficial addition to ocaml
<companion_cube>
(and the current (=) is ugly, very ugly)
<tobiasBora__>
Oh I've an idea (but I think really uggly) : could I do a function print_list deap print_fuction list, and increase n until there is no errors ? I think it's possible to intercept the error no ?
<companion_cube>
orbitz: you never wanted a to_string overloading? :)
<orbitz>
tobiasBora__: that will not work
<tobiasBora__>
why ?
<orbitz>
companion_cube: I have wanted it, sure, but I believe too much else comes with type classes that I would not want
<companion_cube>
like what?
<orbitz>
tobiasBora__: because the type of 'list' changes based on n,
<orbitz>
and ocaml is not dependently typed
<orbitz>
companion_cube: more difficult to read code, for example (IMO)
<orbitz>
as I said, i prefer the source of operators coming into my scopeto be explicit.
<companion_cube>
oh. I don't see why, unless of course you use too many of them
<companion_cube>
but then it's also true for functors
<orbitz>
IME, to_stringis basicallythe only palce that I've wanted typeclasses, and beyond that I have not had an issue that I thought they would solve for me.
<companion_cube>
orbitz: but what if you need two instances of the same operator, for different types?
<tobiasBora__>
orbitz: even if we have somethink like list 'a ? Ocaml doesn't mind what is a no ?
<orbitz>
companion_cube: I rebind them, generally (although this doesn't happen to me often)
<ggole>
damasu, what do you mean by dependencies? dynamically linked libraries?
<orbitz>
tobiasBora__: ocaml needs to be able to determine what 'a is at compiletime
<orbitz>
tobiasBora__: your solution moves that to run time, so it will not work
<damasu>
ggole: yes, as in: what do my users need to run compiled programs if I distribute them?
<orbitz>
companion_cube: But I happily admit I couldbe completley wrong, just based of my experiences typeclasses don't solve many problems I have and I prefer ocaml to remain simpler
<ggole>
damasu, I think everything is statically linked unless you use the dynamic linking features
<notk0>
hello, it seems ocaml can't infer types when I use snd
<orbitz>
notk0: yes it can
<orbitz>
you are doing something else wrong
<damasu>
Great. How does memory usage and performance fare when compared to say... the JDK?
<notk0>
orbitz: I am using List.for_call and it tells me the type is a->b ->b but it expects a specific type
<notk0>
I apply snd to a function
<orbitz>
damasu: IME ocaml programs consume less memory at base line, from there it's upto how you write your program
<ggole>
Less memory, performance is a bit less on certain kinds of code
<ggole>
Usually with 2x or so
<ggole>
*within
<orbitz>
notk0: please provide a testcase, your interpretion of the issue si wrong
<ggole>
Floating point heavy programs can suck a bit
<damasu>
My use-case is a DSL that will be used either stand-alone or embedded in another applications.
<tobiasBora__>
ok thanks. And if n is fixed (if we know the size of the list for exemple ?)
<orbitz>
tobiasBora__: no, no, no
<damasu>
(I don't need floating point performance)
<orbitz>
n is a runtime value
<orbitz>
ocaml is not depenenlty typed
<ggole>
So you would be using ocaml to parse/compile/interpret the dsl?
<tobiasBora__>
Ok thanks !
<damasu>
ggole: yes, a relatively-simple interpreter. I'm looking at Ocaml because in Java (when the host application runs with --server) it consumes tons and tons of memory.
<tobiasBora__>
But I don't understant how does the toplevel works...
<notk0>
here is a test case
<notk0>
let ll1= [ (1,1);(1,2);];; let f i = (i+1);true ;;
<notk0>
List.for_all ( f snd) ll1 ;;
<ggole>
damasu: OCaml is a pretty good match for that
<damasu>
And because having something akin to lex/yacc seems nice (I've never used Ocaml).
<tobiasBora__>
some parts are written in C ?
<ggole>
damasu: there's a toy language example in the docs
<damasu>
Is there a place I can start reading on this topic? (what to use to represent an AST, etc)
<orbitz>
tobiasBora__: the typelevel has access to the udnerlying represtnatio nof objects
<orbitz>
tobiasBora__: aka, it does magic
<damasu>
Oh, great. Thanks a lot for the answers, ggole, orbitz.
<orbitz>
notk0: you are passing 'snd' to f as i, and trying to do (snd + 1)
<ggole>
damasu: algebraic types are lovely for ASTs
<eikke>
damasu: for DSL interpreters, look into using GADTs for encoding
<notk0>
orbitz: in the list snd is supposed to return an int
<orbitz>
notk0: and (f snd) doesn't match the type List.for_all expects
<orbitz>
notk0: reread wha I said
<notk0>
orbitz: so if I have a function that does a' -> bool; and I have a list of ('b,'a) and I want to use List.for_all I can't do that?
<orbitz>
notk0: (f snd) is not function composition
<orbitz>
it is calling 'f' with 'snd' as its first aprameter
<notk0>
hm
<notk0>
ok
<tobiasBora__>
orbitz: yes but for exemple if the toplevel knows that it's a 16 levels nest, how could it print it ? It should have a function for each deap ?
<notk0>
so I have to write a function that does that?
<orbitz>
notk0: just like f 1 is not function compsiiton, it's calling f with the parameter 1
<orbitz>
notk0: you have many solutions
<orbitz>
you coulduse something likeCore that has a function composition opeartor
<eikke>
ls
<damasu>
ggole, eikke: would this be better than say classes? (e.g Int, List, Tuple classes with methods such as ToString is what I used in Java).
<orbitz>
In Core you could do List.for_all (Fn.compose f snd) mylist
<orbitz>
notk0: otherwise, yes just write out the function
<notk0>
I seemed to have solved it by doing a function that does
<orbitz>
notk0: do you understand why your code iswrong?
<notk0>
fun t -> foo (snd t)
<ggole>
damasu, algebraic types are closely related to classes in some ways
<orbitz>
yes that will work
<ggole>
They have some advantages and some disadvantages
<notk0>
orbitz: yes I am applying the value of snd to the function
<ggole>
An AST is pretty much an ideal application for algebraic types though :)
<ggole>
OCaml will give you lovely exhaustiveness and redundancy checking
<orbitz>
especiallyif your langauge has exhasutive matching
<ggole>
Which is a godsend when you start changing data structures
<damasu>
It's just a simple lisp-like thing (similar to Scheme).
<ggole>
Are you just going to walk the AST, or generate byte code?
<orbitz>
or do optimzations
<damasu>
It can't be compiled to bytecode (not easily analyzable), a tree-walking interpreter is more suited to it.
ontologiae has joined #ocaml
<damasu>
Mmmm, ADTs look good for this, thanks for all the input. :-)
<thizanne>
I don't think so. A linked interpreter is way better
<tobiasBora__>
And does anyone knows if there is a way in emacs to have to "prototype" of a function from stdlib ?
<ggole>
Tree walking interpreters are very easy to write, but quite slow
<orbitz>
tobiasBora__: if yo ucan figure it out, typerexmight do it
<damasu>
ggole: my current prototype is fast (when compared to say Python), but is uses a ton of memory (the JDK is the problem here).
<orbitz>
tobiasBora__: I just have a window open to the REPL all the time
<damasu>
But I also don't like pushing the JDK itself as a dependency to my users.
<ggole>
damasu: you wrote a tree walker in Java? I'm surprised that's faster than even a pretty slow language like Python.
<tobiasBora__>
orbitz: what do you call REPL ?
<orbitz>
tobiasBora__: the thing yo uget when you type 'ocaml' into your shell
<tobiasBora__>
orbitz: and typerexmight is run in REPL ?
<orbitz>
tobiasBora__: typerex is an extensio nto emacs
<tobiasBora__>
orbitz: And you're saying that with typerexmight you don't need to open a browser ? (I don't understant the link between typerex and REPL)
<orbitz>
tobiasBora__: I am saying typerex might do what you want, but I prefer to just leave a REPL open and inspect value through that
iZsh has quit [Quit: Coyote finally caught me]
<tobiasBora__>
orbitz: oh ^^ I think I wasn't clear : I mean is there a way to see prototype of commun function ? For exemple I need to know the prototype of fold_right, and I don't want to use the browser to check