Snippet saved on:
11/20/2024, 3:47:17 PM (raw)
11/20/2024, 3:47:17 PM (raw)
importData.ConstraintDict(..),withDict
importqualifiedData.ByteStringasBS
data DBEntry = DBEntry { siteVariant :: SiteVariant
, html :: BS.ByteString
}
data SiteVariant = A | B
data SiteA = SiteA
data SiteB = SiteB
-- | all sites to be transformed into General
data General = General
classIntoGeneralawhere
fromHTML::DictIntoGenerala->BSByteString->General
instanceIntoGeneralSiteAwhere
fromHTML _ = undefined
-- | Depending on `siteVariant` in `DBEntry`, `fromHTML` is calibrated with Proxy
fromDBEntry::DictIntoGenerala->DBEntry->General
fromDBEntry dict (DBEntry siteVariant html) = case siteVariant of
A -> withDict dict (@SiteA) $ fromHTML html
B -> withDict dict SiteB $ fromHTML html
-- Question: how to make fromDBEntry work?
GHC output
Errors
Output