Closed schnecki closed 5 years ago
in fay we don’t have typeclasses but we have
show :: Automatic a -> String
show = ffi "JSON.stringify(%1)"
so you should be able to show aText
Well I have following data structure (which is shared among the haskell server and js client using yesod).
data PatchResult = PatchCacheOk
| PatchUpdate String (Maybe Text) (Maybe Text) (Maybe Text)
deriving (Typeable, Data)
I would like to be able to build a String
out of the type, so I added Show
to the deriving instances and end up with:
• No instance for (Show Text)
arising from the second field of ‘PatchUpdate’ (type ‘Maybe Text’)
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
There are instances for similar types:
instance Show text-1.2.2.1:Data.Text.Internal.Text
-- Defined in ‘text-1.2.2.1:Data.Text.Show’
instance Show text-1.2.2.1:Data.Text.Internal.Lazy.Text
-- Defined in ‘text-1.2.2.1:Data.Text.Lazy’
• When deriving the instance for (Show PatchResult)
But I see. I can add the instance only for the server side using preprocessor definitions.
#ifdef FAY
deriving (Typeable, Data)
#else
deriving (Show, Typeable, Data)
#endif
Interestingly though, compilation works for data types where I only have a list of String
s:
data ApiResult = ApiResult
{ resultColumnName :: [String]
, resultValue :: [String]
} deriving (Data, Show)
This doesn't seem right to me. Anyways, I know how to work with it. Thx
I see,
I think it would make sense to add the Show instance to Data.Text in fay-base to make this smoother. fay itself will ignore it. This is what we do for Data & Typeable.
Hi, I figured that there is now
Show
instance forData.Text
. Is there a reason for this?Best regards Manuel