I’m compiling a Yesod site I’m building to make sure everything is working when I get this compiler error:
Foundation.hs:164:15:
No instance for (Num (Maybe Size))
arising from the literal `140'
Possible fix: add an instance declaration for (Num (Maybe Size))
In the `gSize' field of a record
In the expression:
GravatarOptions
{gSize = 140, gDefault = Identicon, gForceDefault = False,
gRating = PG}
In an equation for `gs':
gs
= GravatarOptions
{gSize = 140, gDefault = Identicon, gForceDefault = False,
gRating = PG}
After reading the haddock documentation, I know that gSize takes a Maybe Size, and that Size is defined as:
newtype Size = Size Int
If it helps any here’s the function in question.
import Yesod.Goodies.Gravatar
import Data.Text
gravatar :: Text -> Text
gravatar email =
gravatarImg email gs
where
gs = GravatarOptions {
gSize = 140
, gDefault = Identicon
, gForceDefault = False
, gRating = PG
}
I’m not sure where to start looking for a solution, could someone please point me in the right direction? Thank you for your time and consideration.
If
gSizeisMaybe Size, then you need to use one ofMaybeconstructors — you can either useNothingfor no value orJust xfor specified value. In your snippet, it should beJust (Size 140), as in