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

Define an instance of Element' to give a custom type error when a member isn’t found.

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

View File

@ -11,7 +11,7 @@ import Data.Monoid (Endo(..))
import Data.List.NonEmpty (NonEmpty(..))
import Data.Text as T
import GHC.Generics
import GHC.TypeLits (ErrorMessage(..))
import GHC.TypeLits (ErrorMessage(..), TypeError)
import Source.Loc
import Source.Range
import Source.Source
@ -205,3 +205,9 @@ type family ShowSum t where
type family ShowSum' p t where
ShowSum' p (l :+: r) = ShowSum' p l ':$$: ShowSum' ('Text ", ") r
ShowSum' p t = p ':<>: 'ShowType t
instance TypeError
( 'ShowType t ':<>: 'Text " is not in"
':$$: ShowSum u)
=> Element' 'False t u where
prj' _ = Nothing