Why do selectField* require Handler ?

11 views
Skip to first unread message

Simon Michael

unread,
Aug 25, 2022, 4:48:09 AMAug 25
to yeso...@googlegroups.com
Good day all!

This is a long shot, but in case anyone can advise:

I'm wondering how to add a selectFieldList here:
https://github.com/simonmichael/hledger/commit/cfc05540daad75a358a47741c16e7611fe42f54f#diff-4f785631673350333a037eca53769f9320f8b8a2856371597ef0687f52f86849R72-R124

And I'm just curious why selectField* has to run in the Handler (HandlerFor site), unlike other field types ?

https://hackage.haskell.org/package/yesod-form-1.7.0/docs/Yesod-Form.html#v:selectFieldList

Thanks for Yesod! I have been relearning it to fix https://github.com/simonmichael/hledger/issues/1229 . The types are intense. I can see how much work they are doing and the amazing value they are providing.

I do find them pretty darn hard to untangle when you go off the beaten path..

Simon Michael

unread,
Aug 26, 2022, 3:16:08 AMAug 26
to yeso...@googlegroups.com
Long story short: I solved that type tetris (more like rubik's cube) as follows:

addModal :: Route App -> Journal -> Day -> Widget
addModal addR j today = do
(addView, addEnctype) <- handlerToWidget $ generateFormPost (addForm j today)
[whamlet| ... |]

addForm :: Journal -> Day -> Markup -> MForm Handler (FormResult Transaction, Widget)
addForm j today = identifyForm "add" $ \extra -> ...

jsch...@gmail.com

unread,
Sep 14, 2022, 1:32:58 PMSep 14
to Yesod Web Framework
Hi Simon,

Just curious: did you find out or have an idea why selectField* have type `Field (HandlerFor site) a` and all other fields have `Field m Text` where m is just `Monad`?

- Jakob
Reply all
Reply to author
Forward
0 new messages