Haskell has error messages that often add to the confusion rather than helping to remove it.
I collect some anecdotal examples here.
data EventResponse
= Success
| FailedParse String
deriving (Generic)
Error:
• Can't make a derived instance of ‘Generic EventResponse’:
You need DeriveGeneric to derive an instance for this class
• In the data declaration for ‘EventResponse’
|
79 | deriving (Generic)
meaning
You forgot to put {-# LANGUAGE DeriveGeneric #-}
at the top
/Users/at/dev/tutor/backend/src/Clients.hs:106:25: error:
• Couldn't match expected type ‘Data.ByteString.Builder.Internal.Builder’
with actual type ‘Data.ByteString.Internal.ByteString’
• In the expression: C.toStrict $ encode frontendEvent
In the ‘eventData’ field of a record
In the expression:
ServerEvent
{eventName = Nothing, eventId = Nothing,
eventData = [C.toStrict $ encode frontendEvent]}
Solution eventData = [ fromByteString $ C.toStrict $ encode frontendEvent ]