From 052c99ec12576477cbb422dc5e16d5f0af4a1a22 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 2 Oct 2019 13:14:25 -0400 Subject: [PATCH] Define a typeclass for joining constraints together. --- src/Semantic/Api/Diffs.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Semantic/Api/Diffs.hs b/src/Semantic/Api/Diffs.hs index 40a426022..8831df4e2 100644 --- a/src/Semantic/Api/Diffs.hs +++ b/src/Semantic/Api/Diffs.hs @@ -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