1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Define an s-expression format.

This commit is contained in:
Rob Rix 2018-05-11 14:45:17 -04:00
parent 4944fdfe21
commit e427457801

View File

@ -7,14 +7,18 @@ module Serializing.Format
import Algebra.Graph.Class
import Data.ByteString.Builder
import Prologue
import Serializing.DOT
import Serializing.SExpression
data Format input where
DOT :: (Ord vertex, ToGraph graph, ToVertex graph ~ vertex) => Style vertex Builder -> Format graph
Show :: Show input => Format input
DOT :: (Ord vertex, ToGraph graph, ToVertex graph ~ vertex) => Style vertex Builder -> Format graph
SExpression :: (Recursive input, ToSExpression (Base input)) => Format input
Show :: Show input => Format input
runSerialize :: Format input -> input -> Builder
runSerialize (DOT style) graph = serializeDOT style graph
runSerialize SExpression input = serializeSExpression input
runSerialize Show input = stringUtf8 (show input)
-- TODO: it would be kinda neat if we could use pretty-show/hscolour for Show output