<roconnor>
^^ is "match begin match ..." bad style?
<roconnor>
actually I guess it could be shortend to "match match", but my question is the same
julm has quit [Ping timeout: 265 seconds]
delamarche has joined #ocaml
<thelema>
roconnor: you could probably clarify things by introducing an intermediate variable:
<roconnor>
thelema: I should let out the inner match
<roconnor>
okay
<thelema>
let t,oas,oakds = match pe with ... in match t with ...
<thelema>
well, you can't quite do a destructuring let...
<roconnor>
nope
<roconnor>
I was going to do that, but it didn't work out :)
<thelema>
Maybe monadic operators will help - it looks like you're following the option monad structure
<roconnor>
I am
<roconnor>
is bind defined in batteries or somewhere?
<thelema>
BatOption.bind
<roconnor>
:)
LionMadeOfLions has quit [Ping timeout: 265 seconds]
julm has joined #ocaml
delamarche has quit [Quit: delamarche]
LionMadeOfLions has joined #ocaml
wuj has joined #ocaml
julm has quit [Quit: Reconnecting]
julm has joined #ocaml
wuj has quit [Ping timeout: 265 seconds]
jakedouglas has quit [Quit: Leaving.]
jonafan_ has joined #ocaml
jonafan has quit [Ping timeout: 240 seconds]
<flux>
diml, hm, I'm actually expecting that the program would output exactly 10 times A\nB\nC\n
<flux>
diml, so that the style would resemble what one would write with the Event-module
<flux>
like: match Event.select [Event.receive a; Event.receive b; Event.receive c] with ..
<flux>
which simply receives the first value from any of the channels while not receiving or discarding anything from the others
<flux>
actually now that I think of it it's not realistic to expect A\nB\nC\n, but I would expect 10 times A, 10 times B and 10 times C in any order
<flux>
in other words, cancelling an Lwt_mvar.take would not discard the value in the channel
ulfdoz has joined #ocaml
roconnor has quit [Remote host closed the connection]
ygrek has joined #ocaml
oc13 has joined #ocaml
ulfdoz has quit [Read error: Operation timed out]
valross has quit [Quit: Ex-Chat]
<diml>
flux: in your example, when Lwt_mvar.take is called, a value is already available in the mailbox, so Lwt_mvar.take takes it and immediatly returns
<diml>
and cancelling a terminated thread has no effect
<flux>
diml, yes, I figured that out while walking to the office :)
<flux>
diml, but is there a message passing facility that allows 'undoing' the take?
<flux>
or do I need to write my own? and it would seem to me it would require having my own data type and my own select/pick/choose-function that works on that
<flux>
actually instead of undoing, an atomic getting facility would work
<flux>
a hackish way would be to write a fully blocking mvar variant: one that continues then the other end has read the value. it would work only _mostly_, though, so perhaps a custom solution is in order..
<diml>
i think the easiest way is to use pushable streams with Lwt_stream.choose
<flux>
thanks, I think that's what I've been looking for :)
<flux>
hm, can those streams be pushed?
<flux>
or would I implement that with Lwt_mvar?
<diml>
you have to create the stream with Lwt_stream.create
<diml>
it returns the stream and a push function
<flux>
I possibly googled an old version of the interface
<flux>
yeah, the ocisgen.org site has that function
<flux>
great, I'll try that once I get home. thanks!
ikaros has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
<flux>
diml, from the signature it looks like Lwt_stream.t has unlimited buffering?
<diml>
yes
<flux>
well, that suits me fine :)
<flux>
I guess if I want to integrate Lwt_stream.choose with regular lwt-threads (like timeouts), I want to use Lwt.npick in the future to avoid losing information
Amorphous has quit [Ping timeout: 240 seconds]
<diml>
you can also use Lwt.pick
<flux>
but it still has the same problem, no?
<diml>
threads never woke up simultaneously so you won't loose information
<diml>
but if you use several Lwt_stream.cooose, yes you better use Lwt.npick
Yoric has joined #ocaml
Axsuul has joined #ocaml
Amorphous has joined #ocaml
sepp2k has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
seafood has quit [Quit: seafood]
barismetin has joined #ocaml
ftrvxmtrx has joined #ocaml
ikaros_ has joined #ocaml
ikaros has quit [Ping timeout: 276 seconds]
ttamttam has joined #ocaml
ttamttam has left #ocaml []
iZZy_ has joined #ocaml
ikaros_ has quit [Read error: Operation timed out]
rossberg has joined #ocaml
rossberg has quit [Remote host closed the connection]
rossberg has joined #ocaml
ikaros_ has joined #ocaml
munga has joined #ocaml
iZZy_ has quit [Ping timeout: 240 seconds]
Yoric has quit [Quit: Yoric]
asmanur has joined #ocaml
asmanur_ has quit [Ping timeout: 240 seconds]
munga has quit [Ping timeout: 276 seconds]
iZZy_ has joined #ocaml
iZZy_ has quit [Client Quit]
ikaros_ has quit [Ping timeout: 276 seconds]
Axsuul has quit [Ping timeout: 250 seconds]
munga has joined #ocaml
coucou747 has quit [Quit: 0x2a]
rwmjones_afk has left #ocaml []
rwmjones has joined #ocaml
ygrek has joined #ocaml
_unK has joined #ocaml
Yoric has joined #ocaml
_andre has joined #ocaml
coucou747 has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
mal`` has quit [Quit: Coyote finally caught me]
munga has quit [Ping timeout: 276 seconds]
mal`` has joined #ocaml
ikaros has joined #ocaml
munga has joined #ocaml
joewilliams_away is now known as joewilliams
oc13 has left #ocaml []
joewilliams is now known as joewilliams_away
rgrig has joined #ocaml
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
cybergirl has joined #ocaml
cybergirl has quit [Client Quit]
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
joewilliams_away is now known as joewilliams
avsm has joined #ocaml
Yoric has joined #ocaml
joewilliams is now known as joewilliams_away
eb4890 has joined #ocaml
wuj has joined #ocaml
olgagirl has joined #ocaml
wuj has quit [Excess Flood]
wuj has joined #ocaml
olgagirl has quit [Client Quit]
jakedouglas has joined #ocaml
avsm has quit [Quit: Leaving.]
lpereira has quit [Ping timeout: 276 seconds]
junis has joined #ocaml
<junis>
greetigns .. what is the best emacs mode for ocaml
<thelema>
junis: I use tuareg 2.x
<flux>
diml, Lwt_stream works great. although I don't like that I need to handle the option type everywhere.
<junis>
thank you thelema .. i'll try it
hcarty has joined #ocaml
f[x] has quit [Ping timeout: 252 seconds]
ztfw has joined #ocaml
avsm has joined #ocaml
joewilliams_away is now known as joewilliams
avsm has quit [Quit: Leaving.]
munga has quit [Ping timeout: 240 seconds]
yezariaely has joined #ocaml
init1 has joined #ocaml
munga has joined #ocaml
junis has quit [Remote host closed the connection]
yezariaely has quit [Quit: Leaving.]
<kaustuv>
did they ever fix the indentation in tuareg 2.x?
<thelema>
kaustuv: probably not to your liking. I'm fine with its indentation
<kaustuv>
you mean you are fine with lining up with the | instead of the pattern?
<flux>
if tuareg gets modified into something what it wasn't, please add notes on how to configure it back :P
<thelema>
let rec subst = function
<thelema>
| Variable -> sub_a_expr
<thelema>
| Constant _const as x -> x
<thelema>
This works for me.
<thelema>
It does require a | on the first match otherwise it indents wrong
<thelema>
well, the indentation happens to be preserved anyway. The |'s still stick out enough for me to find match cases
<thelema>
an extra 2 spaces here isn't so bad
<thelema>
isn't so needed
<kaustuv>
it is for begin/end blocks in the body of the case arm. With tuareg 2.x you have:
<kaustuv>
| Pattern -> begin
<kaustuv>
whatever
<kaustuv>
end
<kaustuv>
which just strikes me as wrong on a fundamental level
<thelema>
give the [begin] its own line and you get the extra indent
<kaustuv>
and anyway, I would like to at least have the ability to add a +2 for the indentation. IIRC tuareg 2.x vanilla has no way to modify the indentation of case arms
<thelema>
and I find that if I'm using begin/end in a match, I'll probably want to refactor anyway
<kaustuv>
You never have nested pattern matches?
<thelema>
*rarely*, and if they're not tiny, then they get broken up
<flux>
diml, hi, I'm back, with new code :-). http://modeemi.fi/~flux/lwttest.ml - it still doesn't seem to receive as many values that were sent.
<kaustuv>
I guess you must not do a lot of AST manipulation in your daily coding then
<thelema>
kaustuv: try setting "tuareg default indent" and "tuareg pipe extra unindent" to 4
<thelema>
kaustuv: I bet it's not as complex AST manipulation as yours
<thelema>
that seems to give me the two extra spaces... otoh, the end still lines up with the |
<flux>
diml, I also tried out and indeed it's the Lwt_stream.map that breaks it
<kaustuv>
thelema: I don't want default indent to be 4. And the other option didn't exist in the debian default tuareg 2.x, if I remember right. Anyway, it's train catching time for me.
<thelema>
default indent doesn't affect most things - everything else uses its 2-space indent
<thelema>
at least many things do...
<thelema>
ok, bye
<flux>
diml, I think it may be broken design to build up new sequences based on others and entering Lwt.t monad in the process..
oriba has joined #ocaml
barismetin has quit [Remote host closed the connection]
munga has quit [Ping timeout: 245 seconds]
ftrvxmtrx has quit [Quit: Leaving]
munga has joined #ocaml
Yoric has quit [Quit: Yoric]
ygrek has joined #ocaml
itewsh has joined #ocaml
itewsh has quit [Read error: Connection reset by peer]
Axsuul has joined #ocaml
itewsh has joined #ocaml
itewsh has quit [Max SendQ exceeded]
joewilliams is now known as joewilliams_away
<Axsuul>
I have a list that contains two types.. for example [Foo Bar; Foo Cow], but I want to extract Bar and Cow... does that make sense? :p
<Axsuul>
I mean each element contains two types*
Fullma has joined #ocaml
<flux>
extract how?
itewsh has joined #ocaml
<Axsuul>
I want to match it
<Axsuul>
for example, something like.. match list with Foo Bar -> function1 | Foo Cow -> function2
joewilliams_away is now known as joewilliams
itewsh has quit [Max SendQ exceeded]
<Axsuul>
or even more general.. for example if .. let list = [Country USA; Country Iran; State California; State Oregon];;
<Axsuul>
then i want to do.. match list with Country country -> country | State state -> state;;
<Axsuul>
where USA, Iran, California, and Oregon are also types
<flux>
types?
<Axsuul>
data types
<flux>
country and state in that expression must be of the same type
<flux>
usually USA etc would be values
<flux>
possibly constructors
<flux>
you would perform the matching one by one
<Axsuul>
I'm just having trouble parsing a list with two types.. but the thing is OCaml throws an error becuase
<Axsuul>
lists cannot contain two different data types in in each element
<flux>
so basically you have lists of various attributes and you want to extract them somehow?
<Axsuul>
flux: basically, this is what I want to do
<flux>
the best you can have would be type value = Nonterminal of awksub_nonterminals | Symbol of string and a list of that
<flux>
or actually make that .. | Terminal of string
<flux>
hm
<flux>
but you have that already?-)
<flux>
so what are you really trying to achieve?
<Axsuul>
if an element has type N
<Axsuul>
if the elemtn is... N Expr.. i want to extract Expr and call a function on it
<Axsuul>
if the elment is T _, i want to extract the _ and call a function on it
<flux>
so how does it help you to have a list of _'s instead of T _'s? you already know how to extract the _ from a constructor
<Axsuul>
it has to be of type T
<Axsuul>
err
<Axsuul>
basically, i will have a list similar to this: [T "("; N Num; N Expr; N Lvalue; N Incrop; N Lvalue; T "$"; T "++"; T "--"; T "+"; T "-"; T "0"; T "1"; T "2"; T "3"; T "4"; T "5"; T "6"; T "7"; T "8"; T "9"]
<Axsuul>
I am iterating recursively through the list
<Axsuul>
and matching each element
<Axsuul>
if the element has is a data type T, then I extract the string
<Axsuul>
if the element has data type N, I extract the Expr, Lvalue, Incrop, ... (which are also types)
<flux>
but what do you do with it once you extract it?
<Axsuul>
I want to call another function
<Axsuul>
on the extracted value
<flux>
call the other function right at the extraction point
<Axsuul>
extraction point?
<flux>
let thingamajic_symbol symbol = match symbol with N nonterminal -> handle_nonterminal nonterminal | T terminal -> handle_terminal terminal
<Axsuul>
it's giving me an error though beacuse N nonterminal isn't matching
<Axsuul>
because there are two different types in a list element
<Axsuul>
T terminal matches fine, because terminal is a string
<Axsuul>
flux: thanks, but how would I return the actual nonterminal.. like Expr, Lvalue, or Incrop
<Axsuul>
instead of just simply "nonterminal"
<flux>
axsuul, you cannot return two different types from a function. impossible. but returning different types from a function isn't actually what a program -does-, so perhaps you need to have a better idea what your end goal is in order to find out how to achieve it?-)
SEcki has joined #ocaml
avsm has joined #ocaml
<flux>
I'm uncertain what is the meaning of the data in symbols
<flux>
atleast the example data doesn't seem to make sense? I'm guessing you are trying to evaluate it?
<Axsuul>
Basically, i am giving these grammar rules, and I am also given grammar
<Axsuul>
and I need to return only the reachable rules
<Axsuul>
each rule contains a symbol, such as Expr, Lvalue, Incrop
<Axsuul>
and the right hand rule contains a list of symbols
<flux>
axsuul, in other words you want to prune rules that are unreachable?
<Axsuul>
Yep
<Axsuul>
but in order to do that
<Axsuul>
I have to recursively go through the right hand side of each rule
<flux>
I guess this is an assignment?
<Axsuul>
Yep you guessed right :) This little problem has stumped me for hours =(
<flux>
well, fortunately you don't need to convert that data into a two-type list :)
ygrek has quit [Ping timeout: 245 seconds]
<flux>
in my view you will need to iterate the list manually, unless you are also permittede to use mutation
ulfdoz has joined #ocaml
<Axsuul>
flux: Ya I am doing that, but what happens when I get to the right hand side
<flux>
axsuul, well, did you notice that because you don't need to consider terminals at all, you can get a list of nonterminals only, which is ok?
<Axsuul>
Hmm, but don't I need to consider the terminals, because those are the rules I need to keep
<flux>
you just keep the the element as-is somewhere
<flux>
but for the point of processing the rules (going deeper in recursion), you don't need terminals
<Axsuul>
but say I start with Expr, so I keep all the rules that start with Expr, but how will I know to also keep the rules that start with Incrop, Lvalue, Binop
<Axsuul>
oops sorry, ya we only need to consider the nonterminals
<Axsuul>
but the thing is, the nonterminal element have the two type problem
<Axsuul>
N Expr or N Incrop
munga has joined #ocaml
<flux>
those are just two distinct values and they are of the same type as well.. I don't see the problem?
<flux>
the constructors aren't different types. for example, type my_boolean = True | False - True and False aren't different types, they are different values
<Axsuul>
but isnt that the same problem that I came here with initially?
<flux>
this works: let xs = [Expr; Incrop]
<Axsuul>
but isn't my list [N Expr; N Incrop]
<flux>
well that works as well
<flux>
what doesn't work but you need to work?
<Axsuul>
but remember, I was having trouble matching the values in each element
<Axsuul>
taking a list.. [N Expr; N Incrop; N Binop]
<Axsuul>
and getting Expr, Incrop, Binop
ygrek has joined #ocaml
<flux>
and the problem is.. ?
<Axsuul>
I get an error because there are two different data types in each element
<Axsuul>
Sorry, it must be frustrating for you, but I'm having trouble grasping this
<flux>
the problem there was that you have type ('a, 'b) symbol = N of 'a | T of 'b but you wanted something like type ('a, 'b) symbol2 = 'a | 'b, which doesn't exist in ocaml
<flux>
can you tell me what is the type of Expr?
<Axsuul>
it is of type awksub_nonterminals
<flux>
and what is the type of Incrop?
<Axsuul>
same, awksub_nonterminals
<flux>
so putting them into the same list isn't a problem
<Axsuul>
oh i see what you are saying
<Axsuul>
so when I loook at the right hand side
<Axsuul>
how would I only look at the nonterminals?
<Axsuul>
like.. how would I turn a list that is
<Axsuul>
[T ")"; N Expr; N Incrop] into [N Expr; N Incrop]
<Axsuul>
get rid of all terminals
<flux>
use List.filter
<Axsuul>
Cool, thanks for the time
<Axsuul>
I'll give it a try :)
<flux>
good luck!
joewilliams is now known as joewilliams_away
<Axsuul>
Thanks again, hopefully I won't be back, but yea List.filter works great
joewilliams_away is now known as joewilliams
roconnor has joined #ocaml
<roconnor>
how do I compare lists for structural equality?
<rgrig>
rconnor, =
<roconnor>
oh
<roconnor>
heh
<roconnor>
how do I negate that?
<rgrig>
rconnor, <>
ulfdoz_ has joined #ocaml
<roconnor>
and != is the negation of == ?
<rgrig>
rconnor, yes
<roconnor>
yay, my program works now
ulfdoz has quit [Ping timeout: 252 seconds]
<diml>
flux: you must create the stream and then iterate over it
<diml>
you must not create a new stream at each iteration