1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

create a place to pass type name info along, and produce type banes

This commit is contained in:
Ayman Nadeem 2020-01-21 16:11:32 -05:00
parent c5fc76cb25
commit 164672e52a

View File

@ -35,8 +35,9 @@ class GMarshalJSON f where
gmarshal :: (ToJSON a) => f a -> Value
-- Stores meta-data for datatypes
instance GMarshalJSON f => GMarshalJSON (M1 D c f) where
gmarshal = gmarshal . unM1 -- using unM1 instead of pattern-matching on M1 in order to express with function composition
instance (GFields f, Datatype c) => GFields (M1 D c f) where
gfields acc x = gfields ((Text.pack "type", String (Text.pack (datatypeName x))): acc) $ unM1 x
-- gmarshal = gmarshal . unM1 -- using unM1 instead of pattern-matching on M1 in order to express with function composition
-- Fold over S1 product types and pass the result to Aeson objects
instance GFields fields => GFields (C1 c fields) where