I'm using the scaffolded yesod template and want to add a new type for monetary values. Ideally this should be done in one file called Money.hs for example. But this will form cyclic imports:
Foundation imports Model.
The new Money type will be used in the model to store monetary values. Therefore Model will have to import Money
Money will have to import foundation for a moneyField :: Field
Handler Money
function
TL DR: Is there a "correct" way to add new types to a scaffolded yesod application including sql db type, shakespeare field widget and ToHtml
instance?
For your third bullet: why do you need to reference Handler
? You can structure your field code the same way as the built in fields in Yesod.Form.Fields, e.g.:
textField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text
With that: I'd say that a Money.hs
(or even Data/Money.hs
) makes the most sense.