From 73dd1ec8a89df1650e1fb13775dd88e2f75b3ba7 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 1 Nov 2016 16:38:28 -0500 Subject: [PATCH] Create Term.Instances module - This allows us to differentiate between ToJSON instances for SyntaxTerm --- src/Term/Instances.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/Term/Instances.hs diff --git a/src/Term/Instances.hs b/src/Term/Instances.hs new file mode 100644 index 000000000..9c89ae55e --- /dev/null +++ b/src/Term/Instances.hs @@ -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) ]