MercurialAlchemi has quit [Ping timeout: 240 seconds]
larhat1 has joined #ocaml
<flux>
myst|fon, no. the way to do that could be: type binop = Add | Sub type unaryop = Imm type ast = Unary of (unaryop * ast) | Binary of (binop * ast * ast)
<myst|fon>
flux: thanks.
kakadu has joined #ocaml
MercurialAlchemi has joined #ocaml
virtualeyes has joined #ocaml
kakadu has quit [Quit: Page closed]
zpe has joined #ocaml
antkong has quit [Quit: antkong]
Haudegen has quit [Ping timeout: 250 seconds]
mac10688 has joined #ocaml
Haudegen has joined #ocaml
cmpxchg has joined #ocaml
wolfcore has quit [Ping timeout: 260 seconds]
ygrek_ has joined #ocaml
virtualeyes is now known as nullremains
wolfcore has joined #ocaml
kushal has joined #ocaml
octachron has joined #ocaml
ygrek_ has quit [Ping timeout: 272 seconds]
ggole has joined #ocaml
kakadu has joined #ocaml
struk|desk|away is now known as struk|desk
chris2 has quit [Ping timeout: 240 seconds]
eni has quit [Read error: No route to host]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
chris2 has joined #ocaml
mac10688_ has joined #ocaml
zpe has quit [Remote host closed the connection]
pierpa has joined #ocaml
Sorella has joined #ocaml
octachron has quit [Ping timeout: 250 seconds]
struk|desk is now known as struk|desk|away
octachron has joined #ocaml
Haudegen has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
Haudegen has joined #ocaml
lokien_ has joined #ocaml
sh0t has joined #ocaml
eni_ has joined #ocaml
eni_ is now known as eni
RossJH has joined #ocaml
ollehar has joined #ocaml
MercurialAlchemi has joined #ocaml
cyraxjoe_ has quit [Ping timeout: 272 seconds]
cyraxjoe has joined #ocaml
aantron has joined #ocaml
Fleurety has quit [Ping timeout: 256 seconds]
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 250 seconds]
octachron has quit [Quit: Leaving]
Fleurety has joined #ocaml
Fleurety has quit [Excess Flood]
Fleurety has joined #ocaml
hairer has joined #ocaml
Fleurety has quit [Excess Flood]
Fleurety has joined #ocaml
Fleurety has quit [Max SendQ exceeded]
MercurialAlchemi has quit [Ping timeout: 256 seconds]
lokien_ has quit [Quit: Connection closed for inactivity]
Fleurety has joined #ocaml
Fleurety has quit [Max SendQ exceeded]
badon has quit [Read error: Connection reset by peer]
kakadu has quit [Remote host closed the connection]
Fleurety has joined #ocaml
phonzbm has joined #ocaml
Fleurety has quit [Max SendQ exceeded]
k1000_ has quit [Quit: .]
Stalkr has quit [Quit: Leaving...]
Stalkr has joined #ocaml
k1000 has joined #ocaml
Stalkr has quit [Ping timeout: 264 seconds]
JacobEdelman has joined #ocaml
manizzle has joined #ocaml
hairer has quit []
struk|desk is now known as struk|desk|away
seangrove has joined #ocaml
<seangrove>
Hey all, struggling a bit - I'm using Opium to get a toy http server up and running. I would like for one of the request handlers to e.g. /some-id to then make a cohttp request to e.g. twitter.com/some-id.json, and return the json parsed output (basically just proxying at this stage)
<seangrove>
The challenge I'm running into is figuring out how Lwt fits in - I have the code that can make the serve a request to localhost/some-id, and I have the code that can make a call to twitter/some-id.json, but cohttp obviously returns lwt-wrapped values. so I get `string Lwt.t` instead of `string`, which is what my handler is expecting
<seangrove>
I feel I'll probably have to invert parts of the program to get the types wrapped in Lwt values to work correctly, but I'm struggling to see what the transformation is :P
<Drup>
You must use either Lwt.bind (>>=) or Lwt.map (>|=) to use the string
<seangrove>
Drup: Inside of the handler itself, I would assume, right?
<Drup>
yes
<Drup>
Some things like that should work, I guess
<seangrove>
Ok, so then that's going to also return a value wrapped in Lwt, which means that the Opium App stuff may have a problem
<Drup>
new_item >>= fun x -> `Json (x |> json_of_item |> Ezjsonm.wrap) >>= respond'
<seangrove>
I'll give it a try first
<Drup>
new_item >|= fun x -> `Json (x |> json_of_item |> Ezjsonm.wrap) >>= respond'
<Drup>
rather that
<Drup>
respond' also returns a Lwt.t so it's fine :)
<seangrove>
Drup: Ok great, that makes sense - glad my intuition wasn't toooo far off, heh
<seangrove>
I'll play with that for a bit, thanks!
<seangrove>
Drup: Also, you're the main force behind js_of_ocaml, right?
<seangrove>
I was curious about the flambda opts too
<Drup>
in which thread was that ?
<seangrove>
The OCamlScript thread
<Drup>
right, YC is a tad more annoying that reddit for long running threads
<Drup>
1) hugo is looking at separate compilation for jsoo
<Drup>
2) the flambda question is difficult, mostly because I don't know much about jsoo's internals
<Drup>
my understanding, derived from what pierre chambart and jerome vouillon told me, is that a good amount of things done by flambda are not representable in bytecode and would be annoying to implement in js.
ollehar has quit [Ping timeout: 245 seconds]
<seangrove>
Interesting, thanks!
<struk|desk>
I wouldn't mind if "module A (B) = struct .. end" implied that "module A (B:B) = struct .. end"
darkf_ is now known as darkf
<seangrove>
Drup: I don't think I quite want: new_item >|= fun x -> `Json (x |> json_of_item |> Ezjsonm.wrap) >>= respond'
<seangrove>
respond' returns <something> Lwt.t, and >|= returns 'b Lwt.t, so that line will return <something> Lwt.t Lwt.t
manizzle has quit [Remote host closed the connection]
<seangrove>
new_item >|= fun x -> `String ("test") >>= respond' (* This expression has type Opium_rock.Response.t Lwt.t Lwt.t *)
<seangrove>
Pretty cool that it catches all this at compile time though :)
kakadu has joined #ocaml
<Drup>
ah, yeah, >>= then
<seangrove>
Yup, that did it - at least for compile errors, now lets see how it behaves...
<seangrove>
Whoops, nope, doesn't compile. Will poke at it some more
<seangrove>
Nice, it works! Now I have to figure out how to coerce the text into JSON, and then hopefully into an OCaml type
<seangrove>
A lot to get through, heh
<seangrove>
If I define a type in OCaml with all the fields from the JSON spec, but some of the JSON fields are optional, is it not possible to coerce it into the OCaml type?
<seangrove>
Nevermind, I think RWO covers this
<seangrove>
Yeah, just "x option", makes sense
silver has joined #ocaml
govg has quit [Ping timeout: 245 seconds]
<struk|desk>
seangrove: for say, ppx_protobuf you can annotate a type with default values, could be something similar with the json framworks