haskellyesodyesod-forms

Why Does Yesod Require PathPiece for Hidden Fields


The type signature for creating hidden fields in Yesod is: hiddenField :: (Monad m, PathPiece p, RenderMessage (HandlerSite m) FormMessage) => Field m p. This is the only field which requires the PathPiece constraint, why is that?


Solution

  • hiddenField is a very free-form field, unlike e.g. textField which specifically works on Text. hiddenField will work on any type which can be marshalled to and from a textual representation, which is where the PathPiece constraint comes into play.