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:
parent
16fa52194d
commit
986349d6d4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user