1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Define a type family to show a sum.

This commit is contained in:
Rob Rix 2019-09-24 12:23:09 -04:00
parent 16fa52194d
commit 986349d6d4
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -11,6 +11,7 @@ import Data.Monoid (Endo(..))
import Data.List.NonEmpty (NonEmpty(..))
import Data.Text as T
import GHC.Generics
import GHC.TypeLits (ErrorMessage(..))
import Source.Loc
import Source.Range
import Source.Source
@ -195,3 +196,12 @@ instance {-# OVERLAPPABLE #-}
=> Element' 'True t (l :+: r) where
prj' (R1 r) = prj' @'True r
prj' _ = Nothing
type family ShowSum t where
ShowSum (l :+: r) = ShowSum' ('Text "{ ") (l :+: r) ':$$: 'Text "}"
ShowSum t = 'Text "{ " ':<>: 'ShowType t ':<>: 'Text " }"
type family ShowSum' p t where
ShowSum' p (l :+: r) = ShowSum' p l ':$$: ShowSum' ('Text ", ") r
ShowSum' p t = p ':<>: 'ShowType t