module Agda.TypeChecking.Conversion.Errors
(
failConversion, mismatchedProjections, addConversionContext,
nowConversionChecking, cutConversionErrors
, ConversionError(..)
, ConversionZipper(..)
, ConversionErrorContext(..)
, FailedCompareAs(..)
)
where
import Control.Monad.Error.Class
import Control.Monad.Trans.Maybe
import Control.Monad.Except
import Control.Applicative
import Control.DeepSeq
import Control.Monad
import GHC.Generics (Generic)
import qualified Agda.Syntax.Common.Pretty as P
import Agda.Syntax.Internal
import Agda.Syntax.Fixity (Precedence(TopCtx))
import Agda.Syntax.Common
import Agda.TypeChecking.Monad.Constraints
import Agda.TypeChecking.Monad.Statistics
import Agda.TypeChecking.Monad.SizedTypes
import Agda.TypeChecking.Monad.Signature
import Agda.TypeChecking.Monad.MetaVars
import Agda.TypeChecking.Monad.Builtin
import Agda.TypeChecking.Monad.Closure
import Agda.TypeChecking.Monad.Context
import Agda.TypeChecking.Monad.Debug
import Agda.TypeChecking.Monad.Pure
import Agda.TypeChecking.Monad.Base
import {-# SOURCE #-} Agda.TypeChecking.Errors
import Agda.TypeChecking.Conversion.Pure
import Agda.TypeChecking.Substitute
import Agda.TypeChecking.Telescope
import Agda.TypeChecking.Warnings
import Agda.TypeChecking.Records
import Agda.TypeChecking.Pretty
import Agda.TypeChecking.Reduce
import qualified Agda.Utils.Null as Null
import Agda.Utils.Impossible
import Agda.Utils.Functor
import Agda.Utils.Maybe
import Agda.Utils.Monad hiding (guard)
import Agda.Utils.Size
data FailedCompareAs
= FailAsTermsOf Type Type
| FailAsTypes
deriving (Int -> FailedCompareAs -> ShowS
[FailedCompareAs] -> ShowS
FailedCompareAs -> String
(Int -> FailedCompareAs -> ShowS)
-> (FailedCompareAs -> String)
-> ([FailedCompareAs] -> ShowS)
-> Show FailedCompareAs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FailedCompareAs -> ShowS
showsPrec :: Int -> FailedCompareAs -> ShowS
$cshow :: FailedCompareAs -> String
show :: FailedCompareAs -> String
$cshowList :: [FailedCompareAs] -> ShowS
showList :: [FailedCompareAs] -> ShowS
Show, (forall x. FailedCompareAs -> Rep FailedCompareAs x)
-> (forall x. Rep FailedCompareAs x -> FailedCompareAs)
-> Generic FailedCompareAs
forall x. Rep FailedCompareAs x -> FailedCompareAs
forall x. FailedCompareAs -> Rep FailedCompareAs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FailedCompareAs -> Rep FailedCompareAs x
from :: forall x. FailedCompareAs -> Rep FailedCompareAs x
$cto :: forall x. Rep FailedCompareAs x -> FailedCompareAs
to :: forall x. Rep FailedCompareAs x -> FailedCompareAs
Generic)
data ConversionZipper
= ConvStop
| ConvLam
(Dom Type)
(Abs ())
ArgName
ConversionZipper
| ConvDom
(Dom ConversionZipper)
(Abs Type)
(Abs Type)
| ConvCod
(Dom Type)
ArgName
ConversionZipper
| ConvApply
Term
(Abs Type)
(Arg ConversionZipper)
[Elim]
[Elim]
deriving (Int -> ConversionZipper -> ShowS
[ConversionZipper] -> ShowS
ConversionZipper -> String
(Int -> ConversionZipper -> ShowS)
-> (ConversionZipper -> String)
-> ([ConversionZipper] -> ShowS)
-> Show ConversionZipper
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConversionZipper -> ShowS
showsPrec :: Int -> ConversionZipper -> ShowS
$cshow :: ConversionZipper -> String
show :: ConversionZipper -> String
$cshowList :: [ConversionZipper] -> ShowS
showList :: [ConversionZipper] -> ShowS
Show, (forall x. ConversionZipper -> Rep ConversionZipper x)
-> (forall x. Rep ConversionZipper x -> ConversionZipper)
-> Generic ConversionZipper
forall x. Rep ConversionZipper x -> ConversionZipper
forall x. ConversionZipper -> Rep ConversionZipper x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConversionZipper -> Rep ConversionZipper x
from :: forall x. ConversionZipper -> Rep ConversionZipper x
$cto :: forall x. Rep ConversionZipper x -> ConversionZipper
to :: forall x. Rep ConversionZipper x -> ConversionZipper
Generic)
data WhyUnequalTypes
= forall a. (NFData a, Verbalize a) => UnequalDomain a a
| UnequalHiding Hiding Hiding
data HeadMismatch
= HdmExtLam QName QName
| HdmTypes WhyUnequalTypes
| HdmVars Int Int
| HdmVarSpine Int (Closure (Elims, Elims))
| HdmVarDef
| HdmDefVar
| HdmVarCon
| HdmConVar
deriving (Int -> HeadMismatch -> ShowS
[HeadMismatch] -> ShowS
HeadMismatch -> String
(Int -> HeadMismatch -> ShowS)
-> (HeadMismatch -> String)
-> ([HeadMismatch] -> ShowS)
-> Show HeadMismatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HeadMismatch -> ShowS
showsPrec :: Int -> HeadMismatch -> ShowS
$cshow :: HeadMismatch -> String
show :: HeadMismatch -> String
$cshowList :: [HeadMismatch] -> ShowS
showList :: [HeadMismatch] -> ShowS
Show, (forall x. HeadMismatch -> Rep HeadMismatch x)
-> (forall x. Rep HeadMismatch x -> HeadMismatch)
-> Generic HeadMismatch
forall x. Rep HeadMismatch x -> HeadMismatch
forall x. HeadMismatch -> Rep HeadMismatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HeadMismatch -> Rep HeadMismatch x
from :: forall x. HeadMismatch -> Rep HeadMismatch x
$cto :: forall x. Rep HeadMismatch x -> HeadMismatch
to :: forall x. Rep HeadMismatch x -> HeadMismatch
Generic)
data HereOrThere
= Here
| There
deriving (Int -> HereOrThere -> ShowS
[HereOrThere] -> ShowS
HereOrThere -> String
(Int -> HereOrThere -> ShowS)
-> (HereOrThere -> String)
-> ([HereOrThere] -> ShowS)
-> Show HereOrThere
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HereOrThere -> ShowS
showsPrec :: Int -> HereOrThere -> ShowS
$cshow :: HereOrThere -> String
show :: HereOrThere -> String
$cshowList :: [HereOrThere] -> ShowS
showList :: [HereOrThere] -> ShowS
Show, (forall x. HereOrThere -> Rep HereOrThere x)
-> (forall x. Rep HereOrThere x -> HereOrThere)
-> Generic HereOrThere
forall x. Rep HereOrThere x -> HereOrThere
forall x. HereOrThere -> Rep HereOrThere x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HereOrThere -> Rep HereOrThere x
from :: forall x. HereOrThere -> Rep HereOrThere x
$cto :: forall x. Rep HereOrThere x -> HereOrThere
to :: forall x. Rep HereOrThere x -> HereOrThere
Generic)
data ConversionErrorContext
= Floating ConversionZipper
| Finished HereOrThere (Maybe HeadMismatch)
deriving (Int -> ConversionErrorContext -> ShowS
[ConversionErrorContext] -> ShowS
ConversionErrorContext -> String
(Int -> ConversionErrorContext -> ShowS)
-> (ConversionErrorContext -> String)
-> ([ConversionErrorContext] -> ShowS)
-> Show ConversionErrorContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConversionErrorContext -> ShowS
showsPrec :: Int -> ConversionErrorContext -> ShowS
$cshow :: ConversionErrorContext -> String
show :: ConversionErrorContext -> String
$cshowList :: [ConversionErrorContext] -> ShowS
showList :: [ConversionErrorContext] -> ShowS
Show, (forall x. ConversionErrorContext -> Rep ConversionErrorContext x)
-> (forall x.
Rep ConversionErrorContext x -> ConversionErrorContext)
-> Generic ConversionErrorContext
forall x. Rep ConversionErrorContext x -> ConversionErrorContext
forall x. ConversionErrorContext -> Rep ConversionErrorContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConversionErrorContext -> Rep ConversionErrorContext x
from :: forall x. ConversionErrorContext -> Rep ConversionErrorContext x
$cto :: forall x. Rep ConversionErrorContext x -> ConversionErrorContext
to :: forall x. Rep ConversionErrorContext x -> ConversionErrorContext
Generic)
data ConversionError = ConversionError
{ ConversionError -> Comparison
convErrCmp :: Comparison
, ConversionError -> FailedCompareAs
convErrTys :: FailedCompareAs
, ConversionError -> Term
convErrLhs :: Term
, ConversionError -> Term
convErrRhs :: Term
, ConversionError -> ConversionErrorContext
convErrCtx :: ConversionErrorContext
}
deriving (Int -> ConversionError -> ShowS
[ConversionError] -> ShowS
ConversionError -> String
(Int -> ConversionError -> ShowS)
-> (ConversionError -> String)
-> ([ConversionError] -> ShowS)
-> Show ConversionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConversionError -> ShowS
showsPrec :: Int -> ConversionError -> ShowS
$cshow :: ConversionError -> String
show :: ConversionError -> String
$cshowList :: [ConversionError] -> ShowS
showList :: [ConversionError] -> ShowS
Show, (forall x. ConversionError -> Rep ConversionError x)
-> (forall x. Rep ConversionError x -> ConversionError)
-> Generic ConversionError
forall x. Rep ConversionError x -> ConversionError
forall x. ConversionError -> Rep ConversionError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConversionError -> Rep ConversionError x
from :: forall x. ConversionError -> Rep ConversionError x
$cto :: forall x. Rep ConversionError x -> ConversionError
to :: forall x. Rep ConversionError x -> ConversionError
Generic)
instance Show WhyUnequalTypes where
show :: WhyUnequalTypes -> String
show = String -> WhyUnequalTypes -> String
forall a b. a -> b -> a
const String
"<WhyUnequalTypes>"
instance NFData WhyUnequalTypes where
rnf :: WhyUnequalTypes -> ()
rnf = \case
UnequalDomain a
a a
b -> (a, a) -> ()
forall a. NFData a => a -> ()
rnf (a
a, a
b)
UnequalHiding Hiding
a Hiding
b -> (Hiding, Hiding) -> ()
forall a. NFData a => a -> ()
rnf (Hiding
a, Hiding
b)
instance NFData ConversionErrorContext
instance NFData ConversionZipper
instance NFData ConversionError
instance NFData FailedCompareAs
instance NFData HeadMismatch
instance NFData HereOrThere
failConversion
:: (MonadTCError m, HasBuiltins m)
=> Comparison
-> Term
-> Term
-> CompareAs
-> m a
failConversion :: forall (m :: * -> *) a.
(MonadTCError m, HasBuiltins m) =>
Comparison -> Term -> Term -> CompareAs -> m a
failConversion Comparison
cmp Term
l Term
r CompareAs
cas = do
as <- case CompareAs
cas of
CompareAs
AsTypes -> FailedCompareAs -> m FailedCompareAs
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FailedCompareAs
FailAsTypes
AsTermsOf Type
t -> FailedCompareAs -> m FailedCompareAs
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FailedCompareAs -> m FailedCompareAs)
-> FailedCompareAs -> m FailedCompareAs
forall a b. (a -> b) -> a -> b
$ Type -> Type -> FailedCompareAs
FailAsTermsOf Type
t Type
t
CompareAs
AsSizes -> do
t <- m Type
forall (m :: * -> *).
(HasBuiltins m, MonadTCEnv m, ReadTCState m) =>
m Type
sizeType
pure $ FailAsTermsOf t t
typeError $ ConversionError_ ConversionError
{ convErrTys = as
, convErrRhs = r
, convErrLhs = l
, convErrCmp = cmp
, convErrCtx = Floating ConvStop
}
addConversionContext
:: (MonadTCError m, HasBuiltins m)
=> (ConversionZipper -> ConversionZipper)
-> m a
-> m a
addConversionContext :: forall (m :: * -> *) a.
(MonadTCError m, HasBuiltins m) =>
(ConversionZipper -> ConversionZipper) -> m a -> m a
addConversionContext ConversionZipper -> ConversionZipper
ext m a
cont = m a
cont m a -> (TCErr -> m a) -> m a
forall a. m a -> (TCErr -> m a) -> m a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
`catchError` \case
TypeError CallStack
loc TCState
st cl' :: Closure TypeError
cl'@Closure{ clValue :: forall a. Closure a -> a
clValue = ConversionError_ conv :: ConversionError
conv@ConversionError{ convErrCtx :: ConversionError -> ConversionErrorContext
convErrCtx = Floating ConversionZipper
ctx } } -> do
let
zip :: ConversionZipper
zip = ConversionZipper -> ConversionZipper
ext ConversionZipper
ctx
old_c :: Maybe (Closure Call)
old_c = TCEnv -> Maybe (Closure Call)
envCall (Closure TypeError -> TCEnv
forall a. Closure a -> TCEnv
clEnv Closure TypeError
cl')
cl <- TypeError -> m (Closure TypeError)
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m) =>
a -> m (Closure a)
buildClosure (TypeError -> m (Closure TypeError))
-> TypeError -> m (Closure TypeError)
forall a b. (a -> b) -> a -> b
$ ConversionError -> TypeError
ConversionError_ (ConversionError -> TypeError) -> ConversionError -> TypeError
forall a b. (a -> b) -> a -> b
$! ConversionError
conv { convErrCtx = Floating zip }
zip `seq` old_c `seq` throwError $ TypeError loc st cl
{ clEnv = (clEnv cl) { envCall = old_c }
}
TCErr
err -> TCErr -> m a
forall a. TCErr -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError TCErr
err
nowConversionChecking
:: forall m a. (MonadTCError m, HasBuiltins m)
=> Comparison
-> Term
-> Term
-> CompareAs
-> m a
-> m a
nowConversionChecking :: forall (m :: * -> *) a.
(MonadTCError m, HasBuiltins m) =>
Comparison -> Term -> Term -> CompareAs -> m a -> m a
nowConversionChecking Comparison
cmp Term
l Term
r CompareAs
cas m a
cont = m a
cont m a -> (TCErr -> m a) -> m a
forall a. m a -> (TCErr -> m a) -> m a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
`catchError` \case
TypeError CallStack
loc TCState
st Closure{ clValue :: forall a. Closure a -> a
clValue = TypeError
err }
| ConversionError_ ConversionError{ convErrCtx :: ConversionError -> ConversionErrorContext
convErrCtx = Floating{} } <- TypeError
err
-> Comparison -> Term -> Term -> CompareAs -> m a
forall (m :: * -> *) a.
(MonadTCError m, HasBuiltins m) =>
Comparison -> Term -> Term -> CompareAs -> m a
failConversion Comparison
cmp Term
l Term
r CompareAs
cas
TCErr
err -> TCErr -> m a
forall a. TCErr -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError TCErr
err
cutConversionErrors
:: (MonadPretty m, MonadError TCErr m)
=> m a -> m a
cutConversionErrors :: forall (m :: * -> *) a.
(MonadPretty m, MonadError TCErr m) =>
m a -> m a
cutConversionErrors m a
cont = m a
cont m a -> (TCErr -> m a) -> m a
forall a. m a -> (TCErr -> m a) -> m a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
`catchError` \case
TypeError CallStack
loc TCState
st cl :: Closure TypeError
cl@Closure{ clValue :: forall a. Closure a -> a
clValue = ConversionError_ ConversionError
conv } -> Closure TypeError -> (TypeError -> m a) -> m a
forall (m :: * -> *) c a b.
(MonadTCEnv m, ReadTCState m, LensClosure c a) =>
c -> (a -> m b) -> m b
enterClosure Closure TypeError
cl \TypeError
_ ->
ConversionError -> (ConversionError -> m a) -> m a
forall (m :: * -> *) z.
PureTCM m =>
ConversionError -> (ConversionError -> m z) -> m z
flattenConversionError ConversionError
conv \conv :: ConversionError
conv@ConversionError{convErrLhs :: ConversionError -> Term
convErrLhs = Term
lhs, convErrRhs :: ConversionError -> Term
convErrRhs = Term
rhs} -> do
cl <- () -> m (Closure ())
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m) =>
a -> m (Closure a)
buildClosure ()
throwError $ TypeError loc st $ cl $> case (lhs, rhs) of
(Sort MetaS{} , Term
t ) -> Type -> TypeError
ShouldBeASort (Type -> TypeError) -> Type -> TypeError
forall a b. (a -> b) -> a -> b
$ Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
forall a. HasCallStack => a
__IMPOSSIBLE__ Term
t
(Term
s , Sort MetaS{} ) -> Type -> TypeError
ShouldBeASort (Type -> TypeError) -> Type -> TypeError
forall a b. (a -> b) -> a -> b
$ Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
forall a. HasCallStack => a
__IMPOSSIBLE__ Term
s
(Sort DefS{} , Term
t ) -> Type -> TypeError
ShouldBeASort (Type -> TypeError) -> Type -> TypeError
forall a b. (a -> b) -> a -> b
$ Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
forall a. HasCallStack => a
__IMPOSSIBLE__ Term
t
(Term
s , Sort DefS{} ) -> Type -> TypeError
ShouldBeASort (Type -> TypeError) -> Type -> TypeError
forall a b. (a -> b) -> a -> b
$ Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
forall a. HasCallStack => a
__IMPOSSIBLE__ Term
s
(Term, Term)
_ -> ConversionError -> TypeError
ConversionError_ ConversionError
conv
TCErr
err -> TCErr -> m a
forall a. TCErr -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError TCErr
err
type ConversionProblem = (FailedCompareAs, Term, Term)
eliminateLhsRhs
:: forall m. PureTCM m
=> Type -> Term -> Elims
-> Type -> Term -> Elims
-> m ConversionProblem
eliminateLhsRhs :: forall (m :: * -> *).
PureTCM m =>
Type
-> Term -> [Elim] -> Type -> Term -> [Elim] -> m ConversionProblem
eliminateLhsRhs Type
t1 Term
v1 [Elim]
l_es Type
t2 Term
v2 [Elim]
r_es =
let
blank :: Term -> Term
blank Term
t
| Term -> Int
forall a. TermSize a => a -> Int
termSize Term
t Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
15 = Term -> Term
DontCare Term
t
| Bool
otherwise = Term
t
in
ConversionProblem
-> MaybeT m ConversionProblem -> m ConversionProblem
forall (m :: * -> *) a. Monad m => a -> MaybeT m a -> m a
fromMaybeT (Type -> Type -> FailedCompareAs
FailAsTermsOf Type
t1 Type
t2, Term
v1, Term
v2) do
t1 <- MaybeT m Empty -> Term -> Type -> [Elim] -> MaybeT m Type
forall (m :: * -> *).
PureTCM m =>
m Empty -> Term -> Type -> [Elim] -> m Type
eliminateType MaybeT m Empty
forall a. MaybeT m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero Term
v1 Type
t1 [Elim]
l_es
t2 <- eliminateType mzero v2 t2 r_es
pure
( FailAsTermsOf t1 t2
, v1 `applyE` map (fmap blank) l_es
, v2 `applyE` map (fmap blank) r_es
)
mismatchedProjections
:: (MonadError TCErr m, PureTCM m)
=> Type
-> Term
-> Elims
-> Type
-> Term
-> Elims
-> m a
mismatchedProjections :: forall (m :: * -> *) a.
(MonadError TCErr m, PureTCM m) =>
Type -> Term -> [Elim] -> Type -> Term -> [Elim] -> m a
mismatchedProjections Type
t1 Term
v1 [Elim]
e1 Type
t2 Term
v2 [Elim]
e2 = do
(tys, lhs, rhs) <- Type
-> Term -> [Elim] -> Type -> Term -> [Elim] -> m ConversionProblem
forall (m :: * -> *).
PureTCM m =>
Type
-> Term -> [Elim] -> Type -> Term -> [Elim] -> m ConversionProblem
eliminateLhsRhs Type
t1 Term
v1 [Elim]
e1 Type
t2 Term
v2 [Elim]
e2
typeError $ ConversionError_ $ ConversionError CmpEq tys lhs rhs (Floating ConvStop)
headMismatch :: forall m. (PureTCM m, MonadPlus m) => Term -> Term -> m HeadMismatch
headMismatch :: forall (m :: * -> *).
(PureTCM m, MonadPlus m) =>
Term -> Term -> m HeadMismatch
headMismatch Var{} Def{} = HeadMismatch -> m HeadMismatch
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HeadMismatch
HdmVarDef
headMismatch Def{} Var{} = HeadMismatch -> m HeadMismatch
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HeadMismatch
HdmDefVar
headMismatch Var{} Con{} = HeadMismatch -> m HeadMismatch
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HeadMismatch
HdmVarCon
headMismatch Con{} Var{} = HeadMismatch -> m HeadMismatch
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HeadMismatch
HdmConVar
headMismatch (Var Int
i [Elim]
xs) (Var Int
j [Elim]
ys)
| Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
j = Int -> Closure ([Elim], [Elim]) -> HeadMismatch
HdmVarSpine Int
i (Closure ([Elim], [Elim]) -> HeadMismatch)
-> m (Closure ([Elim], [Elim])) -> m HeadMismatch
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([Elim], [Elim]) -> m (Closure ([Elim], [Elim]))
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m) =>
a -> m (Closure a)
buildClosure ([Elim]
xs, [Elim]
ys)
headMismatch (Pi Dom Type
d1 Abs Type
_) (Pi Dom Type
d2 Abs Type
_) =
let
hint :: (a -> a -> b) -> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint :: forall a b.
(a -> a -> b)
-> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint a -> a -> b
k forall x y. Dom' x y -> a
g a -> a -> Bool
c = a -> a -> b
k (Dom Type -> a
forall x y. Dom' x y -> a
g Dom Type
d1) (Dom Type -> a
forall x y. Dom' x y -> a
g Dom Type
d2) b -> m () -> m b
forall a b. a -> m b -> m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Bool -> m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (a -> a -> Bool
c (Dom Type -> a
forall x y. Dom' x y -> a
g Dom Type
d1) (Dom Type -> a
forall x y. Dom' x y -> a
g Dom Type
d2)))
in WhyUnequalTypes -> HeadMismatch
HdmTypes (WhyUnequalTypes -> HeadMismatch)
-> m WhyUnequalTypes -> m HeadMismatch
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [m WhyUnequalTypes] -> m WhyUnequalTypes
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
[ (Relevance -> Relevance -> WhyUnequalTypes)
-> (forall x y. Dom' x y -> Relevance)
-> (Relevance -> Relevance -> Bool)
-> m WhyUnequalTypes
forall a b.
(a -> a -> b)
-> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint Relevance -> Relevance -> WhyUnequalTypes
forall a. (NFData a, Verbalize a) => a -> a -> WhyUnequalTypes
UnequalDomain Dom' x y -> Relevance
forall a. LensRelevance a => a -> Relevance
forall x y. Dom' x y -> Relevance
getRelevance Relevance -> Relevance -> Bool
sameRelevance
, (Quantity -> Quantity -> WhyUnequalTypes)
-> (forall x y. Dom' x y -> Quantity)
-> (Quantity -> Quantity -> Bool)
-> m WhyUnequalTypes
forall a b.
(a -> a -> b)
-> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint Quantity -> Quantity -> WhyUnequalTypes
forall a. (NFData a, Verbalize a) => a -> a -> WhyUnequalTypes
UnequalDomain Dom' x y -> Quantity
forall a. LensQuantity a => a -> Quantity
forall x y. Dom' x y -> Quantity
getQuantity Quantity -> Quantity -> Bool
sameQuantity
, (PolarityModality -> PolarityModality -> WhyUnequalTypes)
-> (forall x y. Dom' x y -> PolarityModality)
-> (PolarityModality -> PolarityModality -> Bool)
-> m WhyUnequalTypes
forall a b.
(a -> a -> b)
-> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint PolarityModality -> PolarityModality -> WhyUnequalTypes
forall a. (NFData a, Verbalize a) => a -> a -> WhyUnequalTypes
UnequalDomain Dom' x y -> PolarityModality
forall a. LensModalPolarity a => a -> PolarityModality
forall x y. Dom' x y -> PolarityModality
getModalPolarity PolarityModality -> PolarityModality -> Bool
samePolarity
, (Cohesion -> Cohesion -> WhyUnequalTypes)
-> (forall x y. Dom' x y -> Cohesion)
-> (Cohesion -> Cohesion -> Bool)
-> m WhyUnequalTypes
forall a b.
(a -> a -> b)
-> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint Cohesion -> Cohesion -> WhyUnequalTypes
forall a. (NFData a, Verbalize a) => a -> a -> WhyUnequalTypes
UnequalDomain Dom' x y -> Cohesion
forall a. LensCohesion a => a -> Cohesion
forall x y. Dom' x y -> Cohesion
getCohesion Cohesion -> Cohesion -> Bool
sameCohesion
, (Hiding -> Hiding -> WhyUnequalTypes)
-> (forall x y. Dom' x y -> Hiding)
-> (Hiding -> Hiding -> Bool)
-> m WhyUnequalTypes
forall a b.
(a -> a -> b)
-> (forall x y. Dom' x y -> a) -> (a -> a -> Bool) -> m b
hint Hiding -> Hiding -> WhyUnequalTypes
UnequalHiding Dom' x y -> Hiding
forall a. LensHiding a => a -> Hiding
forall x y. Dom' x y -> Hiding
getHiding Hiding -> Hiding -> Bool
forall a b. (LensHiding a, LensHiding b) => a -> b -> Bool
sameHiding
]
headMismatch (Def QName
i [Elim]
_) (Def QName
j [Elim]
_)
| QName -> Bool
isExtendedLambdaName QName
i, QName -> Bool
isExtendedLambdaName QName
j = HeadMismatch -> m HeadMismatch
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (HeadMismatch -> m HeadMismatch) -> HeadMismatch -> m HeadMismatch
forall a b. (a -> b) -> a -> b
$ QName -> QName -> HeadMismatch
HdmExtLam QName
i QName
j
headMismatch (Var Int
i [Elim]
xs) (Var Int
j [Elim]
ys) = HeadMismatch -> m HeadMismatch
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (HeadMismatch -> m HeadMismatch) -> HeadMismatch -> m HeadMismatch
forall a b. (a -> b) -> a -> b
$ Int -> Int -> HeadMismatch
HdmVars Int
i Int
j
headMismatch Term
lhs Term
rhs = do
String -> Int -> TCMT IO Doc -> m ()
forall (m :: * -> *).
MonadDebug m =>
String -> Int -> TCMT IO Doc -> m ()
reportSDoc String
"tc.conv.ctx" Int
30 (TCMT IO Doc -> m ()) -> TCMT IO Doc -> m ()
forall a b. (a -> b) -> a -> b
$ [TCMT IO Doc] -> TCMT IO Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ TCMT IO Doc
"headMismatch no match"
, TCMT IO Doc
" lhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Term -> m Doc
prettyTCM Term
lhs
, TCMT IO Doc
" rhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Term -> m Doc
prettyTCM Term
rhs
]
m HeadMismatch
forall a. m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
flattenConversionError :: forall m z. PureTCM m => ConversionError -> (ConversionError -> m z) -> m z
flattenConversionError :: forall (m :: * -> *) z.
PureTCM m =>
ConversionError -> (ConversionError -> m z) -> m z
flattenConversionError e :: ConversionError
e@ConversionError{convErrCtx :: ConversionError -> ConversionErrorContext
convErrCtx = Finished{}} ConversionError -> m z
cont = ConversionError -> m z
cont ConversionError
e
flattenConversionError (ConversionError Comparison
cmp FailedCompareAs
tys Term
lhs Term
rhs (Floating ConversionZipper
ctx)) ConversionError -> m z
cont =
do
String -> Int -> TCMT IO Doc -> m ()
forall (m :: * -> *).
MonadDebug m =>
String -> Int -> TCMT IO Doc -> m ()
reportSDoc String
"tc.conv.ctx" Int
30 (TCMT IO Doc -> m ()) -> TCMT IO Doc -> m ()
forall a b. (a -> b) -> a -> b
$ [TCMT IO Doc] -> TCMT IO Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ TCMT IO Doc
"unwinding conversion zipper:"
, TCMT IO Doc
" env:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> (Telescope -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Telescope -> m Doc
prettyTCM (Telescope -> TCMT IO Doc) -> TCMT IO Telescope -> TCMT IO Doc
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TCMT IO Telescope
forall (m :: * -> *). MonadTCEnv m => m Telescope
getContextTelescope)
, TCMT IO Doc
" tys:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> FailedCompareAs -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => FailedCompareAs -> m Doc
prettyTCM FailedCompareAs
tys
, TCMT IO Doc
" lhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Term -> m Doc
prettyTCM Term
lhs
, TCMT IO Doc
" rhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Term -> m Doc
prettyTCM Term
rhs
, TCMT IO Doc
" zip:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> ConversionZipper -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => ConversionZipper -> m Doc
prettyTCM ConversionZipper
ctx
]
let
k :: HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
k HereOrThere
ht Maybe HeadMismatch
hdm (FailedCompareAs
tys, Term
lhs, Term
rhs) = do
String -> Int -> TCMT IO Doc -> m ()
forall (m :: * -> *).
MonadDebug m =>
String -> Int -> TCMT IO Doc -> m ()
reportSDoc String
"tc.conv.ctx" Int
30 (TCMT IO Doc -> m ()) -> TCMT IO Doc -> m ()
forall a b. (a -> b) -> a -> b
$ [TCMT IO Doc] -> TCMT IO Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ TCMT IO Doc
"conversion zipper unwound:"
, TCMT IO Doc
" env:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> (Telescope -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Telescope -> m Doc
prettyTCM (Telescope -> TCMT IO Doc) -> TCMT IO Telescope -> TCMT IO Doc
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TCMT IO Telescope
forall (m :: * -> *). MonadTCEnv m => m Telescope
getContextTelescope)
, TCMT IO Doc
" tys:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> FailedCompareAs -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => FailedCompareAs -> m Doc
prettyTCM FailedCompareAs
tys
, TCMT IO Doc
" lhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Term -> m Doc
prettyTCM Term
lhs
, TCMT IO Doc
" rhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Term -> m Doc
prettyTCM Term
rhs
, TCMT IO Doc
" hdm:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> String -> TCMT IO Doc
forall (m :: * -> *). Applicative m => String -> m Doc
text (Maybe HeadMismatch -> String
forall a. Show a => a -> String
show Maybe HeadMismatch
hdm)
]
ConversionError -> m z
cont (Comparison
-> FailedCompareAs
-> Term
-> Term
-> ConversionErrorContext
-> ConversionError
ConversionError Comparison
cmp FailedCompareAs
tys Term
lhs Term
rhs (HereOrThere -> Maybe HeadMismatch -> ConversionErrorContext
Finished HereOrThere
ht Maybe HeadMismatch
hdm))
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
k ConversionZipper
ctx
where
done :: forall z. (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z) -> m z
done :: forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
done HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok = do
String -> Int -> TCMT IO Doc -> m ()
forall (m :: * -> *).
MonadDebug m =>
String -> Int -> TCMT IO Doc -> m ()
reportSDoc String
"tc.conv.ctx" Int
30 (TCMT IO Doc -> m ()) -> TCMT IO Doc -> m ()
forall a b. (a -> b) -> a -> b
$ [TCMT IO Doc] -> TCMT IO Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ TCMT IO Doc
"reached center of conversion zipper:"
, TCMT IO Doc
" env:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> (Telescope -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Telescope -> m Doc
prettyTCM (Telescope -> TCMT IO Doc) -> TCMT IO Telescope -> TCMT IO Doc
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TCMT IO Telescope
forall (m :: * -> *). MonadTCEnv m => m Telescope
getContextTelescope)
, TCMT IO Doc
" tys:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> FailedCompareAs -> TCMT IO Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => FailedCompareAs -> m Doc
prettyTCM FailedCompareAs
tys
, TCMT IO Doc
" lhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Term
lhs
, TCMT IO Doc
" rhs:" TCMT IO Doc -> TCMT IO Doc -> TCMT IO Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> TCMT IO Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Term
rhs
]
hdm <- MaybeT m HeadMismatch -> m (Maybe HeadMismatch)
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT (MaybeT m HeadMismatch -> m (Maybe HeadMismatch))
-> MaybeT m HeadMismatch -> m (Maybe HeadMismatch)
forall a b. (a -> b) -> a -> b
$ Term -> Term -> MaybeT m HeadMismatch
forall (m :: * -> *).
(PureTCM m, MonadPlus m) =>
Term -> Term -> m HeadMismatch
headMismatch Term
lhs Term
rhs
ok Here hdm (tys, lhs, rhs)
seek
:: forall z. (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper
-> m z
seek :: forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok ConversionZipper
zip = case ConversionZipper
zip of
ConversionZipper
ConvStop -> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
done HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok
ConvApply Term
hd Abs Type
ty (Arg ArgInfo
info ConversionZipper
rest) [Elim]
l_es [Elim]
r_es
| ArgInfo -> Bool
forall a. LensHiding a => a -> Bool
visible ArgInfo
info -> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok ConversionZipper
rest
| Con ConHead
c ConInfo
o [Elim]
_ <- Term
hd, IsRecord{} <- ConHead -> DataOrRecord' PatternOrCopattern
conDataRecord ConHead
c -> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok ConversionZipper
rest
ConvLam Dom Type
dom Abs ()
ty String
name ConversionZipper
rest -> (String, Dom Type) -> m z -> m z
forall b (m :: * -> *) a.
(AddContext b, MonadAddContext m) =>
b -> m a -> m a
forall (m :: * -> *) a.
MonadAddContext m =>
(String, Dom Type) -> m a -> m a
addContext (String
name, Dom Type
dom) (m z -> m z) -> m z -> m z
forall a b. (a -> b) -> a -> b
$ (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok ConversionZipper
rest
ConvCod Dom Type
dom String
name ConversionZipper
rest -> (String, Dom Type) -> m z -> m z
forall b (m :: * -> *) a.
(AddContext b, MonadAddContext m) =>
b -> m a -> m a
forall (m :: * -> *) a.
MonadAddContext m =>
(String, Dom Type) -> m a -> m a
addContext (String
name, Dom Type
dom) (m z -> m z) -> m z -> m z
forall a b. (a -> b) -> a -> b
$ (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok ConversionZipper
rest
ConvDom Dom ConversionZipper
dom Abs Type
c1 Abs Type
c2 -> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> ConversionZipper -> m z
seek HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok (Dom ConversionZipper -> ConversionZipper
forall t e. Dom' t e -> e
unDom Dom ConversionZipper
dom)
ConversionZipper
_ -> ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify ConversionZipper
zip (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok HereOrThere
Here) HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok
reify
:: forall z. ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify :: forall z.
ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify ConversionZipper
ctx Maybe HeadMismatch -> ConversionProblem -> m z
err HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok = case ConversionZipper
ctx of
ConversionZipper
ConvStop -> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
(HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
done HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok
ConvCod Dom Type
dom String
name ConversionZipper
rest -> ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify ConversionZipper
rest (\Maybe HeadMismatch
hdm ConversionProblem
prob -> (String, Dom Type) -> m z -> m z
forall b (m :: * -> *) a.
(AddContext b, MonadAddContext m) =>
b -> m a -> m a
forall (m :: * -> *) a.
MonadAddContext m =>
(String, Dom Type) -> m a -> m a
addContext (String
name, Dom Type
dom) (m z -> m z) -> m z -> m z
forall a b. (a -> b) -> a -> b
$ Maybe HeadMismatch -> ConversionProblem -> m z
err Maybe HeadMismatch
hdm ConversionProblem
prob)
\HereOrThere
_ Maybe HeadMismatch
hdm (FailedCompareAs
_, Term
lhs, Term
rhs) -> HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok HereOrThere
There Maybe HeadMismatch
hdm
( FailedCompareAs
FailAsTypes
, Dom Type -> Abs Type -> Term
Pi Dom Type
dom (String -> Type -> Abs Type
forall a. (Subst a, Free a) => String -> a -> Abs a
mkAbs String
name (Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
HasCallStack => Sort' Term
__DUMMY_SORT__ Term
lhs))
, Dom Type -> Abs Type -> Term
Pi Dom Type
dom (String -> Type -> Abs Type
forall a. (Subst a, Free a) => String -> a -> Abs a
mkAbs String
name (Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
HasCallStack => Sort' Term
__DUMMY_SORT__ Term
rhs))
)
ConvLam Dom Type
dom Abs ()
ty String
name ConversionZipper
rest -> ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify ConversionZipper
rest
(\Maybe HeadMismatch
hdm ConversionProblem
prob -> (String, Dom Type) -> m z -> m z
forall b (m :: * -> *) a.
(AddContext b, MonadAddContext m) =>
b -> m a -> m a
forall (m :: * -> *) a.
MonadAddContext m =>
(String, Dom Type) -> m a -> m a
addContext (String
name, Dom Type
dom) (m z -> m z) -> m z -> m z
forall a b. (a -> b) -> a -> b
$ Maybe HeadMismatch -> ConversionProblem -> m z
err Maybe HeadMismatch
hdm ConversionProblem
prob)
\HereOrThere
ht Maybe HeadMismatch
hdm (FailedCompareAs
cmp, Term
lhs, Term
rhs) -> HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok HereOrThere
There Maybe HeadMismatch
hdm
( case FailedCompareAs
cmp of
FailedCompareAs
FailAsTypes -> FailedCompareAs
FailAsTypes
FailAsTermsOf Type
a Type
b -> Type -> Type -> FailedCompareAs
FailAsTermsOf
(Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El (Dom Term -> Sort' Term -> Abs (Sort' Term) -> Sort' Term
piSort (Type -> Term
forall t a. Type'' t a -> a
unEl (Type -> Term) -> Dom Type -> Dom Term
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dom Type
dom) (Dom Type -> Sort' Term
forall a. LensSort a => a -> Sort' Term
getSort Dom Type
dom) (Type -> Sort' Term
forall a. LensSort a => a -> Sort' Term
getSort Type
a Sort' Term -> Abs () -> Abs (Sort' Term)
forall a b. a -> Abs b -> Abs a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Abs ()
ty)) (Dom Type -> Abs Type -> Term
Pi Dom Type
dom (Type
a Type -> Abs () -> Abs Type
forall a b. a -> Abs b -> Abs a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Abs ()
ty)))
(Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El (Dom Term -> Sort' Term -> Abs (Sort' Term) -> Sort' Term
piSort (Type -> Term
forall t a. Type'' t a -> a
unEl (Type -> Term) -> Dom Type -> Dom Term
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dom Type
dom) (Dom Type -> Sort' Term
forall a. LensSort a => a -> Sort' Term
getSort Dom Type
dom) (Type -> Sort' Term
forall a. LensSort a => a -> Sort' Term
getSort Type
b Sort' Term -> Abs () -> Abs (Sort' Term)
forall a b. a -> Abs b -> Abs a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Abs ()
ty)) (Dom Type -> Abs Type -> Term
Pi Dom Type
dom (Type
b Type -> Abs () -> Abs Type
forall a b. a -> Abs b -> Abs a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Abs ()
ty)))
, ArgInfo -> Abs Term -> Term
Lam (Dom Type -> ArgInfo
forall t e. Dom' t e -> ArgInfo
domInfo Dom Type
dom) (String -> Term -> Abs Term
forall a. (Subst a, Free a) => String -> a -> Abs a
mkAbs String
name Term
lhs), ArgInfo -> Abs Term -> Term
Lam (Dom Type -> ArgInfo
forall t e. Dom' t e -> ArgInfo
domInfo Dom Type
dom) (String -> Term -> Abs Term
forall a. (Subst a, Free a) => String -> a -> Abs a
mkAbs String
name Term
rhs)
)
ConvDom Dom ConversionZipper
dom Abs Type
c1 Abs Type
c2 -> ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify (Dom ConversionZipper -> ConversionZipper
forall t e. Dom' t e -> e
unDom Dom ConversionZipper
dom) Maybe HeadMismatch -> ConversionProblem -> m z
err \HereOrThere
_ Maybe HeadMismatch
hdm (FailedCompareAs
_, Term
lhs, Term
rhs) -> HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok HereOrThere
There Maybe HeadMismatch
hdm
( FailedCompareAs
FailAsTypes
, Dom Type -> Abs Type -> Term
Pi (Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
HasCallStack => Sort' Term
__DUMMY_SORT__ Term
lhs Type -> Dom ConversionZipper -> Dom Type
forall a b. a -> Dom' Term b -> Dom' Term a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Dom ConversionZipper
dom) Abs Type
c1
, Dom Type -> Abs Type -> Term
Pi (Sort' Term -> Term -> Type
forall t a. Sort' t -> a -> Type'' t a
El Sort' Term
HasCallStack => Sort' Term
__DUMMY_SORT__ Term
rhs Type -> Dom ConversionZipper -> Dom Type
forall a b. a -> Dom' Term b -> Dom' Term a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Dom ConversionZipper
dom) Abs Type
c2
)
ConvApply Term
hd Abs Type
ty (Arg ArgInfo
info ConversionZipper
rest) [Elim]
l_es [Elim]
r_es -> ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
forall z.
ConversionZipper
-> (Maybe HeadMismatch -> ConversionProblem -> m z)
-> (HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z)
-> m z
reify ConversionZipper
rest Maybe HeadMismatch -> ConversionProblem -> m z
err \HereOrThere
_ Maybe HeadMismatch
hdm prob :: ConversionProblem
prob@(FailedCompareAs
_, Term
lhs', Term
rhs') ->
let info' :: ArgInfo
info' = ArgInfo
info { argInfoOrigin = ConversionFail } in case Term
hd of
Def QName
nm [Elim]
as | QName -> Bool
isExtendedLambdaName QName
nm -> do
~Function{ funExtLam = Just (ExtLamInfo m b sys) } <- Definition -> Defn
theDef (Definition -> Defn) -> m Definition -> m Defn
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QName -> m Definition
forall (m :: * -> *).
(HasConstInfo m, HasCallStack) =>
QName -> m Definition
getConstInfo QName
nm
bs <- lookupSection m
reportSDoc "tc.conv.ctx" 30 $ vcat
[ "conversion context has extended lambda" <+> pretty nm
, "bs " <> parens (pretty (size bs)) <> colon <> " " <> pretty bs
, "as " <> parens (pretty (size as)) <> colon <> " " <> pretty as
]
err hdm prob
Term
_ -> HereOrThere -> Maybe HeadMismatch -> ConversionProblem -> m z
ok HereOrThere
There Maybe HeadMismatch
hdm (ConversionProblem -> m z) -> m ConversionProblem -> m z
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Type
-> Term -> [Elim] -> Type -> Term -> [Elim] -> m ConversionProblem
forall (m :: * -> *).
PureTCM m =>
Type
-> Term -> [Elim] -> Type -> Term -> [Elim] -> m ConversionProblem
eliminateLhsRhs
(Abs Type
ty Abs Type -> SubstArg Type -> Type
forall a. Subst a => Abs a -> SubstArg a -> a
`absApp` Term
SubstArg Type
lhs') (Term
hd Term -> Args -> Term
forall t. Apply t => t -> Args -> t
`apply` [ArgInfo -> Term -> Arg Term
forall e. ArgInfo -> e -> Arg e
Arg ArgInfo
info' Term
lhs']) [Elim]
l_es
(Abs Type
ty Abs Type -> SubstArg Type -> Type
forall a. Subst a => Abs a -> SubstArg a -> a
`absApp` Term
SubstArg Type
rhs') (Term
hd Term -> Args -> Term
forall t. Apply t => t -> Args -> t
`apply` [ArgInfo -> Term -> Arg Term
forall e. ArgInfo -> e -> Arg e
Arg ArgInfo
info' Term
rhs']) [Elim]
r_es
instance PrettyTCM FailedCompareAs where
prettyTCM :: forall (m :: * -> *). MonadPretty m => FailedCompareAs -> m Doc
prettyTCM = \case
FailAsTypes{} -> m Doc
"(as types)"
FailAsTermsOf Type
a Type
b -> Type -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Type -> m Doc
prettyTCM Type
a m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> m Doc
forall (m :: * -> *). Applicative m => m Doc
comma m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Type -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Type -> m Doc
prettyTCM Type
b
instance PrettyTCM ConversionZipper where
prettyTCM :: forall (m :: * -> *). MonadPretty m => ConversionZipper -> m Doc
prettyTCM = \case
ConversionZipper
ConvStop -> m Doc
"<>"
ConvLam Dom Type
dom Abs ()
ret String
nm ConversionZipper
rest -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"lam" m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> String -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty String
nm m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Dom Type -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Dom Type
dom
, m Doc
"ret: " m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Abs () -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Abs ()
ret
, m Doc
"rest:"
, Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (ConversionZipper -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => ConversionZipper -> m Doc
prettyTCM ConversionZipper
rest)
]
ConvCod Dom Type
dom String
nm ConversionZipper
rest -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"cod" m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> String -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty String
nm m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Dom Type -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Dom Type
dom
, m Doc
"rest:"
, Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (ConversionZipper -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => ConversionZipper -> m Doc
prettyTCM ConversionZipper
rest)
]
ConvDom Dom ConversionZipper
dom Abs Type
t1 Abs Type
t2 -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"dom:" m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Dom' Term () -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty (() () -> Dom ConversionZipper -> Dom' Term ()
forall a b. a -> Dom' Term b -> Dom' Term a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Dom ConversionZipper
dom)
, m Doc
"t1: " m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Abs Type -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Abs Type
t1
, m Doc
"t2: " m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Abs Type -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Abs Type
t2
, m Doc
"rest:"
, Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (ConversionZipper -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => ConversionZipper -> m Doc
prettyTCM (Dom ConversionZipper -> ConversionZipper
forall t e. Dom' t e -> e
unDom Dom ConversionZipper
dom))
]
ConvApply Term
hd Abs Type
ty (Arg ArgInfo
info ConversionZipper
rest) [Elim]
lhs [Elim]
rhs -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"apply" m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Term -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Term
hd
, m Doc
"ty: " m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Abs Type -> m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Abs Type
ty
, m Doc
"lhs: " m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> [Elim] -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => [Elim] -> m Doc
prettyTCM [Elim]
lhs
, m Doc
"rhs: " m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> [Elim] -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => [Elim] -> m Doc
prettyTCM [Elim]
rhs
, m Doc
"rest:"
, Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (ConversionZipper -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => ConversionZipper -> m Doc
prettyTCM ConversionZipper
rest)
]
instance PrettyTCM ConversionError where
prettyTCM :: forall m. MonadPretty m => ConversionError -> m Doc
prettyTCM :: forall (m :: * -> *). MonadPretty m => ConversionError -> m Doc
prettyTCM ConversionError
err = ConversionError -> (ConversionError -> m Doc) -> m Doc
forall (m :: * -> *) z.
PureTCM m =>
ConversionError -> (ConversionError -> m z) -> m z
flattenConversionError ConversionError
err \(ConversionError Comparison
cmp FailedCompareAs
tys Term
lhs Term
rhs ~(Finished HereOrThere
ht Maybe HeadMismatch
hdm)) -> do
(d1, d2, disamb) <- HereOrThere
-> Maybe HeadMismatch -> Term -> Term -> m (Doc, Doc, Maybe Doc)
forall (m :: * -> *).
MonadPretty m =>
HereOrThere
-> Maybe HeadMismatch -> Term -> Term -> m (Doc, Doc, Maybe Doc)
prettyInEqual HereOrThere
ht Maybe HeadMismatch
hdm Term
lhs Term
rhs
let
disambs = Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (m Doc -> m Doc) -> m Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ Maybe (m Doc) -> m Doc
forall a. Null a => Maybe a -> a
orEmpty (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> Maybe Doc -> Maybe (m Doc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Doc
disamb)
what = Maybe HeadMismatch
hdm Maybe HeadMismatch
-> (HeadMismatch -> Maybe WhyUnequalTypes) -> Maybe WhyUnequalTypes
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
HdmTypes WhyUnequalTypes
x -> WhyUnequalTypes -> Maybe WhyUnequalTypes
forall a. a -> Maybe a
Just WhyUnequalTypes
x
HeadMismatch
_ -> Maybe WhyUnequalTypes
forall a. Maybe a
Nothing
case tys of
FailAsTermsOf Type
lhs_t Type
rhs_t -> BlockT m Bool -> m (Either Blocker Bool)
forall (m :: * -> *) a.
Monad m =>
BlockT m a -> m (Either Blocker a)
runBlocked (Type -> Type -> BlockT m Bool
forall (m :: * -> *).
(PureTCM m, MonadBlock m) =>
Type -> Type -> m Bool
pureEqualType Type
lhs_t Type
rhs_t) m (Either Blocker Bool) -> (Either Blocker Bool -> m Doc) -> m Doc
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Right Bool
True -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"The terms", Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d1)
, m Doc
"and", Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d2)
, m Doc
"are not equal at type " m Doc -> m Doc -> m Doc
forall a. Semigroup a => a -> a -> a
<> Type -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Type -> m Doc
prettyTCM Type
lhs_t m Doc -> m Doc -> m Doc
forall a. Semigroup a => a -> a -> a
<> Maybe (m Doc) -> m Doc
forall a. Null a => Maybe a -> a
orEmpty (m Doc
forall (m :: * -> *). Applicative m => m Doc
comma m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> m Doc
"because:" m Doc -> Maybe Doc -> Maybe (m Doc)
forall a b. a -> Maybe b -> Maybe a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Maybe Doc
disamb)
, m Doc
disambs
]
Either Blocker Bool
_ -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"The terms", Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d1 m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> m Doc
forall (m :: * -> *). Applicative m => m Doc
colon m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Type -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Type -> m Doc
prettyTCM Type
lhs_t)
, m Doc
"and", Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d2 m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> m Doc
forall (m :: * -> *). Applicative m => m Doc
colon m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Type -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => Type -> m Doc
prettyTCM Type
rhs_t)
, m Doc
"are not equal" m Doc -> m Doc -> m Doc
forall a. Semigroup a => a -> a -> a
<> Maybe (m Doc) -> m Doc
forall a. Null a => Maybe a -> a
orEmpty (m Doc
forall (m :: * -> *). Applicative m => m Doc
comma m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> m Doc
"because:" m Doc -> Maybe Doc -> Maybe (m Doc)
forall a b. a -> Maybe b -> Maybe a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Maybe Doc
disamb)
, m Doc
disambs
]
FailedCompareAs
FailAsTypes | Comparison
CmpEq <- Comparison
cmp -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"The" m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> case Maybe WhyUnequalTypes
what of
Just UnequalDomain{} -> m Doc
"function types"
Just UnequalHiding{} -> m Doc
"function types"
Maybe WhyUnequalTypes
_ -> m Doc
"types"
, Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d1), m Doc
"and", Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d2)
, m Doc
"are not equal" m Doc -> m Doc -> m Doc
forall a. Semigroup a => a -> a -> a
<> Maybe (m Doc) -> m Doc
forall a. Null a => Maybe a -> a
orEmpty (m Doc
forall (m :: * -> *). Applicative m => m Doc
comma m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> m Doc
"because:" m Doc -> Maybe Doc -> Maybe (m Doc)
forall a b. a -> Maybe b -> Maybe a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Maybe Doc
disamb)
, m Doc
disambs
]
FailedCompareAs
FailAsTypes | Comparison
CmpLeq <- Comparison
cmp -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ m Doc
"The" m Doc -> m Doc -> m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> case Maybe WhyUnequalTypes
what of
Just UnequalDomain{} -> m Doc
"function type"
Just UnequalHiding{} -> m Doc
"function type"
Maybe WhyUnequalTypes
_ -> m Doc
"type"
, Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d1), m Doc
"is not a subtype of", Int -> m Doc -> m Doc
forall (m :: * -> *). Functor m => Int -> m Doc -> m Doc
nest Int
2 (Doc -> m Doc
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
d2)
, Maybe (m Doc) -> m Doc
forall a. Null a => Maybe a -> a
orEmpty (m Doc
"because:" m Doc -> Maybe Doc -> Maybe (m Doc)
forall a b. a -> Maybe b -> Maybe a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Maybe Doc
disamb)
, m Doc
disambs
]
displayDisamb
:: forall m. MonadPretty m
=> HereOrThere
-> Maybe (Int, Closure (Elims, Elims))
-> Term
-> Term
-> m (Doc, Doc, Maybe Doc)
displayDisamb :: forall (m :: * -> *).
MonadPretty m =>
HereOrThere
-> Maybe (Int, Closure ([Elim], [Elim]))
-> Term
-> Term
-> m (Doc, Doc, Maybe Doc)
displayDisamb HereOrThere
ht Maybe (Int, Closure ([Elim], [Elim]))
hdm Term
t1 Term
t2 = do
d1 <- Precedence -> Term -> m Doc
forall a (m :: * -> *).
(PrettyTCM a, MonadPretty m) =>
Precedence -> a -> m Doc
prettyTCMCtx Precedence
TopCtx Term
t1
d2 <- prettyTCMCtx TopCtx t2
let
maybeProjs :: Elims -> Elims -> MaybeT m [m Doc]
maybeProjs (Proj ProjOrigin
_ QName
p:[Elim]
xs) (Proj ProjOrigin
_ QName
p':[Elim]
ys) | QName
p QName -> QName -> Bool
forall a. Eq a => a -> a -> Bool
/= QName
p' = do
df <- QName -> MaybeT m Bool
forall (m :: * -> *).
(HasConstInfo m, ReadTCState m) =>
QName -> m Bool
hasDisplayForms QName
p
df' <- hasDisplayForms p'
case (df, df') of
(Bool
True, Bool
False) -> [m Doc] -> MaybeT m [m Doc]
forall a. a -> MaybeT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([m Doc] -> MaybeT m [m Doc]) -> [m Doc] -> MaybeT m [m Doc]
forall a b. (a -> b) -> a -> b
$ String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"a display form for" [m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [QName -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => QName -> m Doc
prettyTCM QName
p, m Doc
"has"]
(Bool
False, Bool
True) -> [m Doc] -> MaybeT m [m Doc]
forall a. a -> MaybeT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([m Doc] -> MaybeT m [m Doc]) -> [m Doc] -> MaybeT m [m Doc]
forall a b. (a -> b) -> a -> b
$ String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"a display form for" [m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [QName -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => QName -> m Doc
prettyTCM QName
p', m Doc
"has"]
(Bool
True, Bool
True) -> [m Doc] -> MaybeT m [m Doc]
forall a. a -> MaybeT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([m Doc] -> MaybeT m [m Doc]) -> [m Doc] -> MaybeT m [m Doc]
forall a b. (a -> b) -> a -> b
$ String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"display forms for" [m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [QName -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => QName -> m Doc
prettyTCM QName
p, m Doc
"and", QName -> m Doc
forall a (m :: * -> *). (PrettyTCM a, MonadPretty m) => a -> m Doc
forall (m :: * -> *). MonadPretty m => QName -> m Doc
prettyTCM QName
p', m Doc
"have"]
(Bool
False, Bool
False) -> MaybeT m [m Doc]
forall a. MaybeT m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
maybeProjs (Elim
_:[Elim]
xs) (Elim
_:[Elim]
ys) = [Elim] -> [Elim] -> MaybeT m [m Doc]
maybeProjs [Elim]
xs [Elim]
ys
maybeProjs [Elim]
_ [Elim]
_ = MaybeT m [m Doc]
forall a. MaybeT m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
(d1, d2,) <$> runMaybeT do
guard (P.render d1 == P.render d2)
reportSDoc "tc.error.conv" 30 $ vcat
[ "terms rendered the same"
, " t1:" <+> pretty t1
, " d1:" <+> pure d1
, " t2:" <+> pretty t2
, " d2:" <+> pure d2
]
(d1, d2) <- locallyTC eDisplayFormsEnabled (const False) do
(,) <$> prettyTCMCtx TopCtx t1 <*> prettyTCMCtx TopCtx t2
guard (P.render d1 /= P.render d2)
whatdf <- case hdm of
Just (Int
_, Closure ([Elim], [Elim])
cl) -> Closure ([Elim], [Elim])
-> (([Elim], [Elim]) -> MaybeT m (Maybe [m Doc]))
-> MaybeT m (Maybe [m Doc])
forall (m :: * -> *) c a b.
(MonadTCEnv m, ReadTCState m, LensClosure c a) =>
c -> (a -> m b) -> m b
enterClosure Closure ([Elim], [Elim])
cl (m (Maybe [m Doc]) -> MaybeT m (Maybe [m Doc])
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe [m Doc]) -> MaybeT m (Maybe [m Doc]))
-> (([Elim], [Elim]) -> m (Maybe [m Doc]))
-> ([Elim], [Elim])
-> MaybeT m (Maybe [m Doc])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MaybeT m [m Doc] -> m (Maybe [m Doc])
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT (MaybeT m [m Doc] -> m (Maybe [m Doc]))
-> (([Elim], [Elim]) -> MaybeT m [m Doc])
-> ([Elim], [Elim])
-> m (Maybe [m Doc])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Elim] -> [Elim] -> MaybeT m [m Doc])
-> ([Elim], [Elim]) -> MaybeT m [m Doc]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry [Elim] -> [Elim] -> MaybeT m [m Doc]
maybeProjs) MaybeT m (Maybe [m Doc])
-> (Maybe [m Doc] -> [m Doc]) -> MaybeT m [m Doc]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
[m Doc] -> Maybe [m Doc] -> [m Doc]
forall a. a -> Maybe a -> a
fromMaybe (String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"display forms have")
Maybe (Int, Closure ([Elim], [Elim]))
Nothing -> [m Doc] -> MaybeT m [m Doc]
forall a. a -> MaybeT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([m Doc] -> MaybeT m [m Doc]) -> [m Doc] -> MaybeT m [m Doc]
forall a b. (a -> b) -> a -> b
$ String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"display forms have"
vcat
[ fsep $ map lift whatdf <> pwords "caused" <> pwords case ht of
HereOrThere
Here -> String
"them"
HereOrThere
There -> String
"the mismatched terms"
, nest 2 (pure d1), "and", nest 2 (pure d2)
, "to render the same"
]
prettyInEqual
:: MonadPretty m
=> HereOrThere
-> Maybe HeadMismatch
-> Term -> Term -> m (Doc, Doc, Maybe Doc)
prettyInEqual :: forall (m :: * -> *).
MonadPretty m =>
HereOrThere
-> Maybe HeadMismatch -> Term -> Term -> m (Doc, Doc, Maybe Doc)
prettyInEqual HereOrThere
ht Maybe HeadMismatch
hdm Term
t1 Term
t2
| Maybe HeadMismatch
Nothing <- Maybe HeadMismatch
hdm = HereOrThere
-> Maybe (Int, Closure ([Elim], [Elim]))
-> Term
-> Term
-> m (Doc, Doc, Maybe Doc)
forall (m :: * -> *).
MonadPretty m =>
HereOrThere
-> Maybe (Int, Closure ([Elim], [Elim]))
-> Term
-> Term
-> m (Doc, Doc, Maybe Doc)
displayDisamb HereOrThere
ht Maybe (Int, Closure ([Elim], [Elim]))
forall a. Maybe a
Nothing Term
t1 Term
t2
| Just (HdmVarSpine Int
i Closure ([Elim], [Elim])
cl) <- Maybe HeadMismatch
hdm = HereOrThere
-> Maybe (Int, Closure ([Elim], [Elim]))
-> Term
-> Term
-> m (Doc, Doc, Maybe Doc)
forall (m :: * -> *).
MonadPretty m =>
HereOrThere
-> Maybe (Int, Closure ([Elim], [Elim]))
-> Term
-> Term
-> m (Doc, Doc, Maybe Doc)
displayDisamb HereOrThere
ht ((Int, Closure ([Elim], [Elim]))
-> Maybe (Int, Closure ([Elim], [Elim]))
forall a. a -> Maybe a
Just (Int
i, Closure ([Elim], [Elim])
cl)) Term
t1 Term
t2
| Just (HdmTypes WhyUnequalTypes
x) <- Maybe HeadMismatch
hdm =
let
ecore :: [m Doc]
ecore = case WhyUnequalTypes
x of
UnequalDomain a
a a
b -> String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one has"
[m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [m Doc -> m Doc
forall (m :: * -> *). Functor m => m Doc -> m Doc
hlKeyword (String -> m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
text (a -> String
forall a. Verbalize a => a -> String
verbalize a
a))]
[m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"domain, while the other is"
[m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [m Doc -> m Doc
forall (m :: * -> *). Functor m => m Doc -> m Doc
hlKeyword (String -> m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
text (a -> String
forall a. Verbalize a => a -> String
verbalize a
b)) m Doc -> m Doc -> m Doc
forall a. Semigroup a => a -> a -> a
<> m Doc
"."]
UnequalHiding Hiding
a Hiding
b -> String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one takes"
[m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [m Doc -> m Doc
forall (m :: * -> *). Functor m => m Doc -> m Doc
hlKeyword (String -> m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
text (Indefinite Hiding -> String
forall a. Verbalize a => a -> String
verbalize (Hiding -> Indefinite Hiding
forall a. a -> Indefinite a
Indefinite Hiding
a)))]
[m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"argument, while the other takes"
[m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [m Doc -> m Doc
forall (m :: * -> *). Functor m => m Doc -> m Doc
hlKeyword (String -> m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
text (Indefinite Hiding -> String
forall a. Verbalize a => a -> String
verbalize (Hiding -> Indefinite Hiding
forall a. a -> Indefinite a
Indefinite Hiding
b))), m Doc
"argument."]
explain :: m Doc
explain = case HereOrThere
ht of
HereOrThere
Here -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep [m Doc]
ecore
HereOrThere
There -> [m Doc] -> m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([m Doc] -> m Doc) -> [m Doc] -> m Doc
forall a b. (a -> b) -> a -> b
$ String -> [m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"the mismatched terms are function types;" [m Doc] -> [m Doc] -> [m Doc]
forall a. Semigroup a => a -> a -> a
<> [m Doc]
ecore
in (,,) (Doc -> Doc -> Maybe Doc -> (Doc, Doc, Maybe Doc))
-> m Doc -> m (Doc -> Maybe Doc -> (Doc, Doc, Maybe Doc))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Precedence -> Term -> m Doc
forall a (m :: * -> *).
(PrettyTCM a, MonadPretty m) =>
Precedence -> a -> m Doc
prettyTCMCtx Precedence
TopCtx Term
t1 m (Doc -> Maybe Doc -> (Doc, Doc, Maybe Doc))
-> m Doc -> m (Maybe Doc -> (Doc, Doc, Maybe Doc))
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Precedence -> Term -> m Doc
forall a (m :: * -> *).
(PrettyTCM a, MonadPretty m) =>
Precedence -> a -> m Doc
prettyTCMCtx Precedence
TopCtx Term
t2 m (Maybe Doc -> (Doc, Doc, Maybe Doc))
-> m (Maybe Doc) -> m (Doc, Doc, Maybe Doc)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Doc -> Maybe Doc
forall a. a -> Maybe a
Just (Doc -> Maybe Doc) -> m Doc -> m (Maybe Doc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Doc
explain)
prettyInEqual HereOrThere
ht (Just HeadMismatch
hdm) Term
t1 Term
t2 = do
d1 <- Precedence -> Term -> m Doc
forall a (m :: * -> *).
(PrettyTCM a, MonadPretty m) =>
Precedence -> a -> m Doc
prettyTCMCtx Precedence
TopCtx Term
t1
d2 <- prettyTCMCtx TopCtx t2
(d1, d2,) <$> runMaybeT do
guard (P.render d1 == P.render d2)
let
mm = case HereOrThere
ht of
HereOrThere
Here -> []
HereOrThere
There -> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"of the mismatched terms"
case hdm of
HdmExtLam QName
a QName
b -> [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
vcat
[ [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([MaybeT m Doc] -> MaybeT m Doc) -> [MaybeT m Doc] -> MaybeT m Doc
forall a b. (a -> b) -> a -> b
$
case HereOrThere
ht of
HereOrThere
Here -> MaybeT m Doc -> [MaybeT m Doc]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure MaybeT m Doc
"they"
HereOrThere
There -> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"the mismatched terms"
[MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"are distinct extended lambdas; "
, String -> MaybeT m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
fwords String
"one is defined at"
, MaybeT m Doc
" " MaybeT m Doc -> MaybeT m Doc -> MaybeT m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> Range -> MaybeT m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty (Name -> Range
nameBindingSite (QName -> Name
qnameName QName
a))
, String -> MaybeT m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
fwords String
"and the other at"
, MaybeT m Doc
" " MaybeT m Doc -> MaybeT m Doc -> MaybeT m Doc
forall (m :: * -> *). Applicative m => m Doc -> m Doc -> m Doc
<+> (Range -> MaybeT m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty (Name -> Range
nameBindingSite (QName -> Name
qnameName QName
b)) MaybeT m Doc -> MaybeT m Doc -> MaybeT m Doc
forall a. Semigroup a => a -> a -> a
<> MaybeT m Doc
",")
, String -> MaybeT m Doc
forall (m :: * -> *). Applicative m => String -> m Doc
fwords String
"so they have different internal representations."
]
HeadMismatch
HdmVarDef -> [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([MaybeT m Doc] -> MaybeT m Doc) -> [MaybeT m Doc] -> MaybeT m Doc
forall a b. (a -> b) -> a -> b
$ String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one" [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [MaybeT m Doc]
mm [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"is a variable, the other a definition"
HeadMismatch
HdmVarCon -> [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([MaybeT m Doc] -> MaybeT m Doc) -> [MaybeT m Doc] -> MaybeT m Doc
forall a b. (a -> b) -> a -> b
$ String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one" [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [MaybeT m Doc]
mm [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"is a variable, the other a constructor"
HeadMismatch
HdmDefVar -> [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([MaybeT m Doc] -> MaybeT m Doc) -> [MaybeT m Doc] -> MaybeT m Doc
forall a b. (a -> b) -> a -> b
$ String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one" [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [MaybeT m Doc]
mm [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"is a definition, the other a variable"
HeadMismatch
HdmConVar -> [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([MaybeT m Doc] -> MaybeT m Doc) -> [MaybeT m Doc] -> MaybeT m Doc
forall a b. (a -> b) -> a -> b
$ String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one" [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [MaybeT m Doc]
mm [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"is a constructor, the other a variable"
HdmVars Int
i Int
j -> [MaybeT m Doc] -> MaybeT m Doc
forall (m :: * -> *) (t :: * -> *).
(Applicative m, Foldable t) =>
t (m Doc) -> m Doc
fsep ([MaybeT m Doc] -> MaybeT m Doc) -> [MaybeT m Doc] -> MaybeT m Doc
forall a b. (a -> b) -> a -> b
$
String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"one" [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [MaybeT m Doc]
mm [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"has de Bruijn index "
[MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [Int -> MaybeT m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Int
i MaybeT m Doc -> MaybeT m Doc -> MaybeT m Doc
forall a. Semigroup a => a -> a -> a
<> MaybeT m Doc
forall (m :: * -> *). Applicative m => m Doc
comma] [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> String -> [MaybeT m Doc]
forall (m :: * -> *). Applicative m => String -> [m Doc]
pwords String
"the other" [MaybeT m Doc] -> [MaybeT m Doc] -> [MaybeT m Doc]
forall a. Semigroup a => a -> a -> a
<> [Int -> MaybeT m Doc
forall (m :: * -> *) a. (Applicative m, Pretty a) => a -> m Doc
pretty Int
j]