
4 Feb
2016
4 Feb
'16
5:09 p.m.
If your instance-generating function is defined in an external module, you can use it in GHCi like this: |-- Enable TH > :set -XTemplateHaskell -- Import modules (e.g. Aeson) > import Data.Aeson.TH > import Data.Aeson -- Define the type for which I'm going to generate instances > data X = X {x :: Int} -- Derive the instance Prelude Data.Aeson.TH> data Dummy; deriveJSON defaultOptions ''X -- Check that it works > toJSON (X 1) Object (fromList [("x",Number 1.0)]) | (More about the |data Dummy| trick here: https://www.reddit.com/r/haskelltil/comments/3ghacj/you_can_use_template_has....)