1{-# language StandaloneKindSignatures #-}
3module Rel8.Type.JSONEncoded ( JSONEncoded(..) ) where
6import Data.Aeson ( FromJSON, ToJSON, parseJSON, toJSON )
7import Data.Aeson.Types ( parseEither )
10import Data.Kind ( Type )
14import Rel8.Type ( DBType(..) )
15import Rel8.Type.Information ( parseTypeInformation )
18-- | A deriving-via helper type for column types that store a Haskell value
19-- using a JSON encoding described by @aeson@'s 'ToJSON' and 'FromJSON' type
21type JSONEncoded :: Type -> Type
22newtype JSONEncoded a = JSONEncoded { fromJSONEncoded :: a }
25instance (FromJSON a, ToJSON a) => DBType (JSONEncoded a) where
26 typeInformation = parseTypeInformation f g typeInformation
28 f = fmap JSONEncoded . parseEither parseJSON
29 g = toJSON . fromJSONEncoded
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list