1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 12:51:52 +03:00

Create Term.Instances module

- This allows us to differentiate between ToJSON instances for
SyntaxTerm
This commit is contained in:
Rick Winfrey 2016-11-01 16:38:28 -05:00
parent b20e4c195f
commit 73dd1ec8a8

11
src/Term/Instances.hs Normal file
View File

@ -0,0 +1,11 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Term.Instances where
import Prologue
import Data.Record
import Term
import Data.Aeson
instance (ToJSON leaf, ToJSON (Record fields)) => ToJSON (SyntaxTerm leaf fields) where
toJSON syntaxTerm = case runCofree syntaxTerm of
(record :< syntax) -> object [ ("record", toJSON record), ("syntax", toJSON syntax) ]