<Gvidon>
Obviously, I see the difference in the result I get, but I don't really understand how it happens
<flux>
so let f = xxx evaluates xxx right ahead and puts it to f
<flux>
it doesn't create a function
<flux>
the value of f is now ()
<flux>
whereas let f () defines a function from unit to unit (unit being the type of ()). so after let f () the value of f is a function of type unit -> unit.
<Gvidon>
What about "let () = xxx"? Why does it do the same thing?
<flux>
it does do the same thing
<flux>
oh, right :-)
<flux>
so actually let a = b isn't an "assignment"
<flux>
it's pattern matching, where the left side is a pettern with identifier 'a'
<flux>
so for example: let a = 5 <- the pattern 'a' is matched with '5' and as it fits, the number 5 is bound to 'a'
<flux>
or: let () = () the pattern () matches (), but because it's a constructor without a free variable, no new bindings are produced
<flux>
if your case you are basically doing let () = (..expression returning ()..)
<Gvidon>
So, "let f () = " creates a function that takes unit, and "let () = " just "assigns" some value to unit, i.e. throws it away, right?
<flux>
yes
<Gvidon>
Ok
<Gvidon>
Makes sense
<Gvidon>
Thanks
<flux>
btw, let f () = ... can also be considered to be syntactic candy for: let f = fun () -> ...
<Gvidon>
The fact that the same syntax is used for two different things makes it a bit hard to understand
cyraxjoe_ has joined #ocaml
<flux>
I imagine it stems from the idea that functions are values in functional programming languages
ryanartecona has joined #ocaml
cyraxjoe has quit [Ping timeout: 250 seconds]
<artart78>
more like values are functions, I guess :p functions taking no argument
<flux>
I think the very idea of function is that it DOES take an argument :)
<flux>
but yes, perhaps the syntax could be though like that as well.
<Gvidon>
artart78: No, my example shows that they're two totally different things. This is why I got confused
<flux>
I think artart78 was suggesting that functions are in the form let f arg1 arg2 .. and then 'basic binding' is then a zero-argument function let f = x. but, it's really not, in ocaml ;-), because the evaluation is then performed on the spot.
<Gvidon>
Or maybe you're right. For me a "a function that takes unit" and "a function that takes no argument" mean the same thing, but I guess it's wrong. I thought it was the same thing as 'void' in C
<artart78>
it's because ocaml has eager evaluation
<artart78>
a function that takes unit takes 1 argument
<artart78>
let f () = ← 1 argument, let f = ← 0 argument
<Gvidon>
I see
<Gvidon>
It's all pretty confusing for a C++ guy like me. Thanks :)
<flux>
a mathematician might say that a zero-argument function is just a constant. and that it is in ocaml :).
<zamy>
note that: 1- the function "hunpos_tagger_new" is called only once 2- "hunpos_tagger_tag" is called multiple times, with about 1k of data, maybe less
<adrien>
compaction maybe?
<adrien>
hmmm, global_root is there
<zamy>
3- hunpos_tagger_destroy is never called 'cause i have the segfault earlier :)
<zamy>
i have ocaml 4.02.3
<adrien>
hmm, I'd need to actually try by myself but I can't do that now
<zamy>
well i can wait :)
<zamy>
do you want a sample to run?
yegods has joined #ocaml
<zamy>
ah, i forgot: the segfault is consistent. I mean, it happens always at the n line of input. I may be wrong , but it seems like the gc isn't collecting some data, that fills the memory.
yegods has quit [Ping timeout: 276 seconds]
JacobEdelman has joined #ocaml
<edwin>
you can manually call the garbage collector/compact to find out the crash location more precisely
<edwin>
also there is a debug runtime that might help
<edwin>
ocamlopt -runtime-variant d
<zamy>
ty edwin
Kakadu has joined #ocaml
<zamy>
i'm looking for that
Haudegen has quit [Ping timeout: 250 seconds]
ismaelga has quit [Remote host closed the connection]
<zamy>
in the inclusion files i can't find a function to force the gc to do its work
<zamy>
i'm looking at the headers in /us
<zamy>
i'm looking at the headers that i have in /usr/lib/ocaml/caml
Haudegen has joined #ocaml
<zozozo>
zamy: there is a Gc module on the OCaml side
<zamy>
yeah, but how can i access it? its shared header contains only colors and 'Make_header' definitions
infinity0 has quit [Remote host closed the connection]
<zamy>
it runs the test (previousley giving segfault) without particular problems
igoroliveira has joined #ocaml
<zamy>
now it gives another segfault with a different test xD it seems there are some issues with the ocaml code anyway, seeing how the previous segfault was solved
ely-se has joined #ocaml
dsheets has joined #ocaml
Sorella has joined #ocaml
BitPuffin has joined #ocaml
kdas_ has joined #ocaml
NingaLeaf has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
yegods has joined #ocaml
yegods has quit [Ping timeout: 240 seconds]
kdas_ has quit [Quit: Leaving]
ismaelga has joined #ocaml
ismaelga has quit [Read error: Connection reset by peer]
ismaelga has joined #ocaml
ismael has joined #ocaml
ismael is now known as Guest4871
ismaelga has quit [Read error: Connection reset by peer]
ceryo has joined #ocaml
Guest4871 has quit [Remote host closed the connection]
ismaelga has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
agumonkey has quit [Ping timeout: 250 seconds]
dsheets has joined #ocaml
<Kakadu>
Let's say we have some recursive functions and we want to trace their execution (tree). How to do this in most convenient way (without forcing a human to insert some code manually) ?
<Kakadu>
It could be useful when we want to explain how parser combinators work for this concrete output...
ely-se has quit [Quit: leaving]
<ggole>
#trace, maybe?
<Kakadu>
yep, but
<Kakadu>
1) I want to use custom functions for entering/leaving section (should be hackable)
<Kakadu>
2) it doesn't work in js_of_ocaml toplevel because Obj.is_block works differently there (should be hackable too)
<Kakadu>
do you know something less hackable?
<ggole>
Um, pass the trace function as an argument?
<Kakadu>
ggole: yeah, but I should hack compiler sources in this case
<ggole>
O_o
<Kakadu>
is there somethin without touch a compiler?
<Kakadu>
without touching*
<ggole>
Maybe ppx... but I'm not sure how to go about doing that
<zozozo>
Kakadu: maybe something could be done using Printexc.get_callstack ?
<Kakadu>
zozozo: I want to know when function a calls b and successfully leaves b too
<Kakadu>
but it could be an idea
<Kakadu>
but my question is about code injection and not about which should be injected
<zozozo>
ow, then I'd say call some enter/exit logging function
<Kakadu>
I remember some stuff for C# where guys insert some logging in every method. It was called aspect-oriented-programming
<zozozo>
I actually have something like in my code for profiling purposes
<edwin>
if you have a monadic interface could you add some tracing at the monad level?
<Kakadu>
edwin: I have monadic interface but how to do this without forcing a person to add it manually?
<Kakadu>
I can hardcore something in predefined functions (let's say parser-combinators to be more concrete)
<Kakadu>
but a guy writes it's own parser-combinator and I don't want to force him to add some loggin stuff verbosely
<edwin>
hmm could you chain your trace function between all normal binds?
<Kakadu>
hmm
<Kakadu>
it could be an idea
<edwin>
i.e. turn parse_a >>= parse_b into parse_a >>= (fun state -> trace_me '...'; parse_b state)
<edwin>
but you also need to somehow know when parsing fails
<edwin>
and a new branch is tried
aaronelkins has quit [Quit: aaronelkins]
<Kakadu>
edwin: and who should change the code? some syntax extension?
<edwin>
I was thinking that you use a functor to 'interpose' between the user oft he parser combinator and its implementation
<edwin>
like monad transformers
<edwin>
but if you have lots of combinators that might not be very nice
<Kakadu>
I kind of don't get how opening another module can add some code to the current functions
<Kakadu>
let's say we have
<ggole>
It doesn't. It only has a namespacing effect.
<ggole>
include adds the contents of a module, open only makes it available unqualified.
<Kakadu>
What can I open/include to add some logging about entering/leaving foo?
<Kakadu>
I don't understand that
<zozozo>
Kakadu: let 'rec' maybe ?
<Kakadu>
yeah
<zozozo>
well, if foo is in your code base, a ppx could probably do the trick
<Kakadu>
let foo n = (string "[") >> (many (foo 15)) << (string "]")
<Kakadu>
ppx should detect than if my function is declared as partial or not then
<Kakadu>
i.e. ppx should be aware of types
<Kakadu>
( I heard about Jun Furuse's talk this september)
<edwin>
I was thinking you could redefine >> to: a >> tracer "entering" (Printexc.get_callstack 1) >> b; and << to a << tracer "leaving" (Printexc.get_callstack 1) << b
<edwin>
but this would refer to 'foo' your function
<edwin>
not 'many foo'
<Kakadu>
hmmm
<edwin>
ppx would probably be more flexible but I never tried writing a ppx
<Kakadu>
Interesting, what it will print when I compiled this with js_of_ocaml
<edwin>
do backtraces work in js_of_ocaml?
<Kakadu>
js_of_ocaml erases function names sometimes
<Kakadu>
It stores symbol table btw
<Kakadu>
but js_of_ocaml gives some comlications at least
ncthom91 has joined #ocaml
<edwin>
maybe wrapping your parser combinator wouldn't be so bad though:
<edwin>
string c = let msg = "string" ^ c in entering msg >> Impl.string c >> leaving msg
<edwin>
many x = entering "many" >> Impl.many x >> leaving "many"
<edwin>
....
<edwin>
and then the user can open ParserDebug
<edwin>
instead of Parser when they want the tracing
ncthom91 has quit [Client Quit]
<edwin>
in entering/leaving you could track the level and print something like:
<edwin>
entering string [
<edwin>
entering string [
<edwin>
...
<edwin>
leaving string ]
<edwin>
not sure if thast what you are after
ddosia has joined #ocaml
struktured has joined #ocaml
ncthom91 has joined #ocaml
nicoo has quit [Remote host closed the connection]
<zamy>
is there a way to force the garbage collection from c?
nicoo has joined #ocaml
<dsheets>
Does anyone have experience using Lwt_streams between a pre-emptive thread and an Lwt main loop? They don't seem to flush...
<flux>
zamy, well, there is the function caml_gc_full_major aka Gc.major (), maybe you can call it from C
<flux>
you may need to release some lock to do it
<dsheets>
In particular, Lwt_stream.iter_s doesn't seem to wake up when new elements are pushed by a secondary thread
Nahra has quit [Ping timeout: 240 seconds]
Nahra has joined #ocaml
struktured has quit [Ping timeout: 272 seconds]
<edwin>
I know Lwt_unix.make_notification/send_notification works (with Lwt.wait + Lwt.wakeup), do you push elements from the detached thread directly, or do you use the notificaitons?
<zamy>
tnx flux but i'm afraid i can't
MercurialAlchemi has quit [Ping timeout: 240 seconds]
<dsheets>
edwin, I've been pushing directly... I will investigate the notifications, thanks!
<edwin>
the problem with the notification is that its one-shot though, might be complicated to turn that into a stream
<edwin>
the typical way I've seen it used was by using a ref set from the thread
<edwin>
but its the only function documented as 'thread-safe' in Lwt
<dsheets>
Yes, I was wanting to avoid constructing my own stream/sync goop and use a nice existing abstraction, instead
<edwin>
how about run_in_main?
<dsheets>
ohhhhhh... nice idea
struktured has joined #ocaml
<dsheets>
edwin, works beautifully! thank you! :-)
<edwin>
yw, now I wonder why I used the notification in the first place in my code at one place instead of run_in_main :)
MrNice has joined #ocaml
<MrNice>
Hello
<MrNice>
"hello /n World"
<MrNice>
my Ocaml doe not make a new line. Anyone an idea why?
<Kakadu>
MrNice: \n
<MrNice>
sorry, i mean \n
<flux>
mrnice, you mean in the toplevel (shell)?
<MrNice>
yes
<flux>
well, that's how it (the toplevel) prints control codes
<flux>
if you want to put them to your terminal, you need to do it programmatically
<flux>
ie: print_string "hello\nworld\n";;
<MrNice>
Well, i think i did not understand you correctly
Gvidon has quit [Quit: Leaving.]
<MrNice>
i am typing "Hello World" in Ocaml-top
<MrNice>
And i want an output in two lines
<flux>
well, that cannot happen :)
<MrNice>
tell this my teacher :)
<flux>
here's a solution: "Hello World"
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #ocaml
<flux>
what is the exact problem statement?-o
<MrNice>
thanks a lot flux!
<MrNice>
our class is programming on a low level. We are just working inside Ocaml-top
<flux>
I think a reasonable solution would involve the print function somehow.
bibou has joined #ocaml
<MrNice>
It's not important for us. But my teacher searched for an solution.
<MrNice>
bye bye
MrNice has quit [Quit: Page closed]
<edwin>
doesn't ocaml-top show stdout?
bibou has quit [Client Quit]
<flux>
well, it depends what you mean, but you can certainly see what your program writes to stdout (..with ie. print)
lobo_ has joined #ocaml
octachron has quit [Quit: Leaving]
lobo_ is now known as lobo
yegods has joined #ocaml
yegods has quit [Remote host closed the connection]
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ely-se has joined #ocaml
yegods has joined #ocaml
bibou has joined #ocaml
ryanartecona has joined #ocaml
ncthom91 has joined #ocaml
<bibou>
hello. when I run make test (for a project based on oasis) I get: "Warning: the tag "tests" is not used in any flag declaration, so it will have no effect; it may be a typo. Otherwise use `mark_tag_used` in your myocamlbuild.ml to disable this warning."
<bibou>
is there any way to make my test suite to run when I enter "make test"
<bibou>
?
<Drup>
./configure --enable-tests
<bibou>
I have configured through "ocaml setup.ml -configure --enable-tests" its the same, right?
<bibou>
I'm making some changes. I'll check again in a min. What about the warning?
<Drup>
byproduct of ocamlbuild+oasis, it happens sometimes
slimane has quit [Quit: Bye]
kay has joined #ocaml
kay has quit [Max SendQ exceeded]
jeffmo has joined #ocaml
yegods has quit [Remote host closed the connection]
yegods has joined #ocaml
yegods has quit [Remote host closed the connection]
<companion_cube>
gasche is on a merging spree again, nice
MercurialAlchemi has joined #ocaml
zpe has quit [Remote host closed the connection]
tkr_ is now known as tkr
yegods has joined #ocaml
jonludlam has quit [Ping timeout: 255 seconds]
jeffmo has quit [Quit: jeffmo]
slash^ has joined #ocaml
sepp2k has quit [Quit: Leaving.]
<bibou>
ok it works Drup. I manually removed _build (I have messed up the dir hierachy). make runs tests. thx.
Guest38 has joined #ocaml
jonludlam has joined #ocaml
psy_ has joined #ocaml
jeffmo has joined #ocaml
psy_ has quit [Max SendQ exceeded]
mort___ has quit [Ping timeout: 246 seconds]
JacobEdelman has quit [Quit: Connection closed for inactivity]
jonludlam has quit [Ping timeout: 246 seconds]
zamy has quit [Quit: Page closed]
ahf has joined #ocaml
jonludlam has joined #ocaml
ir2ivps4 has joined #ocaml
bibou has quit [Quit: Leaving]
ryanartecona has quit [Quit: ryanartecona]
ryanartecona has joined #ocaml
pyon has quit [Ping timeout: 272 seconds]
yegods has quit [Remote host closed the connection]
yegods has joined #ocaml
JacobEdelman has joined #ocaml
pyon has joined #ocaml
yegods has quit [Remote host closed the connection]
yegods has joined #ocaml
ollehar has joined #ocaml
cyraxjoe_ is now known as cyraxjoe
yegods has quit [Ping timeout: 250 seconds]
sgnb` has quit [Remote host closed the connection]
jonludlam has quit [Remote host closed the connection]
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #ocaml
ousado has joined #ocaml
ousado_ has quit [Ping timeout: 252 seconds]
^elyse^ has joined #ocaml
zpe has joined #ocaml
ismaelga has quit [Remote host closed the connection]
ryanartecona has quit [Quit: ryanartecona]
orbifx has quit [Ping timeout: 255 seconds]
nicoo has quit [Remote host closed the connection]
dsheets has quit [Ping timeout: 276 seconds]
Kakadu has quit [Quit: Page closed]
nicoo has joined #ocaml
ygrek has joined #ocaml
nicoo has quit [Remote host closed the connection]
orbifx has joined #ocaml
<mfp>
what was the magic to make the moral equivalent of this work? type 'a foo = [ `A | 'a ] constraint 'a = [> ]
nicoo has joined #ocaml
<Drup>
type 'a foo = ([> `A] as 'a)
nicoo has quit [Remote host closed the connection]
<mfp>
thanks, this works for the slightly less simplified example: type 'a foo = ([> `A of 'a foo ] as 'a)
nicoo has joined #ocaml
<mfp>
but uh, it's not very useful in actual use, is it? You have to list all the constructors again (as opposed to only the extra one) whenever you want to add some
<mfp>
so the only use is carrying the constraint
<Drup>
there are some usages, but mostly with phantom types
<mfp>
in this case I have type a = [`A of a list | `B ] and a function : [`A of b list | `B | `C ] -> a option (return None if `C found anywhere)
<mfp>
trying not to write type b = [ `A of b list | ...] in full
<mfp>
typo ([`A of 'b list | `B | `C ] as 'b) above
ryanartecona has joined #ocaml
Lis has joined #ocaml
jeffmo_ has joined #ocaml
jeffmo has quit [Ping timeout: 264 seconds]
jeffmo_ is now known as jeffmo
jeffmo has quit [Client Quit]
jeffmo has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
^elyse^ has quit [Quit: Leaving]
shinnya has joined #ocaml
Kakadu has joined #ocaml
orbifx2 has joined #ocaml
<ggole>
mfp: what are you trying to do there?
<ggole>
If you just want to avoid typing all the constructors out again, but need recursion, you could try knot-tying.
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbifx has quit [Ping timeout: 272 seconds]
ryanartecona has joined #ocaml
darkf has quit [Quit: Leaving]
jeffmo_ has joined #ocaml
ncthom91 has joined #ocaml
jeffmo has quit [Ping timeout: 272 seconds]
jeffmo_ is now known as jeffmo
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Lasher` has joined #ocaml
kushal has quit [Quit: Leaving]
freehck has quit [Remote host closed the connection]
ismaelga has joined #ocaml
kandu has quit [Ping timeout: 240 seconds]
slash^ has quit [Read error: Connection reset by peer]
BitPuffin has quit [Ping timeout: 250 seconds]
ggole has quit [Ping timeout: 240 seconds]
zpe has quit [Remote host closed the connection]
tane has quit [Quit: Verlassend]
Denommus has joined #ocaml
yegods has joined #ocaml
zpe has joined #ocaml
larhat has joined #ocaml
Simn has quit [Ping timeout: 252 seconds]
rand has joined #ocaml
ddosia has quit [Quit: Connection closed for inactivity]
kandu has joined #ocaml
kandu is now known as Guest84624
ncthom91 has joined #ocaml
Guest84624 has quit [Remote host closed the connection]
kandu_ has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
jonludlam has joined #ocaml
manud has joined #ocaml
yegods has quit [Remote host closed the connection]
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #ocaml
zpe has joined #ocaml
theblatte has quit [Ping timeout: 260 seconds]
theblatte has joined #ocaml
theblatt1 has quit [Ping timeout: 255 seconds]
teknozulu has joined #ocaml
yegods has quit [Remote host closed the connection]
yegods has joined #ocaml
Denommus has quit [Quit: going home]
orbifx has quit [Quit: WeeChat 1.3]
yegods has quit [Remote host closed the connection]
orbifx2 has quit [Quit: AtomicIRC: The nuclear option.]
jeffmo has quit [Quit: jeffmo]
Kakadu has quit [Remote host closed the connection]
ontologiae has joined #ocaml
<mahem1>
Hmmm, ran into some troubles creating an exists_in_queue functions because I forgot to do a Queue.copy and ended up changing the original queue.
<mahem1>
Makes me wonder why the Queue.t is modified inplace in the first place.
<mahem1>
Like I am tempted to create my own "more functional" queue type that will bypass state issues like this altogether.
coody has joined #ocaml
jeffmo has joined #ocaml
NingaLeaf has quit [Quit: My Mac has gone to sleep. ZZZzzz…]