agocorona / MFlow

(Haskell) Web application server with stateful, type safe user interactions and widget combinators
http://mflowdemo.herokuapp.com
Other
100 stars 12 forks source link

'External content' widget #50

Closed BartAdv closed 10 years ago

BartAdv commented 10 years ago

Would it be doable to implement widget which renders the raw content (html), and then hooks to some URL, and when request arrives there it process it, generate some value and pass this value down the flow?

This could allow to 'escape' the nice-but-often-restricting applicative/monadic land in favour of traditional approach.

Pseudocode:

external uri = do
  sendResponse "<input type='button' onclick="this.form.submit()">foo</input"
  resp <- waitForResponse uri
  x <- processResponse resp (to produce meaningful value from raw HTTP request)
  return x -- could even loop here again to 'external'

test = page $ do
  i <- getInt Nothing
  e <- external "/baz" -- this won't pass further unless there will be request ready at the specified URI
  -- ...
agocorona commented 10 years ago

Look at "retuning". It may be related with what you menripn El 04/08/2014 11:02, "Bartosz" notifications@github.com escribió:

Would it be doable to implement widget which renders the raw content (html), and then hooks to some URL, and when request arrives there it process it, generate some value and pass this value down the flow?

This could allow to 'escape' the nice-but-often-restricting applicative/monadic land in favour of traditional approach.

Pseudocode:

external uri = do sendResponse "foo</input" resp <- waitForResponse uri x <- processResponse resp (to produce meaningful value from raw HTTP request) return x -- could even loop here again to 'external' test = page $ do i <- getInt Nothing e <- external "/baz" -- this won't pass further unless there will be request ready at the specified URI -- ...

— Reply to this email directly or view it on GitHub https://github.com/agocorona/MFlow/issues/50.

BartAdv commented 10 years ago

Hah! This looks waay simplier than what I've envisioned, and should just do the trick - thanks.