user2936306
user2936306

Reputation: 246

Adding custom datatype in Yesod

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:

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?

Upvotes: 1

Views: 154

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31315

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.

Upvotes: 1

Related Questions