justin
justin

Reputation: 453

How does one create a MongoDB document with a child array using Yesod's Persistent?

I am attempting to create a Persistent type that is modeled something like:

MyModel
    something Text
    somethingElse [Int]

and I get an error:

Illegal type constructor or class name: `[Int]' When splicing a TH declaration: data MyModel = MyModel {myModelSomething :: Text, myModelSomethingElse :: [Int]} deriving (Show, Read, Eq)

Any help is appreciated.

Upvotes: 3

Views: 486

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31335

This is just a limitation of the Persistent syntax. To get around it, define a type synonym in your Haskell code (before the mkPersist call) like:

type Ints = [Int]

Then replace [Int] with Ints in your declaration, it should work.

Upvotes: 2

Related Questions