0

I have the following model in config/models:

Post json
    title Text
    intro Text
    posted UTCTime default=now()
    published Bool default=true
    content Markdown Maybe
    cvId CvItemId Maybe
    projectId ProjectId Maybe

I have Yesod.Text.Markdown, which clearly defines a PersistField installed and imported in src/Models.hs. In this file, the models are generated using the following piece of code:

share [mkPersist sqlSettings, mkMigrate "migrateAll"]
    $(persistFileWith lowerCaseSettings "config/models")

On trying to build, I get the following error:

src/Model.hs:20:7: error:
    • Not in scope: type constructor or class ‘Markdown’
    • In the untyped splice:
        $(persistFileWith lowerCaseSettings "config/models")
   |
20 |     $(persistFileWith lowerCaseSettings "config/models")
   |

How do I make this work? I could probably make it work by avoiding TemplateHaskell, but I'd like to stick with this format, as it's much more elegant.

Ben
  • 1,561
  • 4
  • 21
  • 33
  • 1
    I assume you're importing `Text.Markdown` along with `Yesod.Text.Markdown`? The latter only defines an orphan instance, and as far as I can tell doesn't actually reexport the type. – DarthFennec Jun 20 '18 at 16:17
  • That was indeed an issue, however, after adding that, I get ` No instance for (blaze-markup-0.8.2.1:Text.Blaze.ToMarkup (Maybe Text.Markdown.Markdown)) arising from a use of ‘toHtml’` in my Handler. It seems like the conversion to HTML isn't going as smoothly as it should. – Ben Jun 21 '18 at 12:25
  • 1
    It doesn't look like `Maybe a` instantiates `ToMarkup`. Perhaps try `fmap toHtml`? – DarthFennec Jun 21 '18 at 16:28

0 Answers0