1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 17:59:10 +03:00

Define a typeclass for joining constraints together.

This commit is contained in:
Rob Rix 2019-10-02 13:14:25 -04:00
parent a888d6722e
commit 052c99ec12
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -1,4 +1,4 @@
{-# LANGUAGE GADTs, ConstraintKinds, LambdaCase, RankNTypes, UndecidableInstances #-}
{-# LANGUAGE GADTs, ConstraintKinds, LambdaCase, KindSignatures, RankNTypes, TypeOperators, UndecidableInstances, UndecidableSuperClasses #-}
module Semantic.Api.Diffs
( parseDiffBuilder
, DiffOutputFormat(..)
@ -26,6 +26,7 @@ import Data.Blob
import Data.ByteString.Builder
import Data.Graph
import Data.JSON.Fields
import Data.Kind (Constraint)
import Data.Language
import Data.Term
import qualified Data.Text as T
@ -188,6 +189,12 @@ doDiff decorate render blobPair = do
diff <- diffTerms blobPair terms
render diff
class (c1 term, c2 term) => ((c1 :: (* -> *) -> Constraint) & (c2 :: (* -> *) -> Constraint)) (term :: * -> *)
infixl 9 &
instance (c1 term, c2 term) => (c1 & c2) term
diffTerms :: (DiffTerms term, Member Telemetry sig, Carrier sig m, MonadIO m)
=> BlobPair -> Join These (term ann) -> m (DiffFor term ann ann)
diffTerms blobs terms = time "diff" languageTag $ do