{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DeriveTraversable          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE UndecidableInstances       #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE ConstraintKinds            #-}
{-# LANGUAGE DerivingVia                #-}

{-# OPTIONS_GHC -Wno-orphans #-}

-- | This module should contain all the global type definitions and basic instances.

module Language.Haskell.Liquid.Types.Types (

  -- * Options
    module Language.Haskell.Liquid.UX.Config

  -- * Ghc Information
  , TargetVars   (..)
  , TyConMap     (..)

  -- * F.Located Things
  , F.Located (..)
  , F.dummyLoc

  -- * Symbols
  , F.LocSymbol
  , F.LocText

  -- * Default unknown name
  , F.dummyName
  , F.isDummy

  -- * Bare Type Constructors and Variables
  , BTyCon(..)
  , mkBTyCon
  -- , mkClassBTyCon, mkPromotedBTyCon
  , isClassBTyCon
  , BTyVar(..)

  -- * Refined Type Constructors
  , RTyCon (RTyCon, rtc_tc, rtc_info)
  , TyConInfo(..), defaultTyConInfo
  , rTyConPVs
  , rTyConPropVs
  -- , isClassRTyCon
  , isClassType, isEqType, isRVar, isBool, isEmbeddedClass

  -- * Refinement Types
  , RType (..), Ref(..), RTProp, rPropP
  , RTyVar (..)
  , RTAlias (..)
  , OkRT
  , lmapEAlias

  -- * Worlds
  , HSeg (..)
  , World (..)

  -- * Classes describing operations on `RTypes`
  , TyConable (..)
  , SubsTy (..)

  -- * Type Variables
  , RTVar (..), RTVInfo (..)
  , makeRTVar, mapTyVarValue
  , dropTyVarInfo, rTVarToBind
  , setRtvPol

  -- * Predicate Variables
  , PVar (PV, pname, parg, ptype, pargs), isPropPV, pvType
  , PVKind (..)
  , Predicate (..)

  -- * Refinements
  , UReft(..)

  -- * Relational predicates
  , RelExpr (..)

  -- * Parse-time entities describing refined data types
  , SizeFun  (..), szFun
  , DataDecl (..)
  , DataName (..), dataNameSymbol
  , DataCtor (..)
  , DataConP (..)
  , HasDataDecl (..), hasDecl
  , DataDeclKind (..)
  , TyConP   (..)

  -- * Pre-instantiated RType
  , RRType, RRProp
  , BRType, BRProp
  , BSort, BPVar
  , RTVU, PVU

  -- * Instantiated RType
  , BareType, PrType
  , SpecType, SpecProp, SpecRTVar
  , SpecRep
  , LocBareType, LocSpecType
  , RSort
  , UsedPVar, RPVar, RReft
  , REnv
  , AREnv (..)

  -- * Constructing & Destructing RTypes
  , RTypeRep(..), fromRTypeRep, toRTypeRep
  , mkArrow, bkArrowDeep, bkArrow, safeBkArrow
  , mkUnivs, bkUniv, bkClass, bkUnivClass, bkUnivClass'
  , rFun, rFun', rCls, rRCls, rFunDebug

  -- * Manipulating `Predicates`
  , pvars, pappSym, pApp

  -- * Some tests on RTypes
  , isBase
  , isFunTy
  , isTrivial
  , hasHole

  -- * Traversing `RType`
  , efoldReft, foldReft, foldReft'
  , emapReft, mapReft, mapReftM, mapPropM
  , mapExprReft
  , mapBot, mapBind, mapRFInfo
  , foldRType


  -- * ???
  , Oblig(..)
  , ignoreOblig
  , addInvCond

  -- * Inferred Annotations
  , AnnInfo (..)
  , Annot (..)

  -- * Hole Information
  , HoleInfo(..)

  -- * Overall Output
  , Output (..)

  -- * Refinement Hole
  , hole, isHole, hasHoleTy

  -- * Converting To and From Sort
  , ofRSort, toRSort
  , rTypeValueVar
  , rTypeReft
  , stripRTypeBase
  , topRTypeBase

  -- * Class for values that can be pretty printed
  , F.PPrint (..)
  , F.pprint
  , F.showpp

  -- * Printer Configuration
  , PPEnv (..)
  , ppEnv
  , ppEnvShort

  -- * Modules and Imports
  , ModName (..), ModType (..)
  , isSrcImport, isSpecImport, isTarget
  , getModName, getModString, qualifyModName

  -- * Refinement Type Aliases
  , RTEnv (..), BareRTEnv, SpecRTEnv, BareRTAlias, SpecRTAlias
  -- , mapRT, mapRE

  -- * Diagnostics, Warnings, Errors and Error Messages
  , module Language.Haskell.Liquid.Types.Errors
  , Error
  , ErrorResult
  , Warning
  , mkWarning
  , Diagnostics
  , mkDiagnostics
  , emptyDiagnostics
  , noErrors
  , allWarnings
  , allErrors
  , printWarning

  -- * Source information (associated with constraints)
  , Cinfo (..)

  -- * Measures
  , Measure (..)
  , UnSortedExprs, UnSortedExpr
  , MeasureKind (..)
  , CMeasure (..)
  , Def (..)
  , Body (..)
  , MSpec (..)

  -- * Scoping Info
  , BScope

  -- * Type Classes
  , RClass (..)

  -- * KV Profiling
  , KVKind (..)   -- types of kvars
  , KVProf        -- profile table
  , emptyKVProf   -- empty profile
  , updKVProf     -- extend profile

  -- * Misc
  , mapRTAVars
  , insertsSEnv

  -- * CoreToLogic
  , LogicMap(..), toLogicMap, eAppWithMap, LMap(..)

  -- * Refined Instances
  , RDEnv, DEnv(..), RInstance(..), RISig(..), RILaws(..)
  , MethodType(..), getMethodType

  -- * Ureftable Instances
  , UReftable(..)

  -- * String Literals
  , liquidBegin, liquidEnd

  , Axiom(..), HAxiom

  -- , rtyVarUniqueSymbol, tyVarUniqueSymbol
  , rtyVarType, tyVarVar

  -- * Refined Function Info
  , RFInfo(..), defRFInfo, mkRFInfo, classRFInfo, classRFInfoType

  , ordSrcSpan
  )
  where

import           Liquid.GHC.API as Ghc hiding ( Expr
                                                               , isFunTy
                                                               , ($+$)
                                                               , nest
                                                               , text
                                                               , blankLine
                                                               , (<+>)
                                                               , vcat
                                                               , hsep
                                                               , comma
                                                               , colon
                                                               , parens
                                                               , empty
                                                               , char
                                                               , panic
                                                               , int
                                                               , hcat
                                                               , showPpr
                                                               , punctuate
                                                               , ($$)
                                                               , braces
                                                               , angleBrackets
                                                               , brackets
                                                               )
import           Data.String
import           GHC.Generics
import           Prelude                          hiding  (error)
import qualified Prelude

import           Control.Monad                          (liftM2, liftM3, liftM4, void)
import           Control.DeepSeq
import           Data.Bifunctor
import           Data.Typeable                          (Typeable)
import           Data.Generics                          (Data)
import qualified Data.Binary                            as B
import qualified Data.Foldable                          as F
import           Data.Hashable
import qualified Data.HashMap.Strict                    as M
import qualified Data.HashSet                           as S
import qualified Data.List                              as L
import           Data.Maybe                             (mapMaybe)
import           Data.Function                          (on)
import           Data.List                              as L (foldl', nub, null)
import           Data.Text                              (Text)
import           Text.PrettyPrint.HughesPJ              hiding (first, (<>))
import           Text.Printf
import           Language.Fixpoint.Misc

import qualified Language.Fixpoint.Types as F

import           Language.Haskell.Liquid.GHC.Misc
import           Language.Haskell.Liquid.GHC.Logging as GHC
import           Language.Haskell.Liquid.Types.Variance
import           Language.Haskell.Liquid.Types.Errors
import           Language.Haskell.Liquid.Misc
import           Language.Haskell.Liquid.UX.Config
import           Data.Default


-----------------------------------------------------------------------------
-- | Information about scope Binders Scope in
-----------------------------------------------------------------------------
{- In types with base refinement, e.g., {out:T {inner:a | ri} | ro }
If BScope = True , then the outer binder out is     in scope on ri
If BScope = False, then the outer binder out is not in scope on ri
-}

type BScope = Bool
-----------------------------------------------------------------------------
-- | Information about Type Constructors
-----------------------------------------------------------------------------
data TyConMap = TyConMap
  { TyConMap -> HashMap TyCon RTyCon
tcmTyRTy    :: M.HashMap TyCon             RTyCon  -- ^ Map from GHC TyCon to RTyCon
  , TyConMap -> HashMap (TyCon, [Sort]) RTyCon
tcmFIRTy    :: M.HashMap (TyCon, [F.Sort]) RTyCon  -- ^ Map from GHC Family-Instances to RTyCon
  , TyConMap -> HashMap TyCon Int
tcmFtcArity :: M.HashMap TyCon             Int     -- ^ Arity of each Family-Tycon
  }


newtype RFInfo = RFInfo {RFInfo -> Maybe Bool
permitTC :: Maybe Bool }
  deriving ((forall x. RFInfo -> Rep RFInfo x)
-> (forall x. Rep RFInfo x -> RFInfo) -> Generic RFInfo
forall x. Rep RFInfo x -> RFInfo
forall x. RFInfo -> Rep RFInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RFInfo -> Rep RFInfo x
from :: forall x. RFInfo -> Rep RFInfo x
$cto :: forall x. Rep RFInfo x -> RFInfo
to :: forall x. Rep RFInfo x -> RFInfo
Generic, Typeable RFInfo
Typeable RFInfo =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RFInfo -> c RFInfo)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RFInfo)
-> (RFInfo -> Constr)
-> (RFInfo -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RFInfo))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RFInfo))
-> ((forall b. Data b => b -> b) -> RFInfo -> RFInfo)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RFInfo -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RFInfo -> r)
-> (forall u. (forall d. Data d => d -> u) -> RFInfo -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RFInfo -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RFInfo -> m RFInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RFInfo -> m RFInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RFInfo -> m RFInfo)
-> Data RFInfo
RFInfo -> Constr
RFInfo -> DataType
(forall b. Data b => b -> b) -> RFInfo -> RFInfo
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RFInfo -> u
forall u. (forall d. Data d => d -> u) -> RFInfo -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RFInfo
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RFInfo -> c RFInfo
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RFInfo)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RFInfo)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RFInfo -> c RFInfo
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RFInfo -> c RFInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RFInfo
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RFInfo
$ctoConstr :: RFInfo -> Constr
toConstr :: RFInfo -> Constr
$cdataTypeOf :: RFInfo -> DataType
dataTypeOf :: RFInfo -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RFInfo)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RFInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RFInfo)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RFInfo)
$cgmapT :: (forall b. Data b => b -> b) -> RFInfo -> RFInfo
gmapT :: (forall b. Data b => b -> b) -> RFInfo -> RFInfo
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RFInfo -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RFInfo -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RFInfo -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RFInfo -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
Data, Typeable, Int -> RFInfo -> ShowS
[RFInfo] -> ShowS
RFInfo -> String
(Int -> RFInfo -> ShowS)
-> (RFInfo -> String) -> ([RFInfo] -> ShowS) -> Show RFInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RFInfo -> ShowS
showsPrec :: Int -> RFInfo -> ShowS
$cshow :: RFInfo -> String
show :: RFInfo -> String
$cshowList :: [RFInfo] -> ShowS
showList :: [RFInfo] -> ShowS
Show, RFInfo -> RFInfo -> Bool
(RFInfo -> RFInfo -> Bool)
-> (RFInfo -> RFInfo -> Bool) -> Eq RFInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RFInfo -> RFInfo -> Bool
== :: RFInfo -> RFInfo -> Bool
$c/= :: RFInfo -> RFInfo -> Bool
/= :: RFInfo -> RFInfo -> Bool
Eq)

defRFInfo :: RFInfo
defRFInfo :: RFInfo
defRFInfo = Maybe Bool -> RFInfo
RFInfo Maybe Bool
forall a. Maybe a
Nothing

classRFInfo :: Bool -> RFInfo
classRFInfo :: Bool -> RFInfo
classRFInfo Bool
b = Maybe Bool -> RFInfo
RFInfo (Maybe Bool -> RFInfo) -> Maybe Bool -> RFInfo
forall a b. (a -> b) -> a -> b
$ Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
b

classRFInfoType :: Bool -> RType c tv r -> RType c tv r
classRFInfoType :: forall c tv r. Bool -> RType c tv r -> RType c tv r
classRFInfoType Bool
b = RTypeRep c tv r -> RType c tv r
forall c tv r. RTypeRep c tv r -> RType c tv r
fromRTypeRep (RTypeRep c tv r -> RType c tv r)
-> (RType c tv r -> RTypeRep c tv r)
-> RType c tv r
-> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                    (\trep :: RTypeRep c tv r
trep@RTypeRep{[r]
[(RTVar tv (RType c tv ()), r)]
[Symbol]
[RType c tv r]
[PVar (RType c tv ())]
[RFInfo]
RType c tv r
ty_vars :: [(RTVar tv (RType c tv ()), r)]
ty_preds :: [PVar (RType c tv ())]
ty_binds :: [Symbol]
ty_info :: [RFInfo]
ty_refts :: [r]
ty_args :: [RType c tv r]
ty_res :: RType c tv r
ty_vars :: forall c tv r. RTypeRep c tv r -> [(RTVar tv (RType c tv ()), r)]
ty_preds :: forall c tv r. RTypeRep c tv r -> [PVar (RType c tv ())]
ty_binds :: forall c tv r. RTypeRep c tv r -> [Symbol]
ty_info :: forall c tv r. RTypeRep c tv r -> [RFInfo]
ty_refts :: forall c tv r. RTypeRep c tv r -> [r]
ty_args :: forall c tv r. RTypeRep c tv r -> [RType c tv r]
ty_res :: forall c tv r. RTypeRep c tv r -> RType c tv r
..} -> RTypeRep c tv r
trep{ty_info = map (\RFInfo
i -> RFInfo
i{permitTC = pure b}) ty_info}) (RTypeRep c tv r -> RTypeRep c tv r)
-> (RType c tv r -> RTypeRep c tv r)
-> RType c tv r
-> RTypeRep c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                    RType c tv r -> RTypeRep c tv r
forall c tv r. RType c tv r -> RTypeRep c tv r
toRTypeRep

mkRFInfo :: Config  -> RFInfo
mkRFInfo :: Config -> RFInfo
mkRFInfo Config
cfg = Maybe Bool -> RFInfo
RFInfo (Maybe Bool -> RFInfo) -> Maybe Bool -> RFInfo
forall a b. (a -> b) -> a -> b
$ Bool -> Maybe Bool
forall a. a -> Maybe a
Just (Config -> Bool
typeclass Config
cfg)

instance Hashable RFInfo
instance NFData RFInfo
instance B.Binary RFInfo

-----------------------------------------------------------------------------
-- | Printer ----------------------------------------------------------------
-----------------------------------------------------------------------------

data PPEnv = PP
  { PPEnv -> Bool
ppPs    :: Bool -- ^ print abstract-predicates
  , PPEnv -> Bool
ppTyVar :: Bool -- ^ print the unique suffix for each tyvar
  , PPEnv -> Bool
ppShort :: Bool -- ^ print the tycons without qualification
  , PPEnv -> Bool
ppDebug :: Bool -- ^ gross with full info
  }
  deriving (Int -> PPEnv -> ShowS
[PPEnv] -> ShowS
PPEnv -> String
(Int -> PPEnv -> ShowS)
-> (PPEnv -> String) -> ([PPEnv] -> ShowS) -> Show PPEnv
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PPEnv -> ShowS
showsPrec :: Int -> PPEnv -> ShowS
$cshow :: PPEnv -> String
show :: PPEnv -> String
$cshowList :: [PPEnv] -> ShowS
showList :: [PPEnv] -> ShowS
Show)

ppEnv :: PPEnv
ppEnv :: PPEnv
ppEnv = PPEnv
ppEnvDef
          { ppPs    = True }
          { ppDebug = True }   -- RJ: needed for resolution, because pp is used for serialization?

{- | [NOTE:ppEnv] For some mysterious reason, `ppDebug` must equal `True`
     or various tests fail e.g. tests/classes/pos/TypeEquality0{0,1}.hs
     Yikes. Find out why!
 -}

ppEnvDef :: PPEnv
ppEnvDef :: PPEnv
ppEnvDef = Bool -> Bool -> Bool -> Bool -> PPEnv
PP Bool
False Bool
False Bool
False Bool
False

ppEnvShort :: PPEnv -> PPEnv
ppEnvShort :: PPEnv -> PPEnv
ppEnvShort PPEnv
pp = PPEnv
pp { ppShort = True }

------------------------------------------------------------------
-- Huh?
------------------------------------------------------------------
type Expr      = F.Expr
type Symbol    = F.Symbol


-- [NOTE:LIFTED-VAR-SYMBOLS]: Following NOTE:REFLECT-IMPORTS, by default
-- each (lifted) `Var` is mapped to its `Symbol` via the `Symbolic Var`
-- instance. For _generated_ vars, we may want a custom name e.g. see
--   tests/pos/NatClass.hs
-- and we maintain that map in `lmVarSyms` with the `Just s` case.
-- Ideally, this bandaid should be replaced so we don't have these
-- hacky corner cases.

data LogicMap = LM
  { LogicMap -> HashMap Symbol LMap
lmSymDefs  :: M.HashMap Symbol LMap        -- ^ Map from symbols to equations they define
  , LogicMap -> HashMap Var (Maybe Symbol)
lmVarSyms  :: M.HashMap Var (Maybe Symbol) -- ^ Map from (lifted) Vars to `Symbol`; see:
                                              --   NOTE:LIFTED-VAR-SYMBOLS and NOTE:REFLECT-IMPORTs
  } deriving (Int -> LogicMap -> ShowS
[LogicMap] -> ShowS
LogicMap -> String
(Int -> LogicMap -> ShowS)
-> (LogicMap -> String) -> ([LogicMap] -> ShowS) -> Show LogicMap
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogicMap -> ShowS
showsPrec :: Int -> LogicMap -> ShowS
$cshow :: LogicMap -> String
show :: LogicMap -> String
$cshowList :: [LogicMap] -> ShowS
showList :: [LogicMap] -> ShowS
Show)

instance Monoid LogicMap where
  mempty :: LogicMap
mempty  = HashMap Symbol LMap -> HashMap Var (Maybe Symbol) -> LogicMap
LM HashMap Symbol LMap
forall k v. HashMap k v
M.empty HashMap Var (Maybe Symbol)
forall k v. HashMap k v
M.empty
  mappend :: LogicMap -> LogicMap -> LogicMap
mappend = LogicMap -> LogicMap -> LogicMap
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup LogicMap where
  LM HashMap Symbol LMap
x1 HashMap Var (Maybe Symbol)
x2 <> :: LogicMap -> LogicMap -> LogicMap
<> LM HashMap Symbol LMap
y1 HashMap Var (Maybe Symbol)
y2 = HashMap Symbol LMap -> HashMap Var (Maybe Symbol) -> LogicMap
LM (HashMap Symbol LMap -> HashMap Symbol LMap -> HashMap Symbol LMap
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
M.union HashMap Symbol LMap
x1 HashMap Symbol LMap
y1) (HashMap Var (Maybe Symbol)
-> HashMap Var (Maybe Symbol) -> HashMap Var (Maybe Symbol)
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
M.union HashMap Var (Maybe Symbol)
x2 HashMap Var (Maybe Symbol)
y2)

data LMap = LMap
  { LMap -> LocSymbol
lmVar  :: F.LocSymbol
  , LMap -> [Symbol]
lmArgs :: [Symbol]
  , LMap -> Expr
lmExpr :: Expr
  }

instance Show LMap where
  show :: LMap -> String
show (LMap LocSymbol
x [Symbol]
xs Expr
e) = LocSymbol -> String
forall a. Show a => a -> String
show LocSymbol
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Symbol] -> String
forall a. Show a => a -> String
show [Symbol]
xs String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\t |-> \t" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
e

toLogicMap :: [(F.LocSymbol, [Symbol], Expr)] -> LogicMap
toLogicMap :: [(LocSymbol, [Symbol], Expr)] -> LogicMap
toLogicMap [(LocSymbol, [Symbol], Expr)]
ls = LogicMap
forall a. Monoid a => a
mempty {lmSymDefs = M.fromList $ map toLMap ls}
  where
    toLMap :: (LocSymbol, [Symbol], Expr) -> (Symbol, LMap)
toLMap (LocSymbol
x, [Symbol]
ys, Expr
e) = (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
x, LMap {lmVar :: LocSymbol
lmVar = LocSymbol
x, lmArgs :: [Symbol]
lmArgs = [Symbol]
ys, lmExpr :: Expr
lmExpr = Expr
e})

eAppWithMap :: LogicMap -> F.Located Symbol -> [Expr] -> Expr -> Expr
eAppWithMap :: LogicMap -> LocSymbol -> [Expr] -> Expr -> Expr
eAppWithMap LogicMap
lmap LocSymbol
f [Expr]
es Expr
expr
  | Just (LMap LocSymbol
_ [Symbol]
xs Expr
e) <- Symbol -> HashMap Symbol LMap -> Maybe LMap
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
f) (LogicMap -> HashMap Symbol LMap
lmSymDefs LogicMap
lmap)
  , [Symbol] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
xs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [Expr] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Expr]
es
  = Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst ([(Symbol, Expr)] -> Subst
F.mkSubst ([(Symbol, Expr)] -> Subst) -> [(Symbol, Expr)] -> Subst
forall a b. (a -> b) -> a -> b
$ [Symbol] -> [Expr] -> [(Symbol, Expr)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Symbol]
xs [Expr]
es) Expr
e
  | Just (LMap LocSymbol
_ [Symbol]
xs Expr
e) <- Symbol -> HashMap Symbol LMap -> Maybe LMap
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
f) (LogicMap -> HashMap Symbol LMap
lmSymDefs LogicMap
lmap)
  , Expr -> Bool
isApp Expr
e
  = Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst ([(Symbol, Expr)] -> Subst
F.mkSubst ([(Symbol, Expr)] -> Subst) -> [(Symbol, Expr)] -> Subst
forall a b. (a -> b) -> a -> b
$ [Symbol] -> [Expr] -> [(Symbol, Expr)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Symbol]
xs [Expr]
es) (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ Expr -> Int -> Expr
dropApp Expr
e ([Symbol] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
xs Int -> Int -> Int
forall a. Num a => a -> a -> a
- [Expr] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Expr]
es)
  | Bool
otherwise
  = Expr
expr

dropApp :: Expr -> Int -> Expr
dropApp :: Expr -> Int -> Expr
dropApp Expr
e Int
i | Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Expr
e
dropApp (F.EApp Expr
e Expr
_) Int
i = Expr -> Int -> Expr
dropApp Expr
e (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1)
dropApp Expr
_ Int
_          = String -> Expr
forall a. (?callStack::CallStack) => String -> a
errorstar String
"impossible"

isApp :: Expr -> Bool
isApp :: Expr -> Bool
isApp (F.EApp (F.EVar Symbol
_) (F.EVar Symbol
_)) = Bool
True
isApp (F.EApp Expr
e (F.EVar Symbol
_))          = Expr -> Bool
isApp Expr
e
isApp Expr
_                              = Bool
False

data TyConP = TyConP
  { TyConP -> SourcePos
tcpLoc          :: !F.SourcePos
  , TyConP -> TyCon
tcpCon          :: !TyCon
  , TyConP -> [RTyVar]
tcpFreeTyVarsTy :: ![RTyVar]
  , TyConP -> [PVar RSort]
tcpFreePredTy   :: ![PVar RSort]
  , TyConP -> VarianceInfo
tcpVarianceTs   :: !VarianceInfo
  , TyConP -> VarianceInfo
tcpVariancePs   :: !VarianceInfo
  , TyConP -> Maybe SizeFun
tcpSizeFun      :: !(Maybe SizeFun)
  } deriving ((forall x. TyConP -> Rep TyConP x)
-> (forall x. Rep TyConP x -> TyConP) -> Generic TyConP
forall x. Rep TyConP x -> TyConP
forall x. TyConP -> Rep TyConP x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TyConP -> Rep TyConP x
from :: forall x. TyConP -> Rep TyConP x
$cto :: forall x. Rep TyConP x -> TyConP
to :: forall x. Rep TyConP x -> TyConP
Generic, Typeable TyConP
Typeable TyConP =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> TyConP -> c TyConP)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TyConP)
-> (TyConP -> Constr)
-> (TyConP -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TyConP))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP))
-> ((forall b. Data b => b -> b) -> TyConP -> TyConP)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConP -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConP -> r)
-> (forall u. (forall d. Data d => d -> u) -> TyConP -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TyConP -> m TyConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConP -> m TyConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConP -> m TyConP)
-> Data TyConP
TyConP -> Constr
TyConP -> DataType
(forall b. Data b => b -> b) -> TyConP -> TyConP
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u
forall u. (forall d. Data d => d -> u) -> TyConP -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConP
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConP -> c TyConP
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConP)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConP -> c TyConP
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConP -> c TyConP
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConP
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConP
$ctoConstr :: TyConP -> Constr
toConstr :: TyConP -> Constr
$cdataTypeOf :: TyConP -> DataType
dataTypeOf :: TyConP -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConP)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConP)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP)
$cgmapT :: (forall b. Data b => b -> b) -> TyConP -> TyConP
gmapT :: (forall b. Data b => b -> b) -> TyConP -> TyConP
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TyConP -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TyConP -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
Data, Typeable)

instance F.Loc TyConP where
  srcSpan :: TyConP -> SrcSpan
srcSpan TyConP
tc = SourcePos -> SourcePos -> SrcSpan
F.SS (TyConP -> SourcePos
tcpLoc TyConP
tc) (TyConP -> SourcePos
tcpLoc TyConP
tc)


-- TODO: just use Located instead of dc_loc, dc_locE
data DataConP = DataConP
  { DataConP -> SourcePos
dcpLoc        :: !F.SourcePos
  , DataConP -> DataCon
dcpCon        :: !DataCon                -- ^ Corresponding GHC DataCon
  , DataConP -> [RTyVar]
dcpFreeTyVars :: ![RTyVar]               -- ^ Type parameters
  , DataConP -> [PVar RSort]
dcpFreePred   :: ![PVar RSort]           -- ^ Abstract Refinement parameters
  , DataConP -> [SpecType]
dcpTyConstrs  :: ![SpecType]             -- ^ ? Class constraints (via `dataConStupidTheta`)
  , DataConP -> [(Symbol, SpecType)]
dcpTyArgs     :: ![(Symbol, SpecType)]   -- ^ Value parameters
  , DataConP -> SpecType
dcpTyRes      :: !SpecType               -- ^ Result type
  , DataConP -> Bool
dcpIsGadt     :: !Bool                   -- ^ Was this specified in GADT style (if so, DONT use function names as fields)
  , DataConP -> Symbol
dcpModule     :: !F.Symbol               -- ^ Which module was this defined in
  , DataConP -> SourcePos
dcpLocE       :: !F.SourcePos
  } deriving ((forall x. DataConP -> Rep DataConP x)
-> (forall x. Rep DataConP x -> DataConP) -> Generic DataConP
forall x. Rep DataConP x -> DataConP
forall x. DataConP -> Rep DataConP x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataConP -> Rep DataConP x
from :: forall x. DataConP -> Rep DataConP x
$cto :: forall x. Rep DataConP x -> DataConP
to :: forall x. Rep DataConP x -> DataConP
Generic, Typeable DataConP
Typeable DataConP =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataConP -> c DataConP)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataConP)
-> (DataConP -> Constr)
-> (DataConP -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataConP))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP))
-> ((forall b. Data b => b -> b) -> DataConP -> DataConP)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataConP -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataConP -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataConP -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataConP -> m DataConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataConP -> m DataConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataConP -> m DataConP)
-> Data DataConP
DataConP -> Constr
DataConP -> DataType
(forall b. Data b => b -> b) -> DataConP -> DataConP
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u
forall u. (forall d. Data d => d -> u) -> DataConP -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConP
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConP -> c DataConP
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConP)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConP -> c DataConP
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConP -> c DataConP
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConP
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConP
$ctoConstr :: DataConP -> Constr
toConstr :: DataConP -> Constr
$cdataTypeOf :: DataConP -> DataType
dataTypeOf :: DataConP -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConP)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConP)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP)
$cgmapT :: (forall b. Data b => b -> b) -> DataConP -> DataConP
gmapT :: (forall b. Data b => b -> b) -> DataConP -> DataConP
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataConP -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataConP -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
Data, Typeable)

-- | [NOTE:DataCon-Data] for each 'DataConP' we also
--   store the type of the constructed data. This is
--   *the same as* 'tyRes' for *vanilla* ADTs
--   (e.g. List, Maybe etc.) but may differ for GADTs.
--   For example,
--
--      data Thing a where
--        X  :: Thing Int
--        Y  :: Thing Bool
--
--   Here the 'DataConP' associated with 'X' (resp. 'Y')
--   has 'tyRes' corresponding to 'Thing Int' (resp. 'Thing Bool'),
--   but in both cases, the 'tyData' should be 'Thing a'.
--

instance F.Loc DataConP where
  srcSpan :: DataConP -> SrcSpan
srcSpan DataConP
d = SourcePos -> SourcePos -> SrcSpan
F.SS (DataConP -> SourcePos
dcpLoc DataConP
d) (DataConP -> SourcePos
dcpLocE DataConP
d)

-- | Which Top-Level Binders Should be Verified
data TargetVars = AllVars | Only ![Var]


--------------------------------------------------------------------
-- | Abstract Predicate Variables ----------------------------------
--------------------------------------------------------------------

data PVar t = PV
  { forall t. PVar t -> Symbol
pname :: !Symbol
  , forall t. PVar t -> PVKind t
ptype :: !(PVKind t)
  , forall t. PVar t -> Symbol
parg  :: !Symbol
  , forall t. PVar t -> [(t, Symbol, Expr)]
pargs :: ![(t, Symbol, Expr)]
  } deriving ((forall x. PVar t -> Rep (PVar t) x)
-> (forall x. Rep (PVar t) x -> PVar t) -> Generic (PVar t)
forall x. Rep (PVar t) x -> PVar t
forall x. PVar t -> Rep (PVar t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (PVar t) x -> PVar t
forall t x. PVar t -> Rep (PVar t) x
$cfrom :: forall t x. PVar t -> Rep (PVar t) x
from :: forall x. PVar t -> Rep (PVar t) x
$cto :: forall t x. Rep (PVar t) x -> PVar t
to :: forall x. Rep (PVar t) x -> PVar t
Generic, Typeable (PVar t)
Typeable (PVar t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> PVar t -> c (PVar t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PVar t))
-> (PVar t -> Constr)
-> (PVar t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (PVar t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t)))
-> ((forall b. Data b => b -> b) -> PVar t -> PVar t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PVar t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PVar t -> r)
-> (forall u. (forall d. Data d => d -> u) -> PVar t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PVar t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PVar t -> m (PVar t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVar t -> m (PVar t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVar t -> m (PVar t))
-> Data (PVar t)
PVar t -> Constr
PVar t -> DataType
(forall b. Data b => b -> b) -> PVar t -> PVar t
forall t. Data t => Typeable (PVar t)
forall t. Data t => PVar t -> Constr
forall t. Data t => PVar t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> PVar t -> PVar t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> PVar t -> u
forall t u. Data t => (forall d. Data d => d -> u) -> PVar t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
forall t r r'.
Data t =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVar t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> c (PVar t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PVar t -> u
forall u. (forall d. Data d => d -> u) -> PVar t -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVar t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> c (PVar t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> c (PVar t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> c (PVar t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVar t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVar t)
$ctoConstr :: forall t. Data t => PVar t -> Constr
toConstr :: PVar t -> Constr
$cdataTypeOf :: forall t. Data t => PVar t -> DataType
dataTypeOf :: PVar t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> PVar t -> PVar t
gmapT :: (forall b. Data b => b -> b) -> PVar t -> PVar t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
$cgmapQ :: forall t u. Data t => (forall d. Data d => d -> u) -> PVar t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PVar t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> PVar t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PVar t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
Data, Typeable, Int -> PVar t -> ShowS
[PVar t] -> ShowS
PVar t -> String
(Int -> PVar t -> ShowS)
-> (PVar t -> String) -> ([PVar t] -> ShowS) -> Show (PVar t)
forall t. Show t => Int -> PVar t -> ShowS
forall t. Show t => [PVar t] -> ShowS
forall t. Show t => PVar t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> PVar t -> ShowS
showsPrec :: Int -> PVar t -> ShowS
$cshow :: forall t. Show t => PVar t -> String
show :: PVar t -> String
$cshowList :: forall t. Show t => [PVar t] -> ShowS
showList :: [PVar t] -> ShowS
Show, (forall a b. (a -> b) -> PVar a -> PVar b)
-> (forall a b. a -> PVar b -> PVar a) -> Functor PVar
forall a b. a -> PVar b -> PVar a
forall a b. (a -> b) -> PVar a -> PVar b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> PVar a -> PVar b
fmap :: forall a b. (a -> b) -> PVar a -> PVar b
$c<$ :: forall a b. a -> PVar b -> PVar a
<$ :: forall a b. a -> PVar b -> PVar a
Functor)

instance Eq (PVar t) where
  PVar t
pv == :: PVar t -> PVar t -> Bool
== PVar t
pv' = PVar t -> Symbol
forall t. PVar t -> Symbol
pname PVar t
pv Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== PVar t -> Symbol
forall t. PVar t -> Symbol
pname PVar t
pv' {- UNIFY: What about: && eqArgs pv pv' -}

instance Ord (PVar t) where
  compare :: PVar t -> PVar t -> Ordering
compare (PV Symbol
n PVKind t
_ Symbol
_ [(t, Symbol, Expr)]
_)  (PV Symbol
n' PVKind t
_ Symbol
_ [(t, Symbol, Expr)]
_) = Symbol -> Symbol -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Symbol
n Symbol
n'

instance B.Binary t => B.Binary (PVar t)
instance NFData t   => NFData   (PVar t)

instance Hashable (PVar a) where
  hashWithSalt :: Int -> PVar a -> Int
hashWithSalt Int
i (PV Symbol
n PVKind a
_ Symbol
_ [(a, Symbol, Expr)]
_) = Int -> Symbol -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
i Symbol
n

pvType :: PVar t -> t
pvType :: forall t. PVar t -> t
pvType PVar t
p = case PVar t -> PVKind t
forall t. PVar t -> PVKind t
ptype PVar t
p of
             PVProp t
t -> t
t
             PVKind t
PVHProp  -> Maybe SrcSpan -> String -> t
forall a. Maybe SrcSpan -> String -> a
panic Maybe SrcSpan
forall a. Maybe a
Nothing String
"pvType on HProp-PVar"

data PVKind t
  = PVProp t
  | PVHProp
  deriving ((forall x. PVKind t -> Rep (PVKind t) x)
-> (forall x. Rep (PVKind t) x -> PVKind t) -> Generic (PVKind t)
forall x. Rep (PVKind t) x -> PVKind t
forall x. PVKind t -> Rep (PVKind t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (PVKind t) x -> PVKind t
forall t x. PVKind t -> Rep (PVKind t) x
$cfrom :: forall t x. PVKind t -> Rep (PVKind t) x
from :: forall x. PVKind t -> Rep (PVKind t) x
$cto :: forall t x. Rep (PVKind t) x -> PVKind t
to :: forall x. Rep (PVKind t) x -> PVKind t
Generic, Typeable (PVKind t)
Typeable (PVKind t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> PVKind t -> c (PVKind t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PVKind t))
-> (PVKind t -> Constr)
-> (PVKind t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (PVKind t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (PVKind t)))
-> ((forall b. Data b => b -> b) -> PVKind t -> PVKind t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PVKind t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PVKind t -> r)
-> (forall u. (forall d. Data d => d -> u) -> PVKind t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PVKind t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t))
-> Data (PVKind t)
PVKind t -> Constr
PVKind t -> DataType
(forall b. Data b => b -> b) -> PVKind t -> PVKind t
forall t. Data t => Typeable (PVKind t)
forall t. Data t => PVKind t -> Constr
forall t. Data t => PVKind t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> PVKind t -> PVKind t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> PVKind t -> u
forall t u.
Data t =>
(forall d. Data d => d -> u) -> PVKind t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVKind t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVKind t -> c (PVKind t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PVKind t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVKind t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PVKind t -> u
forall u. (forall d. Data d => d -> u) -> PVKind t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVKind t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVKind t -> c (PVKind t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVKind t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVKind t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVKind t -> c (PVKind t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVKind t -> c (PVKind t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVKind t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVKind t)
$ctoConstr :: forall t. Data t => PVKind t -> Constr
toConstr :: PVKind t -> Constr
$cdataTypeOf :: forall t. Data t => PVKind t -> DataType
dataTypeOf :: PVKind t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PVKind t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVKind t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVKind t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVKind t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> PVKind t -> PVKind t
gmapT :: (forall b. Data b => b -> b) -> PVKind t -> PVKind t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> PVKind t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PVKind t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> PVKind t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PVKind t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
Data, Typeable, (forall a b. (a -> b) -> PVKind a -> PVKind b)
-> (forall a b. a -> PVKind b -> PVKind a) -> Functor PVKind
forall a b. a -> PVKind b -> PVKind a
forall a b. (a -> b) -> PVKind a -> PVKind b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> PVKind a -> PVKind b
fmap :: forall a b. (a -> b) -> PVKind a -> PVKind b
$c<$ :: forall a b. a -> PVKind b -> PVKind a
<$ :: forall a b. a -> PVKind b -> PVKind a
Functor, (forall m. Monoid m => PVKind m -> m)
-> (forall m a. Monoid m => (a -> m) -> PVKind a -> m)
-> (forall m a. Monoid m => (a -> m) -> PVKind a -> m)
-> (forall a b. (a -> b -> b) -> b -> PVKind a -> b)
-> (forall a b. (a -> b -> b) -> b -> PVKind a -> b)
-> (forall b a. (b -> a -> b) -> b -> PVKind a -> b)
-> (forall b a. (b -> a -> b) -> b -> PVKind a -> b)
-> (forall a. (a -> a -> a) -> PVKind a -> a)
-> (forall a. (a -> a -> a) -> PVKind a -> a)
-> (forall a. PVKind a -> [a])
-> (forall a. PVKind a -> Bool)
-> (forall a. PVKind a -> Int)
-> (forall a. Eq a => a -> PVKind a -> Bool)
-> (forall a. Ord a => PVKind a -> a)
-> (forall a. Ord a => PVKind a -> a)
-> (forall a. Num a => PVKind a -> a)
-> (forall a. Num a => PVKind a -> a)
-> Foldable PVKind
forall a. Eq a => a -> PVKind a -> Bool
forall a. Num a => PVKind a -> a
forall a. Ord a => PVKind a -> a
forall m. Monoid m => PVKind m -> m
forall a. PVKind a -> Bool
forall a. PVKind a -> Int
forall a. PVKind a -> [a]
forall a. (a -> a -> a) -> PVKind a -> a
forall m a. Monoid m => (a -> m) -> PVKind a -> m
forall b a. (b -> a -> b) -> b -> PVKind a -> b
forall a b. (a -> b -> b) -> b -> PVKind a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => PVKind m -> m
fold :: forall m. Monoid m => PVKind m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> PVKind a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> PVKind a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> PVKind a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> PVKind a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> PVKind a -> b
foldr :: forall a b. (a -> b -> b) -> b -> PVKind a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> PVKind a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> PVKind a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> PVKind a -> b
foldl :: forall b a. (b -> a -> b) -> b -> PVKind a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> PVKind a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> PVKind a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> PVKind a -> a
foldr1 :: forall a. (a -> a -> a) -> PVKind a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> PVKind a -> a
foldl1 :: forall a. (a -> a -> a) -> PVKind a -> a
$ctoList :: forall a. PVKind a -> [a]
toList :: forall a. PVKind a -> [a]
$cnull :: forall a. PVKind a -> Bool
null :: forall a. PVKind a -> Bool
$clength :: forall a. PVKind a -> Int
length :: forall a. PVKind a -> Int
$celem :: forall a. Eq a => a -> PVKind a -> Bool
elem :: forall a. Eq a => a -> PVKind a -> Bool
$cmaximum :: forall a. Ord a => PVKind a -> a
maximum :: forall a. Ord a => PVKind a -> a
$cminimum :: forall a. Ord a => PVKind a -> a
minimum :: forall a. Ord a => PVKind a -> a
$csum :: forall a. Num a => PVKind a -> a
sum :: forall a. Num a => PVKind a -> a
$cproduct :: forall a. Num a => PVKind a -> a
product :: forall a. Num a => PVKind a -> a
F.Foldable, Functor PVKind
Foldable PVKind
(Functor PVKind, Foldable PVKind) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> PVKind a -> f (PVKind b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    PVKind (f a) -> f (PVKind a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> PVKind a -> m (PVKind b))
-> (forall (m :: * -> *) a.
    Monad m =>
    PVKind (m a) -> m (PVKind a))
-> Traversable PVKind
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => PVKind (m a) -> m (PVKind a)
forall (f :: * -> *) a.
Applicative f =>
PVKind (f a) -> f (PVKind a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> PVKind a -> m (PVKind b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> PVKind a -> f (PVKind b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> PVKind a -> f (PVKind b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> PVKind a -> f (PVKind b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
PVKind (f a) -> f (PVKind a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
PVKind (f a) -> f (PVKind a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> PVKind a -> m (PVKind b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> PVKind a -> m (PVKind b)
$csequence :: forall (m :: * -> *) a. Monad m => PVKind (m a) -> m (PVKind a)
sequence :: forall (m :: * -> *) a. Monad m => PVKind (m a) -> m (PVKind a)
Traversable, Int -> PVKind t -> ShowS
[PVKind t] -> ShowS
PVKind t -> String
(Int -> PVKind t -> ShowS)
-> (PVKind t -> String) -> ([PVKind t] -> ShowS) -> Show (PVKind t)
forall t. Show t => Int -> PVKind t -> ShowS
forall t. Show t => [PVKind t] -> ShowS
forall t. Show t => PVKind t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> PVKind t -> ShowS
showsPrec :: Int -> PVKind t -> ShowS
$cshow :: forall t. Show t => PVKind t -> String
show :: PVKind t -> String
$cshowList :: forall t. Show t => [PVKind t] -> ShowS
showList :: [PVKind t] -> ShowS
Show)

instance B.Binary a => B.Binary (PVKind a)
instance NFData a   => NFData   (PVKind a)


--------------------------------------------------------------------------------
-- | Predicates ----------------------------------------------------------------
--------------------------------------------------------------------------------

type UsedPVar      = PVar ()

newtype Predicate  = Pr [UsedPVar]
  deriving ((forall x. Predicate -> Rep Predicate x)
-> (forall x. Rep Predicate x -> Predicate) -> Generic Predicate
forall x. Rep Predicate x -> Predicate
forall x. Predicate -> Rep Predicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Predicate -> Rep Predicate x
from :: forall x. Predicate -> Rep Predicate x
$cto :: forall x. Rep Predicate x -> Predicate
to :: forall x. Rep Predicate x -> Predicate
Generic, Typeable Predicate
Typeable Predicate =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Predicate -> c Predicate)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Predicate)
-> (Predicate -> Constr)
-> (Predicate -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Predicate))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Predicate))
-> ((forall b. Data b => b -> b) -> Predicate -> Predicate)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Predicate -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Predicate -> r)
-> (forall u. (forall d. Data d => d -> u) -> Predicate -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Predicate -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Predicate -> m Predicate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Predicate -> m Predicate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Predicate -> m Predicate)
-> Data Predicate
Predicate -> Constr
Predicate -> DataType
(forall b. Data b => b -> b) -> Predicate -> Predicate
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Predicate -> u
forall u. (forall d. Data d => d -> u) -> Predicate -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Predicate -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Predicate -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Predicate
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Predicate -> c Predicate
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Predicate)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Predicate)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Predicate -> c Predicate
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Predicate -> c Predicate
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Predicate
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Predicate
$ctoConstr :: Predicate -> Constr
toConstr :: Predicate -> Constr
$cdataTypeOf :: Predicate -> DataType
dataTypeOf :: Predicate -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Predicate)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Predicate)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Predicate)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Predicate)
$cgmapT :: (forall b. Data b => b -> b) -> Predicate -> Predicate
gmapT :: (forall b. Data b => b -> b) -> Predicate -> Predicate
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Predicate -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Predicate -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Predicate -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Predicate -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Predicate -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Predicate -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Predicate -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Predicate -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Predicate -> m Predicate
Data, Typeable)
  deriving Eq Predicate
Eq Predicate =>
(Int -> Predicate -> Int)
-> (Predicate -> Int) -> Hashable Predicate
Int -> Predicate -> Int
Predicate -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Predicate -> Int
hashWithSalt :: Int -> Predicate -> Int
$chash :: Predicate -> Int
hash :: Predicate -> Int
Hashable via Generically Predicate

instance Eq Predicate where
  (Pr [UsedPVar]
vs) == :: Predicate -> Predicate -> Bool
== (Pr [UsedPVar]
ws)
      = [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> [Bool] -> Bool
forall a b. (a -> b) -> a -> b
$ ([UsedPVar] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [UsedPVar]
vs' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [UsedPVar] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [UsedPVar]
ws') Bool -> [Bool] -> [Bool]
forall a. a -> [a] -> [a]
: [UsedPVar
v UsedPVar -> UsedPVar -> Bool
forall a. Eq a => a -> a -> Bool
== UsedPVar
w | (UsedPVar
v, UsedPVar
w) <- [UsedPVar] -> [UsedPVar] -> [(UsedPVar, UsedPVar)]
forall a b. [a] -> [b] -> [(a, b)]
zip [UsedPVar]
vs' [UsedPVar]
ws']
        where
          vs' :: [UsedPVar]
vs' = [UsedPVar] -> [UsedPVar]
forall a. Ord a => [a] -> [a]
L.sort [UsedPVar]
vs
          ws' :: [UsedPVar]
ws' = [UsedPVar] -> [UsedPVar]
forall a. Ord a => [a] -> [a]
L.sort [UsedPVar]
ws



instance B.Binary Predicate

instance NFData Predicate where
  rnf :: Predicate -> ()
rnf Predicate
_ = ()

instance Monoid Predicate where
  mempty :: Predicate
mempty  = Predicate
pdTrue
  mappend :: Predicate -> Predicate -> Predicate
mappend = Predicate -> Predicate -> Predicate
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup Predicate where
  Predicate
p <> :: Predicate -> Predicate -> Predicate
<> Predicate
p' = [Predicate] -> Predicate
forall (t :: * -> *). Foldable t => t Predicate -> Predicate
pdAnd [Predicate
p, Predicate
p']

instance Semigroup a => Semigroup (UReft a) where
  MkUReft a
x Predicate
y <> :: UReft a -> UReft a -> UReft a
<> MkUReft a
x' Predicate
y' = a -> Predicate -> UReft a
forall r. r -> Predicate -> UReft r
MkUReft (a
x a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
x') (Predicate
y Predicate -> Predicate -> Predicate
forall a. Semigroup a => a -> a -> a
<> Predicate
y')

instance (Monoid a) => Monoid (UReft a) where
  mempty :: UReft a
mempty  = a -> Predicate -> UReft a
forall r. r -> Predicate -> UReft r
MkUReft a
forall a. Monoid a => a
mempty Predicate
forall a. Monoid a => a
mempty
  mappend :: UReft a -> UReft a -> UReft a
mappend = UReft a -> UReft a -> UReft a
forall a. Semigroup a => a -> a -> a
(<>)


pdTrue :: Predicate
pdTrue :: Predicate
pdTrue         = [UsedPVar] -> Predicate
Pr []

pdAnd :: Foldable t => t Predicate -> Predicate
pdAnd :: forall (t :: * -> *). Foldable t => t Predicate -> Predicate
pdAnd t Predicate
ps       = [UsedPVar] -> Predicate
Pr ([UsedPVar] -> [UsedPVar]
forall a. Eq a => [a] -> [a]
nub ([UsedPVar] -> [UsedPVar]) -> [UsedPVar] -> [UsedPVar]
forall a b. (a -> b) -> a -> b
$ (Predicate -> [UsedPVar]) -> t Predicate -> [UsedPVar]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Predicate -> [UsedPVar]
pvars t Predicate
ps)

pvars :: Predicate -> [UsedPVar]
pvars :: Predicate -> [UsedPVar]
pvars (Pr [UsedPVar]
pvs) = [UsedPVar]
pvs

instance F.Subable UsedPVar where
  syms :: UsedPVar -> [Symbol]
syms UsedPVar
pv         = [ Symbol
y | (()
_, Symbol
x, F.EVar Symbol
y) <- UsedPVar -> [((), Symbol, Expr)]
forall t. PVar t -> [(t, Symbol, Expr)]
pargs UsedPVar
pv, Symbol
x Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
/= Symbol
y ]
  subst :: Subst -> UsedPVar -> UsedPVar
subst Subst
s UsedPVar
pv      = UsedPVar
pv { pargs = mapThd3 (F.subst s)  <$> pargs pv }
  substf :: (Symbol -> Expr) -> UsedPVar -> UsedPVar
substf Symbol -> Expr
f UsedPVar
pv     = UsedPVar
pv { pargs = mapThd3 (F.substf f) <$> pargs pv }
  substa :: (Symbol -> Symbol) -> UsedPVar -> UsedPVar
substa Symbol -> Symbol
f UsedPVar
pv     = UsedPVar
pv { pargs = mapThd3 (F.substa f) <$> pargs pv }


instance F.Subable Predicate where
  syms :: Predicate -> [Symbol]
syms     (Pr [UsedPVar]
pvs) = (UsedPVar -> [Symbol]) -> [UsedPVar] -> [Symbol]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap UsedPVar -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms   [UsedPVar]
pvs
  subst :: Subst -> Predicate -> Predicate
subst  Subst
s (Pr [UsedPVar]
pvs) = [UsedPVar] -> Predicate
Pr (Subst -> UsedPVar -> UsedPVar
forall a. Subable a => Subst -> a -> a
F.subst Subst
s  (UsedPVar -> UsedPVar) -> [UsedPVar] -> [UsedPVar]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UsedPVar]
pvs)
  substf :: (Symbol -> Expr) -> Predicate -> Predicate
substf Symbol -> Expr
f (Pr [UsedPVar]
pvs) = [UsedPVar] -> Predicate
Pr ((Symbol -> Expr) -> UsedPVar -> UsedPVar
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f (UsedPVar -> UsedPVar) -> [UsedPVar] -> [UsedPVar]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UsedPVar]
pvs)
  substa :: (Symbol -> Symbol) -> Predicate -> Predicate
substa Symbol -> Symbol
f (Pr [UsedPVar]
pvs) = [UsedPVar] -> Predicate
Pr ((Symbol -> Symbol) -> UsedPVar -> UsedPVar
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f (UsedPVar -> UsedPVar) -> [UsedPVar] -> [UsedPVar]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UsedPVar]
pvs)

instance NFData r => NFData (UReft r)

data RelExpr = ERBasic F.Expr | ERChecked Expr RelExpr | ERUnChecked Expr RelExpr
  deriving (RelExpr -> RelExpr -> Bool
(RelExpr -> RelExpr -> Bool)
-> (RelExpr -> RelExpr -> Bool) -> Eq RelExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RelExpr -> RelExpr -> Bool
== :: RelExpr -> RelExpr -> Bool
$c/= :: RelExpr -> RelExpr -> Bool
/= :: RelExpr -> RelExpr -> Bool
Eq, Int -> RelExpr -> ShowS
[RelExpr] -> ShowS
RelExpr -> String
(Int -> RelExpr -> ShowS)
-> (RelExpr -> String) -> ([RelExpr] -> ShowS) -> Show RelExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RelExpr -> ShowS
showsPrec :: Int -> RelExpr -> ShowS
$cshow :: RelExpr -> String
show :: RelExpr -> String
$cshowList :: [RelExpr] -> ShowS
showList :: [RelExpr] -> ShowS
Show, Typeable RelExpr
Typeable RelExpr =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RelExpr -> c RelExpr)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RelExpr)
-> (RelExpr -> Constr)
-> (RelExpr -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RelExpr))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelExpr))
-> ((forall b. Data b => b -> b) -> RelExpr -> RelExpr)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RelExpr -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RelExpr -> r)
-> (forall u. (forall d. Data d => d -> u) -> RelExpr -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RelExpr -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RelExpr -> m RelExpr)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RelExpr -> m RelExpr)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RelExpr -> m RelExpr)
-> Data RelExpr
RelExpr -> Constr
RelExpr -> DataType
(forall b. Data b => b -> b) -> RelExpr -> RelExpr
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RelExpr -> u
forall u. (forall d. Data d => d -> u) -> RelExpr -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelExpr
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelExpr -> c RelExpr
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelExpr)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelExpr)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelExpr -> c RelExpr
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelExpr -> c RelExpr
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelExpr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelExpr
$ctoConstr :: RelExpr -> Constr
toConstr :: RelExpr -> Constr
$cdataTypeOf :: RelExpr -> DataType
dataTypeOf :: RelExpr -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelExpr)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelExpr)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelExpr)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelExpr)
$cgmapT :: (forall b. Data b => b -> b) -> RelExpr -> RelExpr
gmapT :: (forall b. Data b => b -> b) -> RelExpr -> RelExpr
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RelExpr -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RelExpr -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RelExpr -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RelExpr -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
Data, (forall x. RelExpr -> Rep RelExpr x)
-> (forall x. Rep RelExpr x -> RelExpr) -> Generic RelExpr
forall x. Rep RelExpr x -> RelExpr
forall x. RelExpr -> Rep RelExpr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RelExpr -> Rep RelExpr x
from :: forall x. RelExpr -> Rep RelExpr x
$cto :: forall x. Rep RelExpr x -> RelExpr
to :: forall x. Rep RelExpr x -> RelExpr
Generic)

instance B.Binary RelExpr

instance F.PPrint RelExpr where
  pprintTidy :: Tidy -> RelExpr -> Doc
pprintTidy Tidy
k (ERBasic Expr
e)       = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e
  pprintTidy Tidy
k (ERChecked Expr
e RelExpr
r)   = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e Doc -> Doc -> Doc
<+> Doc
"!=>" Doc -> Doc -> Doc
<+> Tidy -> RelExpr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k RelExpr
r
  pprintTidy Tidy
k (ERUnChecked Expr
e RelExpr
r) = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e Doc -> Doc -> Doc
<+> Doc
":=>" Doc -> Doc -> Doc
<+> Tidy -> RelExpr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k RelExpr
r

newtype BTyVar = BTV Symbol deriving (Int -> BTyVar -> ShowS
[BTyVar] -> ShowS
BTyVar -> String
(Int -> BTyVar -> ShowS)
-> (BTyVar -> String) -> ([BTyVar] -> ShowS) -> Show BTyVar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BTyVar -> ShowS
showsPrec :: Int -> BTyVar -> ShowS
$cshow :: BTyVar -> String
show :: BTyVar -> String
$cshowList :: [BTyVar] -> ShowS
showList :: [BTyVar] -> ShowS
Show, (forall x. BTyVar -> Rep BTyVar x)
-> (forall x. Rep BTyVar x -> BTyVar) -> Generic BTyVar
forall x. Rep BTyVar x -> BTyVar
forall x. BTyVar -> Rep BTyVar x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BTyVar -> Rep BTyVar x
from :: forall x. BTyVar -> Rep BTyVar x
$cto :: forall x. Rep BTyVar x -> BTyVar
to :: forall x. Rep BTyVar x -> BTyVar
Generic, Typeable BTyVar
Typeable BTyVar =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> BTyVar -> c BTyVar)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BTyVar)
-> (BTyVar -> Constr)
-> (BTyVar -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BTyVar))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar))
-> ((forall b. Data b => b -> b) -> BTyVar -> BTyVar)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyVar -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyVar -> r)
-> (forall u. (forall d. Data d => d -> u) -> BTyVar -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BTyVar -> m BTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyVar -> m BTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyVar -> m BTyVar)
-> Data BTyVar
BTyVar -> Constr
BTyVar -> DataType
(forall b. Data b => b -> b) -> BTyVar -> BTyVar
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u
forall u. (forall d. Data d => d -> u) -> BTyVar -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyVar
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyVar -> c BTyVar
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyVar)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyVar -> c BTyVar
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyVar -> c BTyVar
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyVar
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyVar
$ctoConstr :: BTyVar -> Constr
toConstr :: BTyVar -> Constr
$cdataTypeOf :: BTyVar -> DataType
dataTypeOf :: BTyVar -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyVar)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyVar)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar)
$cgmapT :: (forall b. Data b => b -> b) -> BTyVar -> BTyVar
gmapT :: (forall b. Data b => b -> b) -> BTyVar -> BTyVar
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BTyVar -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> BTyVar -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
Data, Typeable)

newtype RTyVar = RTV TyVar deriving ((forall x. RTyVar -> Rep RTyVar x)
-> (forall x. Rep RTyVar x -> RTyVar) -> Generic RTyVar
forall x. Rep RTyVar x -> RTyVar
forall x. RTyVar -> Rep RTyVar x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RTyVar -> Rep RTyVar x
from :: forall x. RTyVar -> Rep RTyVar x
$cto :: forall x. Rep RTyVar x -> RTyVar
to :: forall x. Rep RTyVar x -> RTyVar
Generic, Typeable RTyVar
Typeable RTyVar =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RTyVar -> c RTyVar)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RTyVar)
-> (RTyVar -> Constr)
-> (RTyVar -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RTyVar))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyVar))
-> ((forall b. Data b => b -> b) -> RTyVar -> RTyVar)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyVar -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyVar -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTyVar -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RTyVar -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTyVar -> m RTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyVar -> m RTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyVar -> m RTyVar)
-> Data RTyVar
RTyVar -> Constr
RTyVar -> DataType
(forall b. Data b => b -> b) -> RTyVar -> RTyVar
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTyVar -> u
forall u. (forall d. Data d => d -> u) -> RTyVar -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RTyVar -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RTyVar -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RTyVar
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyVar -> c RTyVar
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RTyVar)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyVar)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyVar -> c RTyVar
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyVar -> c RTyVar
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RTyVar
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RTyVar
$ctoConstr :: RTyVar -> Constr
toConstr :: RTyVar -> Constr
$cdataTypeOf :: RTyVar -> DataType
dataTypeOf :: RTyVar -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RTyVar)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RTyVar)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyVar)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyVar)
$cgmapT :: (forall b. Data b => b -> b) -> RTyVar -> RTyVar
gmapT :: (forall b. Data b => b -> b) -> RTyVar -> RTyVar
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RTyVar -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RTyVar -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RTyVar -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RTyVar -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RTyVar -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTyVar -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTyVar -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTyVar -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyVar -> m RTyVar
Data, Typeable)

instance Eq BTyVar where
  (BTV Symbol
x) == :: BTyVar -> BTyVar -> Bool
== (BTV Symbol
y) = Symbol
x Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== Symbol
y

instance Ord BTyVar where
  compare :: BTyVar -> BTyVar -> Ordering
compare (BTV Symbol
x) (BTV Symbol
y) = Symbol -> Symbol -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Symbol
x Symbol
y

instance IsString BTyVar where
  fromString :: String -> BTyVar
fromString = Symbol -> BTyVar
BTV (Symbol -> BTyVar) -> (String -> Symbol) -> String -> BTyVar
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Symbol
forall a. IsString a => String -> a
fromString

instance B.Binary BTyVar
instance Hashable BTyVar
instance NFData   BTyVar
instance NFData   RTyVar

instance F.Symbolic BTyVar where
  symbol :: BTyVar -> Symbol
symbol (BTV Symbol
tv) = Symbol
tv

instance F.Symbolic RTyVar where
  symbol :: RTyVar -> Symbol
symbol (RTV Var
tv) = Var -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol Var
tv -- tyVarUniqueSymbol tv

-- instance F.Symbolic RTyVar where
  -- symbol (RTV tv) = F.symbol . getName $ tv
-- rtyVarUniqueSymbol  :: RTyVar -> Symbol
-- rtyVarUniqueSymbol (RTV tv) = tyVarUniqueSymbol tv
-- tyVarUniqueSymbol :: TyVar -> Symbol
-- tyVarUniqueSymbol tv = F.symbol $ show (getName tv) ++ "_" ++ show (varUnique tv)

data BTyCon = BTyCon
  { BTyCon -> LocSymbol
btc_tc    :: !F.LocSymbol    -- ^ TyCon name with location information
  , BTyCon -> Bool
btc_class :: !Bool           -- ^ Is this a class type constructor?
  , BTyCon -> Bool
btc_prom  :: !Bool           -- ^ Is Promoted Data Con?
  }
  deriving ((forall x. BTyCon -> Rep BTyCon x)
-> (forall x. Rep BTyCon x -> BTyCon) -> Generic BTyCon
forall x. Rep BTyCon x -> BTyCon
forall x. BTyCon -> Rep BTyCon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BTyCon -> Rep BTyCon x
from :: forall x. BTyCon -> Rep BTyCon x
$cto :: forall x. Rep BTyCon x -> BTyCon
to :: forall x. Rep BTyCon x -> BTyCon
Generic, Typeable BTyCon
Typeable BTyCon =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> BTyCon -> c BTyCon)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BTyCon)
-> (BTyCon -> Constr)
-> (BTyCon -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BTyCon))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon))
-> ((forall b. Data b => b -> b) -> BTyCon -> BTyCon)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyCon -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyCon -> r)
-> (forall u. (forall d. Data d => d -> u) -> BTyCon -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BTyCon -> m BTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyCon -> m BTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyCon -> m BTyCon)
-> Data BTyCon
BTyCon -> Constr
BTyCon -> DataType
(forall b. Data b => b -> b) -> BTyCon -> BTyCon
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u
forall u. (forall d. Data d => d -> u) -> BTyCon -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyCon
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyCon -> c BTyCon
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyCon)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyCon -> c BTyCon
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyCon -> c BTyCon
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyCon
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyCon
$ctoConstr :: BTyCon -> Constr
toConstr :: BTyCon -> Constr
$cdataTypeOf :: BTyCon -> DataType
dataTypeOf :: BTyCon -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyCon)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyCon)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon)
$cgmapT :: (forall b. Data b => b -> b) -> BTyCon -> BTyCon
gmapT :: (forall b. Data b => b -> b) -> BTyCon -> BTyCon
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BTyCon -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> BTyCon -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
Data, Typeable)
  deriving Eq BTyCon
Eq BTyCon =>
(Int -> BTyCon -> Int) -> (BTyCon -> Int) -> Hashable BTyCon
Int -> BTyCon -> Int
BTyCon -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> BTyCon -> Int
hashWithSalt :: Int -> BTyCon -> Int
$chash :: BTyCon -> Int
hash :: BTyCon -> Int
Hashable via Generically BTyCon

instance B.Binary BTyCon

data RTyCon = RTyCon
  { RTyCon -> TyCon
rtc_tc    :: TyCon         -- ^ GHC Type Constructor
  , RTyCon -> [PVar RSort]
rtc_pvars :: ![RPVar]      -- ^ Predicate Parameters
  , RTyCon -> TyConInfo
rtc_info  :: !TyConInfo    -- ^ TyConInfo
  }
  deriving ((forall x. RTyCon -> Rep RTyCon x)
-> (forall x. Rep RTyCon x -> RTyCon) -> Generic RTyCon
forall x. Rep RTyCon x -> RTyCon
forall x. RTyCon -> Rep RTyCon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RTyCon -> Rep RTyCon x
from :: forall x. RTyCon -> Rep RTyCon x
$cto :: forall x. Rep RTyCon x -> RTyCon
to :: forall x. Rep RTyCon x -> RTyCon
Generic, Typeable RTyCon
Typeable RTyCon =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RTyCon -> c RTyCon)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RTyCon)
-> (RTyCon -> Constr)
-> (RTyCon -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RTyCon))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyCon))
-> ((forall b. Data b => b -> b) -> RTyCon -> RTyCon)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyCon -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyCon -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTyCon -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RTyCon -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTyCon -> m RTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyCon -> m RTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyCon -> m RTyCon)
-> Data RTyCon
RTyCon -> Constr
RTyCon -> DataType
(forall b. Data b => b -> b) -> RTyCon -> RTyCon
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTyCon -> u
forall u. (forall d. Data d => d -> u) -> RTyCon -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RTyCon -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RTyCon -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RTyCon
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyCon -> c RTyCon
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RTyCon)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyCon)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyCon -> c RTyCon
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyCon -> c RTyCon
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RTyCon
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RTyCon
$ctoConstr :: RTyCon -> Constr
toConstr :: RTyCon -> Constr
$cdataTypeOf :: RTyCon -> DataType
dataTypeOf :: RTyCon -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RTyCon)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RTyCon)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyCon)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyCon)
$cgmapT :: (forall b. Data b => b -> b) -> RTyCon -> RTyCon
gmapT :: (forall b. Data b => b -> b) -> RTyCon -> RTyCon
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RTyCon -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RTyCon -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RTyCon -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RTyCon -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RTyCon -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTyCon -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTyCon -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTyCon -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTyCon -> m RTyCon
Data, Typeable)

instance F.Symbolic RTyCon where
  symbol :: RTyCon -> Symbol
symbol = TyCon -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (TyCon -> Symbol) -> (RTyCon -> TyCon) -> RTyCon -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc

instance F.Symbolic BTyCon where
  symbol :: BTyCon -> Symbol
symbol = LocSymbol -> Symbol
forall a. Located a -> a
F.val (LocSymbol -> Symbol) -> (BTyCon -> LocSymbol) -> BTyCon -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc

instance NFData BTyCon

instance NFData RTyCon

rtyVarType :: RTyVar -> Type
rtyVarType :: RTyVar -> Type
rtyVarType (RTV Var
v) = Var -> Type
TyVarTy Var
v

tyVarVar :: RTVar RTyVar c -> Var
tyVarVar :: forall c. RTVar RTyVar c -> Var
tyVarVar (RTVar (RTV Var
v) RTVInfo c
_) = Var
v



mkBTyCon :: F.LocSymbol -> BTyCon
mkBTyCon :: LocSymbol -> BTyCon
mkBTyCon LocSymbol
x = LocSymbol -> Bool -> Bool -> BTyCon
BTyCon LocSymbol
x Bool
False Bool
False


-- | Accessors for @RTyCon@

isBool :: RType RTyCon t t1 -> Bool
isBool :: forall t t1. RType RTyCon t t1 -> Bool
isBool (RApp RTyCon{rtc_tc :: RTyCon -> TyCon
rtc_tc = TyCon
c} [RType RTyCon t t1]
_ [RTProp RTyCon t t1]
_ t1
_) = TyCon
c TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
== TyCon
boolTyCon
isBool RType RTyCon t t1
_                                 = Bool
False

isRVar :: RType c tv r -> Bool
isRVar :: forall c tv r. RType c tv r -> Bool
isRVar (RVar tv
_ r
_) = Bool
True
isRVar RType c tv r
_          = Bool
False

isClassBTyCon :: BTyCon -> Bool
isClassBTyCon :: BTyCon -> Bool
isClassBTyCon = BTyCon -> Bool
btc_class

-- isClassRTyCon :: RTyCon -> Bool
-- isClassRTyCon x = (isClassTyCon $ rtc_tc x) || (rtc_tc x == eqPrimTyCon)

rTyConPVs :: RTyCon -> [RPVar]
rTyConPVs :: RTyCon -> [PVar RSort]
rTyConPVs     = RTyCon -> [PVar RSort]
rtc_pvars

rTyConPropVs :: RTyCon -> [PVar RSort]
rTyConPropVs :: RTyCon -> [PVar RSort]
rTyConPropVs  = (PVar RSort -> Bool) -> [PVar RSort] -> [PVar RSort]
forall a. (a -> Bool) -> [a] -> [a]
filter PVar RSort -> Bool
forall t. PVar t -> Bool
isPropPV ([PVar RSort] -> [PVar RSort])
-> (RTyCon -> [PVar RSort]) -> RTyCon -> [PVar RSort]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> [PVar RSort]
rtc_pvars

isPropPV :: PVar t -> Bool
isPropPV :: forall t. PVar t -> Bool
isPropPV      = PVKind t -> Bool
forall a. PVKind a -> Bool
isProp (PVKind t -> Bool) -> (PVar t -> PVKind t) -> PVar t -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PVar t -> PVKind t
forall t. PVar t -> PVKind t
ptype

isEqType :: TyConable c => RType c t t1 -> Bool
isEqType :: forall c t t1. TyConable c => RType c t t1 -> Bool
isEqType (RApp c
c [RType c t t1]
_ [RTProp c t t1]
_ t1
_) = c -> Bool
forall c. TyConable c => c -> Bool
isEqual c
c
isEqType RType c t t1
_              = Bool
False


isClassType :: TyConable c => RType c t t1 -> Bool
isClassType :: forall c t t1. TyConable c => RType c t t1 -> Bool
isClassType (RApp c
c [RType c t t1]
_ [RTProp c t t1]
_ t1
_) = c -> Bool
forall c. TyConable c => c -> Bool
isClass c
c
isClassType RType c t t1
_              = Bool
False

isEmbeddedClass :: TyConable c => RType c t t1 -> Bool
isEmbeddedClass :: forall c t t1. TyConable c => RType c t t1 -> Bool
isEmbeddedClass (RApp c
c [RType c t t1]
_ [RTProp c t t1]
_ t1
_) = c -> Bool
forall c. TyConable c => c -> Bool
isEmbeddedDict c
c
isEmbeddedClass RType c t t1
_              = Bool
False

-- rTyConPVHPs = filter isHPropPV . rtc_pvars
-- isHPropPV   = not . isPropPV

isProp :: PVKind t -> Bool
isProp :: forall a. PVKind a -> Bool
isProp (PVProp t
_) = Bool
True
isProp PVKind t
_          = Bool
False


defaultTyConInfo :: TyConInfo
defaultTyConInfo :: TyConInfo
defaultTyConInfo = VarianceInfo -> VarianceInfo -> Maybe SizeFun -> TyConInfo
TyConInfo [] [] Maybe SizeFun
forall a. Maybe a
Nothing

instance Default TyConInfo where
  def :: TyConInfo
def = TyConInfo
defaultTyConInfo


-----------------------------------------------------------------------
-- | Co- and Contra-variance for TyCon --------------------------------
-----------------------------------------------------------------------

-- | Indexes start from 0 and type or predicate arguments can be both
--   covariant and contravaariant e.g., for the below Foo dataType
--
--     data Foo a b c d <p :: b -> Prop, q :: Int -> Prop, r :: a -> Prop>
--       = F (a<r> -> b<p>) | Q (c -> a) | G (Int<q> -> a<r>)
--
--  there will be:
--
--    varianceTyArgs     = [Bivariant , Covariant, Contravatiant, Invariant]
--    variancePsArgs     = [Covariant, Contravatiant, Bivariant]
--

data TyConInfo = TyConInfo
  { TyConInfo -> VarianceInfo
varianceTyArgs  :: !VarianceInfo      -- ^ variance info for type variables
  , TyConInfo -> VarianceInfo
variancePsArgs  :: !VarianceInfo      -- ^ variance info for predicate variables
  , TyConInfo -> Maybe SizeFun
sizeFunction    :: !(Maybe SizeFun)   -- ^ logical UNARY function that computes the size of the structure
  } deriving ((forall x. TyConInfo -> Rep TyConInfo x)
-> (forall x. Rep TyConInfo x -> TyConInfo) -> Generic TyConInfo
forall x. Rep TyConInfo x -> TyConInfo
forall x. TyConInfo -> Rep TyConInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TyConInfo -> Rep TyConInfo x
from :: forall x. TyConInfo -> Rep TyConInfo x
$cto :: forall x. Rep TyConInfo x -> TyConInfo
to :: forall x. Rep TyConInfo x -> TyConInfo
Generic, Typeable TyConInfo
Typeable TyConInfo =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> TyConInfo -> c TyConInfo)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TyConInfo)
-> (TyConInfo -> Constr)
-> (TyConInfo -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TyConInfo))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo))
-> ((forall b. Data b => b -> b) -> TyConInfo -> TyConInfo)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConInfo -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConInfo -> r)
-> (forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TyConInfo -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo)
-> Data TyConInfo
TyConInfo -> Constr
TyConInfo -> DataType
(forall b. Data b => b -> b) -> TyConInfo -> TyConInfo
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConInfo
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConInfo -> c TyConInfo
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConInfo)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConInfo -> c TyConInfo
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConInfo -> c TyConInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConInfo
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConInfo
$ctoConstr :: TyConInfo -> Constr
toConstr :: TyConInfo -> Constr
$cdataTypeOf :: TyConInfo -> DataType
dataTypeOf :: TyConInfo -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConInfo)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo)
$cgmapT :: (forall b. Data b => b -> b) -> TyConInfo -> TyConInfo
gmapT :: (forall b. Data b => b -> b) -> TyConInfo -> TyConInfo
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
Data, Typeable)

instance NFData TyConInfo

instance Show TyConInfo where
  show :: TyConInfo -> String
show (TyConInfo VarianceInfo
x VarianceInfo
y Maybe SizeFun
_) = VarianceInfo -> String
forall a. Show a => a -> String
show VarianceInfo
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\n" String -> ShowS
forall a. [a] -> [a] -> [a]
++ VarianceInfo -> String
forall a. Show a => a -> String
show VarianceInfo
y

--------------------------------------------------------------------------------
-- | Unified Representation of Refinement Types --------------------------------
--------------------------------------------------------------------------------

type RTVU c tv = RTVar tv (RType c tv ())
type PVU  c tv = PVar     (RType c tv ())

instance Show tv => Show (RTVU c tv) where
  show :: RTVU c tv -> String
show (RTVar tv
t RTVInfo (RType c tv ())
_) = tv -> String
forall a. Show a => a -> String
show tv
t

data RType c tv r
  = RVar {
      forall c tv r. RType c tv r -> tv
rt_var    :: !tv
    , forall c tv r. RType c tv r -> r
rt_reft   :: !r
    }

  | RFun  {
      forall c tv r. RType c tv r -> Symbol
rt_bind   :: !Symbol
    , forall c tv r. RType c tv r -> RFInfo
rt_rinfo  :: !RFInfo
    , forall c tv r. RType c tv r -> RType c tv r
rt_in     :: !(RType c tv r)
    , forall c tv r. RType c tv r -> RType c tv r
rt_out    :: !(RType c tv r)
    , rt_reft   :: !r
    }

  | RAllT {
      forall c tv r. RType c tv r -> RTVU c tv
rt_tvbind :: !(RTVU c tv) -- RTVar tv (RType c tv ()))
    , forall c tv r. RType c tv r -> RType c tv r
rt_ty     :: !(RType c tv r)
    , forall c tv r. RType c tv r -> r
rt_ref    :: !r
    }

  -- | "forall x y <z :: Nat, w :: Int> . TYPE"
  --               ^^^^^^^^^^^^^^^^^^^ (rt_pvbind)
  | RAllP {
      forall c tv r. RType c tv r -> PVU c tv
rt_pvbind :: !(PVU c tv)
    , rt_ty     :: !(RType c tv r)
    }

  -- | For example, in [a]<{\h -> v > h}>, we apply (via `RApp`)
  --   * the `RProp`  denoted by `{\h -> v > h}` to
  --   * the `RTyCon` denoted by `[]`.
  | RApp  {
      forall c tv r. RType c tv r -> c
rt_tycon  :: !c
    , forall c tv r. RType c tv r -> [RType c tv r]
rt_args   :: ![RType  c tv r]
    , forall c tv r. RType c tv r -> [RTProp c tv r]
rt_pargs  :: ![RTProp c tv r]
    , rt_reft   :: !r
    }

  | RAllE {
      rt_bind   :: !Symbol
    , forall c tv r. RType c tv r -> RType c tv r
rt_allarg :: !(RType c tv r)
    , rt_ty     :: !(RType c tv r)
    }

  | REx {
      rt_bind   :: !Symbol
    , forall c tv r. RType c tv r -> RType c tv r
rt_exarg  :: !(RType c tv r)
    , rt_ty     :: !(RType c tv r)
    }

  | RExprArg (F.Located Expr)                   -- ^ For expression arguments to type aliases
                                                --   see tests/pos/vector2.hs
  | RAppTy{
      forall c tv r. RType c tv r -> RType c tv r
rt_arg   :: !(RType c tv r)
    , forall c tv r. RType c tv r -> RType c tv r
rt_res   :: !(RType c tv r)
    , rt_reft  :: !r
    }

  | RRTy  {
      forall c tv r. RType c tv r -> [(Symbol, RType c tv r)]
rt_env   :: ![(Symbol, RType c tv r)]
    , rt_ref   :: !r
    , forall c tv r. RType c tv r -> Oblig
rt_obl   :: !Oblig
    , rt_ty    :: !(RType c tv r)
    }

  | RHole r -- ^ let LH match against the Haskell type and add k-vars, e.g. `x:_`
            --   see tests/pos/Holes.hs
  deriving (RType c tv r -> RType c tv r -> Bool
(RType c tv r -> RType c tv r -> Bool)
-> (RType c tv r -> RType c tv r -> Bool) -> Eq (RType c tv r)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall c tv r.
(Eq tv, Eq c, Eq r) =>
RType c tv r -> RType c tv r -> Bool
$c== :: forall c tv r.
(Eq tv, Eq c, Eq r) =>
RType c tv r -> RType c tv r -> Bool
== :: RType c tv r -> RType c tv r -> Bool
$c/= :: forall c tv r.
(Eq tv, Eq c, Eq r) =>
RType c tv r -> RType c tv r -> Bool
/= :: RType c tv r -> RType c tv r -> Bool
Eq, (forall x. RType c tv r -> Rep (RType c tv r) x)
-> (forall x. Rep (RType c tv r) x -> RType c tv r)
-> Generic (RType c tv r)
forall x. Rep (RType c tv r) x -> RType c tv r
forall x. RType c tv r -> Rep (RType c tv r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c tv r x. Rep (RType c tv r) x -> RType c tv r
forall c tv r x. RType c tv r -> Rep (RType c tv r) x
$cfrom :: forall c tv r x. RType c tv r -> Rep (RType c tv r) x
from :: forall x. RType c tv r -> Rep (RType c tv r) x
$cto :: forall c tv r x. Rep (RType c tv r) x -> RType c tv r
to :: forall x. Rep (RType c tv r) x -> RType c tv r
Generic, Typeable (RType c tv r)
Typeable (RType c tv r) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RType c tv r))
-> (RType c tv r -> Constr)
-> (RType c tv r -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RType c tv r)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RType c tv r)))
-> ((forall b. Data b => b -> b) -> RType c tv r -> RType c tv r)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RType c tv r -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RType c tv r -> r)
-> (forall u. (forall d. Data d => d -> u) -> RType c tv r -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RType c tv r -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r))
-> Data (RType c tv r)
RType c tv r -> Constr
RType c tv r -> DataType
(forall b. Data b => b -> b) -> RType c tv r -> RType c tv r
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
forall u. (forall d. Data d => d -> u) -> RType c tv r -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall c tv r. (Data tv, Data c, Data r) => Typeable (RType c tv r)
forall c tv r. (Data tv, Data c, Data r) => RType c tv r -> Constr
forall c tv r.
(Data tv, Data c, Data r) =>
RType c tv r -> DataType
forall c tv r.
(Data tv, Data c, Data r) =>
(forall b. Data b => b -> b) -> RType c tv r -> RType c tv r
forall c tv r u.
(Data tv, Data c, Data r) =>
Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
forall c tv r u.
(Data tv, Data c, Data r) =>
(forall d. Data d => d -> u) -> RType c tv r -> [u]
forall c tv r r r'.
(Data tv, Data c, Data r) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall c tv r r r'.
(Data tv, Data c, Data r) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall c tv r (m :: * -> *).
(Data tv, Data c, Data r, Monad m) =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
forall c tv r (m :: * -> *).
(Data tv, Data c, Data r, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
forall c tv r (c :: * -> *).
(Data tv, Data c, Data r) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
forall c tv r (c :: * -> *).
(Data tv, Data c, Data r) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r)
forall c tv r (t :: * -> *) (c :: * -> *).
(Data tv, Data c, Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
forall c tv r (t :: * -> * -> *) (c :: * -> *).
(Data tv, Data c, Data r, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RType c tv r))
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RType c tv r))
$cgfoldl :: forall c tv r (c :: * -> *).
(Data tv, Data c, Data r) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r)
$cgunfold :: forall c tv r (c :: * -> *).
(Data tv, Data c, Data r) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
$ctoConstr :: forall c tv r. (Data tv, Data c, Data r) => RType c tv r -> Constr
toConstr :: RType c tv r -> Constr
$cdataTypeOf :: forall c tv r.
(Data tv, Data c, Data r) =>
RType c tv r -> DataType
dataTypeOf :: RType c tv r -> DataType
$cdataCast1 :: forall c tv r (t :: * -> *) (c :: * -> *).
(Data tv, Data c, Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
$cdataCast2 :: forall c tv r (t :: * -> * -> *) (c :: * -> *).
(Data tv, Data c, Data r, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RType c tv r))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RType c tv r))
$cgmapT :: forall c tv r.
(Data tv, Data c, Data r) =>
(forall b. Data b => b -> b) -> RType c tv r -> RType c tv r
gmapT :: (forall b. Data b => b -> b) -> RType c tv r -> RType c tv r
$cgmapQl :: forall c tv r r r'.
(Data tv, Data c, Data r) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
$cgmapQr :: forall c tv r r r'.
(Data tv, Data c, Data r) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
$cgmapQ :: forall c tv r u.
(Data tv, Data c, Data r) =>
(forall d. Data d => d -> u) -> RType c tv r -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RType c tv r -> [u]
$cgmapQi :: forall c tv r u.
(Data tv, Data c, Data r) =>
Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
$cgmapM :: forall c tv r (m :: * -> *).
(Data tv, Data c, Data r, Monad m) =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
$cgmapMp :: forall c tv r (m :: * -> *).
(Data tv, Data c, Data r, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
$cgmapMo :: forall c tv r (m :: * -> *).
(Data tv, Data c, Data r, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
Data, Typeable, (forall a b. (a -> b) -> RType c tv a -> RType c tv b)
-> (forall a b. a -> RType c tv b -> RType c tv a)
-> Functor (RType c tv)
forall a b. a -> RType c tv b -> RType c tv a
forall a b. (a -> b) -> RType c tv a -> RType c tv b
forall c tv a b. a -> RType c tv b -> RType c tv a
forall c tv a b. (a -> b) -> RType c tv a -> RType c tv b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall c tv a b. (a -> b) -> RType c tv a -> RType c tv b
fmap :: forall a b. (a -> b) -> RType c tv a -> RType c tv b
$c<$ :: forall c tv a b. a -> RType c tv b -> RType c tv a
<$ :: forall a b. a -> RType c tv b -> RType c tv a
Functor)
  deriving Eq (RType c tv r)
Eq (RType c tv r) =>
(Int -> RType c tv r -> Int)
-> (RType c tv r -> Int) -> Hashable (RType c tv r)
Int -> RType c tv r -> Int
RType c tv r -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
Eq (RType c tv r)
forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
Int -> RType c tv r -> Int
forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
RType c tv r -> Int
$chashWithSalt :: forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
Int -> RType c tv r -> Int
hashWithSalt :: Int -> RType c tv r -> Int
$chash :: forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
RType c tv r -> Int
hash :: RType c tv r -> Int
Hashable via Generically (RType c tv r)

instance (B.Binary c, B.Binary tv, B.Binary r) => B.Binary (RType c tv r)
instance (NFData c, NFData tv, NFData r)       => NFData (RType c tv r)

ignoreOblig :: RType t t1 t2 -> RType t t1 t2
ignoreOblig :: forall c tv r. RType c tv r -> RType c tv r
ignoreOblig (RRTy [(Symbol, RType t t1 t2)]
_ t2
_ Oblig
_ RType t t1 t2
t) = RType t t1 t2
t
ignoreOblig RType t t1 t2
t              = RType t t1 t2
t

makeRTVar :: tv -> RTVar tv s
makeRTVar :: forall tv s. tv -> RTVar tv s
makeRTVar tv
a = tv -> RTVInfo s -> RTVar tv s
forall tv s. tv -> RTVInfo s -> RTVar tv s
RTVar tv
a (Bool -> RTVInfo s
forall s. Bool -> RTVInfo s
RTVNoInfo Bool
True)

instance (Eq tv) => Eq (RTVar tv s) where
  RTVar tv s
t1 == :: RTVar tv s -> RTVar tv s -> Bool
== RTVar tv s
t2 = RTVar tv s -> tv
forall tv s. RTVar tv s -> tv
ty_var_value RTVar tv s
t1 tv -> tv -> Bool
forall a. Eq a => a -> a -> Bool
== RTVar tv s -> tv
forall tv s. RTVar tv s -> tv
ty_var_value RTVar tv s
t2

data RTVar tv s = RTVar
  { forall tv s. RTVar tv s -> tv
ty_var_value :: tv
  , forall tv s. RTVar tv s -> RTVInfo s
ty_var_info  :: RTVInfo s
  } deriving ((forall x. RTVar tv s -> Rep (RTVar tv s) x)
-> (forall x. Rep (RTVar tv s) x -> RTVar tv s)
-> Generic (RTVar tv s)
forall x. Rep (RTVar tv s) x -> RTVar tv s
forall x. RTVar tv s -> Rep (RTVar tv s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall tv s x. Rep (RTVar tv s) x -> RTVar tv s
forall tv s x. RTVar tv s -> Rep (RTVar tv s) x
$cfrom :: forall tv s x. RTVar tv s -> Rep (RTVar tv s) x
from :: forall x. RTVar tv s -> Rep (RTVar tv s) x
$cto :: forall tv s x. Rep (RTVar tv s) x -> RTVar tv s
to :: forall x. Rep (RTVar tv s) x -> RTVar tv s
Generic, Typeable (RTVar tv s)
Typeable (RTVar tv s) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RTVar tv s))
-> (RTVar tv s -> Constr)
-> (RTVar tv s -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RTVar tv s)))
-> ((forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTVar tv s -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s))
-> Data (RTVar tv s)
RTVar tv s -> Constr
RTVar tv s -> DataType
(forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
forall u. (forall d. Data d => d -> u) -> RTVar tv s -> [u]
forall tv s. (Data s, Data tv) => Typeable (RTVar tv s)
forall tv s. (Data s, Data tv) => RTVar tv s -> Constr
forall tv s. (Data s, Data tv) => RTVar tv s -> DataType
forall tv s.
(Data s, Data tv) =>
(forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s
forall tv s u.
(Data s, Data tv) =>
Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
forall tv s u.
(Data s, Data tv) =>
(forall d. Data d => d -> u) -> RTVar tv s -> [u]
forall tv s r r'.
(Data s, Data tv) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall tv s r r'.
(Data s, Data tv) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall tv s (m :: * -> *).
(Data s, Data tv, Monad m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall tv s (m :: * -> *).
(Data s, Data tv, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall tv s (c :: * -> *).
(Data s, Data tv) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
forall tv s (c :: * -> *).
(Data s, Data tv) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s)
forall tv s (t :: * -> *) (c :: * -> *).
(Data s, Data tv, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
forall tv s (t :: * -> * -> *) (c :: * -> *).
(Data s, Data tv, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
$cgfoldl :: forall tv s (c :: * -> *).
(Data s, Data tv) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s)
$cgunfold :: forall tv s (c :: * -> *).
(Data s, Data tv) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
$ctoConstr :: forall tv s. (Data s, Data tv) => RTVar tv s -> Constr
toConstr :: RTVar tv s -> Constr
$cdataTypeOf :: forall tv s. (Data s, Data tv) => RTVar tv s -> DataType
dataTypeOf :: RTVar tv s -> DataType
$cdataCast1 :: forall tv s (t :: * -> *) (c :: * -> *).
(Data s, Data tv, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
$cdataCast2 :: forall tv s (t :: * -> * -> *) (c :: * -> *).
(Data s, Data tv, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
$cgmapT :: forall tv s.
(Data s, Data tv) =>
(forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s
gmapT :: (forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s
$cgmapQl :: forall tv s r r'.
(Data s, Data tv) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
$cgmapQr :: forall tv s r r'.
(Data s, Data tv) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
$cgmapQ :: forall tv s u.
(Data s, Data tv) =>
(forall d. Data d => d -> u) -> RTVar tv s -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTVar tv s -> [u]
$cgmapQi :: forall tv s u.
(Data s, Data tv) =>
Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
$cgmapM :: forall tv s (m :: * -> *).
(Data s, Data tv, Monad m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
$cgmapMp :: forall tv s (m :: * -> *).
(Data s, Data tv, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
$cgmapMo :: forall tv s (m :: * -> *).
(Data s, Data tv, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
Data, Typeable)
    deriving Eq (RTVar tv s)
Eq (RTVar tv s) =>
(Int -> RTVar tv s -> Int)
-> (RTVar tv s -> Int) -> Hashable (RTVar tv s)
Int -> RTVar tv s -> Int
RTVar tv s -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall tv s. (Hashable tv, Hashable s) => Eq (RTVar tv s)
forall tv s. (Hashable tv, Hashable s) => Int -> RTVar tv s -> Int
forall tv s. (Hashable tv, Hashable s) => RTVar tv s -> Int
$chashWithSalt :: forall tv s. (Hashable tv, Hashable s) => Int -> RTVar tv s -> Int
hashWithSalt :: Int -> RTVar tv s -> Int
$chash :: forall tv s. (Hashable tv, Hashable s) => RTVar tv s -> Int
hash :: RTVar tv s -> Int
Hashable via Generically (RTVar tv s)

mapTyVarValue :: (tv1 -> tv2) -> RTVar tv1 s -> RTVar tv2 s
mapTyVarValue :: forall tv1 tv2 s. (tv1 -> tv2) -> RTVar tv1 s -> RTVar tv2 s
mapTyVarValue tv1 -> tv2
f RTVar tv1 s
v = RTVar tv1 s
v {ty_var_value = f $ ty_var_value v}

dropTyVarInfo :: RTVar tv s1 -> RTVar tv s2
dropTyVarInfo :: forall tv s1 s2. RTVar tv s1 -> RTVar tv s2
dropTyVarInfo RTVar tv s1
v = RTVar tv s1
v{ty_var_info = RTVNoInfo True }

data RTVInfo s
  = RTVNoInfo { forall s. RTVInfo s -> Bool
rtv_is_pol :: Bool }
  | RTVInfo { forall s. RTVInfo s -> Symbol
rtv_name   :: Symbol
            , forall s. RTVInfo s -> s
rtv_kind   :: s
            , forall s. RTVInfo s -> Bool
rtv_is_val :: Bool
            , rtv_is_pol :: Bool -- true iff the type variable gets instantiated with
                                 -- any refinement (ie is polymorphic on refinements),
                                 -- false iff instantiation is with true refinement
            } deriving ((forall x. RTVInfo s -> Rep (RTVInfo s) x)
-> (forall x. Rep (RTVInfo s) x -> RTVInfo s)
-> Generic (RTVInfo s)
forall x. Rep (RTVInfo s) x -> RTVInfo s
forall x. RTVInfo s -> Rep (RTVInfo s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall s x. Rep (RTVInfo s) x -> RTVInfo s
forall s x. RTVInfo s -> Rep (RTVInfo s) x
$cfrom :: forall s x. RTVInfo s -> Rep (RTVInfo s) x
from :: forall x. RTVInfo s -> Rep (RTVInfo s) x
$cto :: forall s x. Rep (RTVInfo s) x -> RTVInfo s
to :: forall x. Rep (RTVInfo s) x -> RTVInfo s
Generic, Typeable (RTVInfo s)
Typeable (RTVInfo s) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RTVInfo s))
-> (RTVInfo s -> Constr)
-> (RTVInfo s -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RTVInfo s)))
-> ((forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTVInfo s -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s))
-> Data (RTVInfo s)
RTVInfo s -> Constr
RTVInfo s -> DataType
(forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
forall s. Data s => Typeable (RTVInfo s)
forall s. Data s => RTVInfo s -> Constr
forall s. Data s => RTVInfo s -> DataType
forall s.
Data s =>
(forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
forall s u.
Data s =>
Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u
forall s u.
Data s =>
(forall d. Data d => d -> u) -> RTVInfo s -> [u]
forall s r r'.
Data s =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
forall s r r'.
Data s =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
forall s (m :: * -> *).
(Data s, Monad m) =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
forall s (m :: * -> *).
(Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
forall s (c :: * -> *).
Data s =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVInfo s)
forall s (c :: * -> *).
Data s =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s)
forall s (t :: * -> *) (c :: * -> *).
(Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
forall s (t :: * -> * -> *) (c :: * -> *).
(Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVInfo s))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u
forall u. (forall d. Data d => d -> u) -> RTVInfo s -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVInfo s)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVInfo s))
$cgfoldl :: forall s (c :: * -> *).
Data s =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s)
$cgunfold :: forall s (c :: * -> *).
Data s =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVInfo s)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVInfo s)
$ctoConstr :: forall s. Data s => RTVInfo s -> Constr
toConstr :: RTVInfo s -> Constr
$cdataTypeOf :: forall s. Data s => RTVInfo s -> DataType
dataTypeOf :: RTVInfo s -> DataType
$cdataCast1 :: forall s (t :: * -> *) (c :: * -> *).
(Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
$cdataCast2 :: forall s (t :: * -> * -> *) (c :: * -> *).
(Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVInfo s))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVInfo s))
$cgmapT :: forall s.
Data s =>
(forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
gmapT :: (forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
$cgmapQl :: forall s r r'.
Data s =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
$cgmapQr :: forall s r r'.
Data s =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
$cgmapQ :: forall s u.
Data s =>
(forall d. Data d => d -> u) -> RTVInfo s -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTVInfo s -> [u]
$cgmapQi :: forall s u.
Data s =>
Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u
$cgmapM :: forall s (m :: * -> *).
(Data s, Monad m) =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
$cgmapMp :: forall s (m :: * -> *).
(Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
$cgmapMo :: forall s (m :: * -> *).
(Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
Data, Typeable, (forall a b. (a -> b) -> RTVInfo a -> RTVInfo b)
-> (forall a b. a -> RTVInfo b -> RTVInfo a) -> Functor RTVInfo
forall a b. a -> RTVInfo b -> RTVInfo a
forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
fmap :: forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
$c<$ :: forall a b. a -> RTVInfo b -> RTVInfo a
<$ :: forall a b. a -> RTVInfo b -> RTVInfo a
Functor, RTVInfo s -> RTVInfo s -> Bool
(RTVInfo s -> RTVInfo s -> Bool)
-> (RTVInfo s -> RTVInfo s -> Bool) -> Eq (RTVInfo s)
forall s. Eq s => RTVInfo s -> RTVInfo s -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall s. Eq s => RTVInfo s -> RTVInfo s -> Bool
== :: RTVInfo s -> RTVInfo s -> Bool
$c/= :: forall s. Eq s => RTVInfo s -> RTVInfo s -> Bool
/= :: RTVInfo s -> RTVInfo s -> Bool
Eq)
              deriving Eq (RTVInfo s)
Eq (RTVInfo s) =>
(Int -> RTVInfo s -> Int)
-> (RTVInfo s -> Int) -> Hashable (RTVInfo s)
Int -> RTVInfo s -> Int
RTVInfo s -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall s. Hashable s => Eq (RTVInfo s)
forall s. Hashable s => Int -> RTVInfo s -> Int
forall s. Hashable s => RTVInfo s -> Int
$chashWithSalt :: forall s. Hashable s => Int -> RTVInfo s -> Int
hashWithSalt :: Int -> RTVInfo s -> Int
$chash :: forall s. Hashable s => RTVInfo s -> Int
hash :: RTVInfo s -> Int
Hashable via Generically (RTVInfo s)


setRtvPol :: RTVar tv a -> Bool -> RTVar tv a
setRtvPol :: forall tv a. RTVar tv a -> Bool -> RTVar tv a
setRtvPol (RTVar tv
a RTVInfo a
i) Bool
b = tv -> RTVInfo a -> RTVar tv a
forall tv s. tv -> RTVInfo s -> RTVar tv s
RTVar tv
a (RTVInfo a
i{rtv_is_pol = b})

rTVarToBind :: RTVar RTyVar s  -> Maybe (Symbol, s)
rTVarToBind :: forall s. RTVar RTyVar s -> Maybe (Symbol, s)
rTVarToBind = RTVInfo s -> Maybe (Symbol, s)
forall {b}. RTVInfo b -> Maybe (Symbol, b)
go (RTVInfo s -> Maybe (Symbol, s))
-> (RTVar RTyVar s -> RTVInfo s)
-> RTVar RTyVar s
-> Maybe (Symbol, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTVar RTyVar s -> RTVInfo s
forall tv s. RTVar tv s -> RTVInfo s
ty_var_info
  where
    go :: RTVInfo b -> Maybe (Symbol, b)
go RTVInfo{b
Bool
Symbol
rtv_is_pol :: forall s. RTVInfo s -> Bool
rtv_name :: forall s. RTVInfo s -> Symbol
rtv_kind :: forall s. RTVInfo s -> s
rtv_is_val :: forall s. RTVInfo s -> Bool
rtv_name :: Symbol
rtv_kind :: b
rtv_is_val :: Bool
rtv_is_pol :: Bool
..} | Bool
rtv_is_val = (Symbol, b) -> Maybe (Symbol, b)
forall a. a -> Maybe a
Just (Symbol
rtv_name, b
rtv_kind)
    go RTVInfo b
_                        = Maybe (Symbol, b)
forall a. Maybe a
Nothing

tyVarIsVal :: RTVar tv s -> Bool
tyVarIsVal :: forall tv s. RTVar tv s -> Bool
tyVarIsVal = RTVInfo s -> Bool
forall s. RTVInfo s -> Bool
rtvinfoIsVal (RTVInfo s -> Bool)
-> (RTVar tv s -> RTVInfo s) -> RTVar tv s -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTVar tv s -> RTVInfo s
forall tv s. RTVar tv s -> RTVInfo s
ty_var_info

rtvinfoIsVal :: RTVInfo s -> Bool
rtvinfoIsVal :: forall s. RTVInfo s -> Bool
rtvinfoIsVal RTVNoInfo{} = Bool
False
rtvinfoIsVal RTVInfo{s
Bool
Symbol
rtv_is_pol :: forall s. RTVInfo s -> Bool
rtv_name :: forall s. RTVInfo s -> Symbol
rtv_kind :: forall s. RTVInfo s -> s
rtv_is_val :: forall s. RTVInfo s -> Bool
rtv_name :: Symbol
rtv_kind :: s
rtv_is_val :: Bool
rtv_is_pol :: Bool
..} = Bool
rtv_is_val

instance (B.Binary tv, B.Binary s) => B.Binary (RTVar tv s)
instance (NFData tv, NFData s)     => NFData   (RTVar tv s)
instance (NFData s)                => NFData   (RTVInfo s)
instance (B.Binary s)              => B.Binary (RTVInfo s)

-- | @Ref@ describes `Prop τ` and `HProp` arguments applied to type constructors.
--   For example, in [a]<{\h -> v > h}>, we apply (via `RApp`)
--   * the `RProp`  denoted by `{\h -> v > h}` to
--   * the `RTyCon` denoted by `[]`.
--   Thus, @Ref@ is used for abstract-predicate (arguments) that are associated
--   with _type constructors_ i.e. whose semantics are _dependent upon_ the data-type.
--   In contrast, the `Predicate` argument in `ur_pred` in the @UReft@ applies
--   directly to any type and has semantics _independent of_ the data-type.

data Ref τ t = RProp
  { forall τ t. Ref τ t -> [(Symbol, τ)]
rf_args :: [(Symbol, τ)] -- ^ arguments. e.g. @h@ in the above example
  , forall τ t. Ref τ t -> t
rf_body :: t -- ^ Abstract refinement associated with `RTyCon`. e.g. @v > h@ in the above example
  } deriving (Ref τ t -> Ref τ t -> Bool
(Ref τ t -> Ref τ t -> Bool)
-> (Ref τ t -> Ref τ t -> Bool) -> Eq (Ref τ t)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall τ t. (Eq τ, Eq t) => Ref τ t -> Ref τ t -> Bool
$c== :: forall τ t. (Eq τ, Eq t) => Ref τ t -> Ref τ t -> Bool
== :: Ref τ t -> Ref τ t -> Bool
$c/= :: forall τ t. (Eq τ, Eq t) => Ref τ t -> Ref τ t -> Bool
/= :: Ref τ t -> Ref τ t -> Bool
Eq, (forall x. Ref τ t -> Rep (Ref τ t) x)
-> (forall x. Rep (Ref τ t) x -> Ref τ t) -> Generic (Ref τ t)
forall x. Rep (Ref τ t) x -> Ref τ t
forall x. Ref τ t -> Rep (Ref τ t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall τ t x. Rep (Ref τ t) x -> Ref τ t
forall τ t x. Ref τ t -> Rep (Ref τ t) x
$cfrom :: forall τ t x. Ref τ t -> Rep (Ref τ t) x
from :: forall x. Ref τ t -> Rep (Ref τ t) x
$cto :: forall τ t x. Rep (Ref τ t) x -> Ref τ t
to :: forall x. Rep (Ref τ t) x -> Ref τ t
Generic, Typeable (Ref τ t)
Typeable (Ref τ t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Ref τ t))
-> (Ref τ t -> Constr)
-> (Ref τ t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Ref τ t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t)))
-> ((forall b. Data b => b -> b) -> Ref τ t -> Ref τ t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Ref τ t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Ref τ t -> r)
-> (forall u. (forall d. Data d => d -> u) -> Ref τ t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Ref τ t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t))
-> Data (Ref τ t)
Ref τ t -> Constr
Ref τ t -> DataType
(forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Ref τ t -> u
forall u. (forall d. Data d => d -> u) -> Ref τ t -> [u]
forall τ t. (Data τ, Data t) => Typeable (Ref τ t)
forall τ t. (Data τ, Data t) => Ref τ t -> Constr
forall τ t. (Data τ, Data t) => Ref τ t -> DataType
forall τ t.
(Data τ, Data t) =>
(forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
forall τ t u.
(Data τ, Data t) =>
Int -> (forall d. Data d => d -> u) -> Ref τ t -> u
forall τ t u.
(Data τ, Data t) =>
(forall d. Data d => d -> u) -> Ref τ t -> [u]
forall τ t r r'.
(Data τ, Data t) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
forall τ t r r'.
(Data τ, Data t) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
forall τ t (m :: * -> *).
(Data τ, Data t, Monad m) =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
forall τ t (m :: * -> *).
(Data τ, Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
forall τ t (c :: * -> *).
(Data τ, Data t) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Ref τ t)
forall τ t (c :: * -> *).
(Data τ, Data t) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t)
forall τ t (t :: * -> *) (c :: * -> *).
(Data τ, Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
forall τ t (t :: * -> * -> *) (c :: * -> *).
(Data τ, Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Ref τ t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
$cgfoldl :: forall τ t (c :: * -> *).
(Data τ, Data t) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t)
$cgunfold :: forall τ t (c :: * -> *).
(Data τ, Data t) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Ref τ t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Ref τ t)
$ctoConstr :: forall τ t. (Data τ, Data t) => Ref τ t -> Constr
toConstr :: Ref τ t -> Constr
$cdataTypeOf :: forall τ t. (Data τ, Data t) => Ref τ t -> DataType
dataTypeOf :: Ref τ t -> DataType
$cdataCast1 :: forall τ t (t :: * -> *) (c :: * -> *).
(Data τ, Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
$cdataCast2 :: forall τ t (t :: * -> * -> *) (c :: * -> *).
(Data τ, Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
$cgmapT :: forall τ t.
(Data τ, Data t) =>
(forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
gmapT :: (forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
$cgmapQl :: forall τ t r r'.
(Data τ, Data t) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
$cgmapQr :: forall τ t r r'.
(Data τ, Data t) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
$cgmapQ :: forall τ t u.
(Data τ, Data t) =>
(forall d. Data d => d -> u) -> Ref τ t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Ref τ t -> [u]
$cgmapQi :: forall τ t u.
(Data τ, Data t) =>
Int -> (forall d. Data d => d -> u) -> Ref τ t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Ref τ t -> u
$cgmapM :: forall τ t (m :: * -> *).
(Data τ, Data t, Monad m) =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
$cgmapMp :: forall τ t (m :: * -> *).
(Data τ, Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
$cgmapMo :: forall τ t (m :: * -> *).
(Data τ, Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
Data, Typeable, (forall a b. (a -> b) -> Ref τ a -> Ref τ b)
-> (forall a b. a -> Ref τ b -> Ref τ a) -> Functor (Ref τ)
forall a b. a -> Ref τ b -> Ref τ a
forall a b. (a -> b) -> Ref τ a -> Ref τ b
forall τ a b. a -> Ref τ b -> Ref τ a
forall τ a b. (a -> b) -> Ref τ a -> Ref τ b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall τ a b. (a -> b) -> Ref τ a -> Ref τ b
fmap :: forall a b. (a -> b) -> Ref τ a -> Ref τ b
$c<$ :: forall τ a b. a -> Ref τ b -> Ref τ a
<$ :: forall a b. a -> Ref τ b -> Ref τ a
Functor)
    deriving Eq (Ref τ t)
Eq (Ref τ t) =>
(Int -> Ref τ t -> Int) -> (Ref τ t -> Int) -> Hashable (Ref τ t)
Int -> Ref τ t -> Int
Ref τ t -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall τ t. (Hashable τ, Hashable t) => Eq (Ref τ t)
forall τ t. (Hashable τ, Hashable t) => Int -> Ref τ t -> Int
forall τ t. (Hashable τ, Hashable t) => Ref τ t -> Int
$chashWithSalt :: forall τ t. (Hashable τ, Hashable t) => Int -> Ref τ t -> Int
hashWithSalt :: Int -> Ref τ t -> Int
$chash :: forall τ t. (Hashable τ, Hashable t) => Ref τ t -> Int
hash :: Ref τ t -> Int
Hashable via Generically (Ref τ t)

instance (B.Binary τ, B.Binary t) => B.Binary (Ref τ t)
instance (NFData τ,   NFData t)   => NFData   (Ref τ t)

rPropP :: [(Symbol, τ)] -> r -> Ref τ (RType c tv r)
rPropP :: forall τ r c tv. [(Symbol, τ)] -> r -> Ref τ (RType c tv r)
rPropP [(Symbol, τ)]
τ r
r = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
τ (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r)

-- | @RTProp@ is a convenient alias for @Ref@ that will save a bunch of typing.
--   In general, perhaps we need not expose @Ref@ directly at all.
type RTProp c tv r = Ref (RType c tv ()) (RType c tv r)


-- | A @World@ is a Separation Logic predicate that is essentially a sequence of binders
--   that satisfies two invariants (TODO:LIQUID):
--   1. Each `hs_addr :: Symbol` appears at most once,
--   2. There is at most one `HVar` in a list.

newtype World t = World [HSeg t]
                deriving ((forall x. World t -> Rep (World t) x)
-> (forall x. Rep (World t) x -> World t) -> Generic (World t)
forall x. Rep (World t) x -> World t
forall x. World t -> Rep (World t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (World t) x -> World t
forall t x. World t -> Rep (World t) x
$cfrom :: forall t x. World t -> Rep (World t) x
from :: forall x. World t -> Rep (World t) x
$cto :: forall t x. Rep (World t) x -> World t
to :: forall x. Rep (World t) x -> World t
Generic, Typeable (World t)
Typeable (World t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> World t -> c (World t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (World t))
-> (World t -> Constr)
-> (World t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (World t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t)))
-> ((forall b. Data b => b -> b) -> World t -> World t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> World t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> World t -> r)
-> (forall u. (forall d. Data d => d -> u) -> World t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> World t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> World t -> m (World t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> World t -> m (World t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> World t -> m (World t))
-> Data (World t)
World t -> Constr
World t -> DataType
(forall b. Data b => b -> b) -> World t -> World t
forall t. Data t => Typeable (World t)
forall t. Data t => World t -> Constr
forall t. Data t => World t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> World t -> World t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> World t -> u
forall t u.
Data t =>
(forall d. Data d => d -> u) -> World t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (World t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> c (World t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> World t -> u
forall u. (forall d. Data d => d -> u) -> World t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (World t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> c (World t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> c (World t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> c (World t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (World t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (World t)
$ctoConstr :: forall t. Data t => World t -> Constr
toConstr :: World t -> Constr
$cdataTypeOf :: forall t. Data t => World t -> DataType
dataTypeOf :: World t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> World t -> World t
gmapT :: (forall b. Data b => b -> b) -> World t -> World t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> World t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> World t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> World t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> World t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
Data, Typeable)

data    HSeg  t = HBind {forall t. HSeg t -> Symbol
hs_addr :: !Symbol, forall t. HSeg t -> t
hs_val :: t}
                | HVar UsedPVar
                deriving ((forall x. HSeg t -> Rep (HSeg t) x)
-> (forall x. Rep (HSeg t) x -> HSeg t) -> Generic (HSeg t)
forall x. Rep (HSeg t) x -> HSeg t
forall x. HSeg t -> Rep (HSeg t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (HSeg t) x -> HSeg t
forall t x. HSeg t -> Rep (HSeg t) x
$cfrom :: forall t x. HSeg t -> Rep (HSeg t) x
from :: forall x. HSeg t -> Rep (HSeg t) x
$cto :: forall t x. Rep (HSeg t) x -> HSeg t
to :: forall x. Rep (HSeg t) x -> HSeg t
Generic, Typeable (HSeg t)
Typeable (HSeg t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> HSeg t -> c (HSeg t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (HSeg t))
-> (HSeg t -> Constr)
-> (HSeg t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (HSeg t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t)))
-> ((forall b. Data b => b -> b) -> HSeg t -> HSeg t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HSeg t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HSeg t -> r)
-> (forall u. (forall d. Data d => d -> u) -> HSeg t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> HSeg t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t))
-> Data (HSeg t)
HSeg t -> Constr
HSeg t -> DataType
(forall b. Data b => b -> b) -> HSeg t -> HSeg t
forall t. Data t => Typeable (HSeg t)
forall t. Data t => HSeg t -> Constr
forall t. Data t => HSeg t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> HSeg t -> HSeg t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> HSeg t -> u
forall t u. Data t => (forall d. Data d => d -> u) -> HSeg t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
forall t r r'.
Data t =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HSeg t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> c (HSeg t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> HSeg t -> u
forall u. (forall d. Data d => d -> u) -> HSeg t -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HSeg t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> c (HSeg t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> c (HSeg t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> c (HSeg t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HSeg t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HSeg t)
$ctoConstr :: forall t. Data t => HSeg t -> Constr
toConstr :: HSeg t -> Constr
$cdataTypeOf :: forall t. Data t => HSeg t -> DataType
dataTypeOf :: HSeg t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> HSeg t -> HSeg t
gmapT :: (forall b. Data b => b -> b) -> HSeg t -> HSeg t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
$cgmapQ :: forall t u. Data t => (forall d. Data d => d -> u) -> HSeg t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> HSeg t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> HSeg t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HSeg t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
Data, Typeable)

data UReft r = MkUReft
  { forall r. UReft r -> r
ur_reft   :: !r
  , forall r. UReft r -> Predicate
ur_pred   :: !Predicate
  }
  deriving (UReft r -> UReft r -> Bool
(UReft r -> UReft r -> Bool)
-> (UReft r -> UReft r -> Bool) -> Eq (UReft r)
forall r. Eq r => UReft r -> UReft r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => UReft r -> UReft r -> Bool
== :: UReft r -> UReft r -> Bool
$c/= :: forall r. Eq r => UReft r -> UReft r -> Bool
/= :: UReft r -> UReft r -> Bool
Eq, (forall x. UReft r -> Rep (UReft r) x)
-> (forall x. Rep (UReft r) x -> UReft r) -> Generic (UReft r)
forall x. Rep (UReft r) x -> UReft r
forall x. UReft r -> Rep (UReft r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (UReft r) x -> UReft r
forall r x. UReft r -> Rep (UReft r) x
$cfrom :: forall r x. UReft r -> Rep (UReft r) x
from :: forall x. UReft r -> Rep (UReft r) x
$cto :: forall r x. Rep (UReft r) x -> UReft r
to :: forall x. Rep (UReft r) x -> UReft r
Generic, Typeable (UReft r)
Typeable (UReft r) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> UReft r -> c (UReft r))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (UReft r))
-> (UReft r -> Constr)
-> (UReft r -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (UReft r)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r)))
-> ((forall b. Data b => b -> b) -> UReft r -> UReft r)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UReft r -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UReft r -> r)
-> (forall u. (forall d. Data d => d -> u) -> UReft r -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> UReft r -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> UReft r -> m (UReft r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UReft r -> m (UReft r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UReft r -> m (UReft r))
-> Data (UReft r)
UReft r -> Constr
UReft r -> DataType
(forall b. Data b => b -> b) -> UReft r -> UReft r
forall r. Data r => Typeable (UReft r)
forall r. Data r => UReft r -> Constr
forall r. Data r => UReft r -> DataType
forall r.
Data r =>
(forall b. Data b => b -> b) -> UReft r -> UReft r
forall r u.
Data r =>
Int -> (forall d. Data d => d -> u) -> UReft r -> u
forall r u.
Data r =>
(forall d. Data d => d -> u) -> UReft r -> [u]
forall r r r'.
Data r =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
forall r r r'.
Data r =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
forall r (m :: * -> *).
(Data r, Monad m) =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
forall r (m :: * -> *).
(Data r, MonadPlus m) =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
forall r (c :: * -> *).
Data r =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UReft r)
forall r (c :: * -> *).
Data r =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> c (UReft r)
forall r (t :: * -> *) (c :: * -> *).
(Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
forall r (t :: * -> * -> *) (c :: * -> *).
(Data r, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> UReft r -> u
forall u. (forall d. Data d => d -> u) -> UReft r -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UReft r)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> c (UReft r)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r))
$cgfoldl :: forall r (c :: * -> *).
Data r =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> c (UReft r)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> c (UReft r)
$cgunfold :: forall r (c :: * -> *).
Data r =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UReft r)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UReft r)
$ctoConstr :: forall r. Data r => UReft r -> Constr
toConstr :: UReft r -> Constr
$cdataTypeOf :: forall r. Data r => UReft r -> DataType
dataTypeOf :: UReft r -> DataType
$cdataCast1 :: forall r (t :: * -> *) (c :: * -> *).
(Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
$cdataCast2 :: forall r (t :: * -> * -> *) (c :: * -> *).
(Data r, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r))
$cgmapT :: forall r.
Data r =>
(forall b. Data b => b -> b) -> UReft r -> UReft r
gmapT :: (forall b. Data b => b -> b) -> UReft r -> UReft r
$cgmapQl :: forall r r r'.
Data r =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
$cgmapQr :: forall r r r'.
Data r =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
$cgmapQ :: forall r u.
Data r =>
(forall d. Data d => d -> u) -> UReft r -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> UReft r -> [u]
$cgmapQi :: forall r u.
Data r =>
Int -> (forall d. Data d => d -> u) -> UReft r -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UReft r -> u
$cgmapM :: forall r (m :: * -> *).
(Data r, Monad m) =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
$cgmapMp :: forall r (m :: * -> *).
(Data r, MonadPlus m) =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
$cgmapMo :: forall r (m :: * -> *).
(Data r, MonadPlus m) =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
Data, Typeable, (forall a b. (a -> b) -> UReft a -> UReft b)
-> (forall a b. a -> UReft b -> UReft a) -> Functor UReft
forall a b. a -> UReft b -> UReft a
forall a b. (a -> b) -> UReft a -> UReft b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> UReft a -> UReft b
fmap :: forall a b. (a -> b) -> UReft a -> UReft b
$c<$ :: forall a b. a -> UReft b -> UReft a
<$ :: forall a b. a -> UReft b -> UReft a
Functor, (forall m. Monoid m => UReft m -> m)
-> (forall m a. Monoid m => (a -> m) -> UReft a -> m)
-> (forall m a. Monoid m => (a -> m) -> UReft a -> m)
-> (forall a b. (a -> b -> b) -> b -> UReft a -> b)
-> (forall a b. (a -> b -> b) -> b -> UReft a -> b)
-> (forall b a. (b -> a -> b) -> b -> UReft a -> b)
-> (forall b a. (b -> a -> b) -> b -> UReft a -> b)
-> (forall a. (a -> a -> a) -> UReft a -> a)
-> (forall a. (a -> a -> a) -> UReft a -> a)
-> (forall a. UReft a -> [a])
-> (forall a. UReft a -> Bool)
-> (forall a. UReft a -> Int)
-> (forall a. Eq a => a -> UReft a -> Bool)
-> (forall a. Ord a => UReft a -> a)
-> (forall a. Ord a => UReft a -> a)
-> (forall a. Num a => UReft a -> a)
-> (forall a. Num a => UReft a -> a)
-> Foldable UReft
forall a. Eq a => a -> UReft a -> Bool
forall a. Num a => UReft a -> a
forall a. Ord a => UReft a -> a
forall m. Monoid m => UReft m -> m
forall a. UReft a -> Bool
forall a. UReft a -> Int
forall a. UReft a -> [a]
forall a. (a -> a -> a) -> UReft a -> a
forall m a. Monoid m => (a -> m) -> UReft a -> m
forall b a. (b -> a -> b) -> b -> UReft a -> b
forall a b. (a -> b -> b) -> b -> UReft a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => UReft m -> m
fold :: forall m. Monoid m => UReft m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> UReft a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> UReft a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> UReft a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> UReft a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> UReft a -> b
foldr :: forall a b. (a -> b -> b) -> b -> UReft a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> UReft a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> UReft a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> UReft a -> b
foldl :: forall b a. (b -> a -> b) -> b -> UReft a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> UReft a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> UReft a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> UReft a -> a
foldr1 :: forall a. (a -> a -> a) -> UReft a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> UReft a -> a
foldl1 :: forall a. (a -> a -> a) -> UReft a -> a
$ctoList :: forall a. UReft a -> [a]
toList :: forall a. UReft a -> [a]
$cnull :: forall a. UReft a -> Bool
null :: forall a. UReft a -> Bool
$clength :: forall a. UReft a -> Int
length :: forall a. UReft a -> Int
$celem :: forall a. Eq a => a -> UReft a -> Bool
elem :: forall a. Eq a => a -> UReft a -> Bool
$cmaximum :: forall a. Ord a => UReft a -> a
maximum :: forall a. Ord a => UReft a -> a
$cminimum :: forall a. Ord a => UReft a -> a
minimum :: forall a. Ord a => UReft a -> a
$csum :: forall a. Num a => UReft a -> a
sum :: forall a. Num a => UReft a -> a
$cproduct :: forall a. Num a => UReft a -> a
product :: forall a. Num a => UReft a -> a
Foldable, Functor UReft
Foldable UReft
(Functor UReft, Foldable UReft) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> UReft a -> f (UReft b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    UReft (f a) -> f (UReft a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> UReft a -> m (UReft b))
-> (forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a))
-> Traversable UReft
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a)
forall (f :: * -> *) a. Applicative f => UReft (f a) -> f (UReft a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UReft a -> m (UReft b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UReft a -> f (UReft b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UReft a -> f (UReft b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UReft a -> f (UReft b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => UReft (f a) -> f (UReft a)
sequenceA :: forall (f :: * -> *) a. Applicative f => UReft (f a) -> f (UReft a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UReft a -> m (UReft b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UReft a -> m (UReft b)
$csequence :: forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a)
sequence :: forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a)
Traversable)
  deriving Eq (UReft r)
Eq (UReft r) =>
(Int -> UReft r -> Int) -> (UReft r -> Int) -> Hashable (UReft r)
Int -> UReft r -> Int
UReft r -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall r. Hashable r => Eq (UReft r)
forall r. Hashable r => Int -> UReft r -> Int
forall r. Hashable r => UReft r -> Int
$chashWithSalt :: forall r. Hashable r => Int -> UReft r -> Int
hashWithSalt :: Int -> UReft r -> Int
$chash :: forall r. Hashable r => UReft r -> Int
hash :: UReft r -> Int
Hashable via Generically (UReft r)

instance B.Binary r => B.Binary (UReft r)

type BRType      = RType BTyCon BTyVar       -- ^ "Bare" parsed version
type RRType      = RType RTyCon RTyVar       -- ^ "Resolved" version
type RRep        = RTypeRep RTyCon RTyVar
type BSort       = BRType    ()
type RSort       = RRType    ()
type BPVar       = PVar      BSort
type RPVar       = PVar      RSort
type RReft       = UReft     F.Reft
type PrType      = RRType    Predicate
type BareType    = BRType    RReft
type SpecType    = RRType    RReft
type SpecRep     = RRep      RReft
type SpecProp    = RRProp    RReft
type RRProp r    = Ref       RSort (RRType r)
type BRProp r    = Ref       BSort (BRType r)
type SpecRTVar   = RTVar     RTyVar RSort



type LocBareType = F.Located BareType
type LocSpecType = F.Located SpecType

type SpecRTEnv   = RTEnv RTyVar SpecType
type BareRTEnv   = RTEnv Symbol BareType
type BareRTAlias = RTAlias Symbol BareType
type SpecRTAlias = RTAlias RTyVar SpecType


class SubsTy tv ty a where
  subt :: (tv, ty) -> a -> a

class (Eq c) => TyConable c where
  isFun    :: c -> Bool
  isList   :: c -> Bool
  isTuple  :: c -> Bool
  ppTycon  :: c -> Doc
  isClass  :: c -> Bool
  isEmbeddedDict :: c -> Bool
  isEqual  :: c -> Bool
  isOrdCls  :: c -> Bool
  isEqCls   :: c -> Bool

  isNumCls  :: c -> Bool
  isFracCls :: c -> Bool

  isClass   = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isEmbeddedDict c
c = c -> Bool
forall c. TyConable c => c -> Bool
isNumCls c
c Bool -> Bool -> Bool
|| c -> Bool
forall c. TyConable c => c -> Bool
isEqual c
c Bool -> Bool -> Bool
|| c -> Bool
forall c. TyConable c => c -> Bool
isOrdCls c
c Bool -> Bool -> Bool
|| c -> Bool
forall c. TyConable c => c -> Bool
isEqCls c
c
  isOrdCls  = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isEqCls   = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isEqual   = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isNumCls  = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isFracCls = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False


-- Should just make this a @Pretty@ instance but its too damn tedious
-- to figure out all the constraints.

type OkRT c tv r = ( TyConable c
                   , F.PPrint tv, F.PPrint c, F.PPrint r
                   , F.Reftable r, F.Reftable (RTProp c tv ()), F.Reftable (RTProp c tv r)
                   , Eq c, Eq tv
                   , Hashable tv
                   )

-------------------------------------------------------------------------------
-- | TyConable Instances -------------------------------------------------------
-------------------------------------------------------------------------------

instance TyConable RTyCon where
  isFun :: RTyCon -> Bool
isFun      = TyCon -> Bool
isArrowTyCon (TyCon -> Bool) -> (RTyCon -> TyCon) -> RTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  isList :: RTyCon -> Bool
isList     = (TyCon
listTyCon TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
==) (TyCon -> Bool) -> (RTyCon -> TyCon) -> RTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  isTuple :: RTyCon -> Bool
isTuple    = TyCon -> Bool
Ghc.isTupleTyCon   (TyCon -> Bool) -> (RTyCon -> TyCon) -> RTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  isClass :: RTyCon -> Bool
isClass    = TyCon -> Bool
forall c. TyConable c => c -> Bool
isClass (TyCon -> Bool) -> (RTyCon -> TyCon) -> RTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc -- isClassRTyCon
  isEqual :: RTyCon -> Bool
isEqual    = TyCon -> Bool
forall c. TyConable c => c -> Bool
isEqual (TyCon -> Bool) -> (RTyCon -> TyCon) -> RTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  ppTycon :: RTyCon -> Doc
ppTycon    = RTyCon -> Doc
forall a. Fixpoint a => a -> Doc
F.toFix

  isNumCls :: RTyCon -> Bool
isNumCls RTyCon
c  = Bool -> (Class -> Bool) -> Maybe Class -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False ((Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
isNumericClass)
                (TyCon -> Maybe Class
tyConClass_maybe (TyCon -> Maybe Class) -> TyCon -> Maybe Class
forall a b. (a -> b) -> a -> b
$ RTyCon -> TyCon
rtc_tc RTyCon
c)
  isFracCls :: RTyCon -> Bool
isFracCls RTyCon
c = Bool -> (Class -> Bool) -> Maybe Class -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False ((Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
isFractionalClass)
                (TyCon -> Maybe Class
tyConClass_maybe (TyCon -> Maybe Class) -> TyCon -> Maybe Class
forall a b. (a -> b) -> a -> b
$ RTyCon -> TyCon
rtc_tc RTyCon
c)
  isOrdCls :: RTyCon -> Bool
isOrdCls  RTyCon
c = Bool -> (Class -> Bool) -> Maybe Class -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Class -> Bool
isOrdClass (TyCon -> Maybe Class
tyConClass_maybe (TyCon -> Maybe Class) -> TyCon -> Maybe Class
forall a b. (a -> b) -> a -> b
$ RTyCon -> TyCon
rtc_tc RTyCon
c)
  isEqCls :: RTyCon -> Bool
isEqCls   RTyCon
c = TyCon -> Bool
forall c. TyConable c => c -> Bool
isEqCls (RTyCon -> TyCon
rtc_tc RTyCon
c)


instance TyConable TyCon where
  isFun :: TyCon -> Bool
isFun      = TyCon -> Bool
isArrowTyCon
  isList :: TyCon -> Bool
isList     = (TyCon
listTyCon TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
==)
  isTuple :: TyCon -> Bool
isTuple    = TyCon -> Bool
Ghc.isTupleTyCon
  isClass :: TyCon -> Bool
isClass TyCon
c  = TyCon -> Bool
isClassTyCon TyCon
c   Bool -> Bool -> Bool
|| TyCon -> Bool
forall c. TyConable c => c -> Bool
isEqual TyCon
c -- c == eqPrimTyCon
  isEqual :: TyCon -> Bool
isEqual TyCon
c  = TyCon
c TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
== TyCon
eqPrimTyCon Bool -> Bool -> Bool
|| TyCon
c TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
== TyCon
eqReprPrimTyCon
  ppTycon :: TyCon -> Doc
ppTycon    = String -> Doc
text (String -> Doc) -> (TyCon -> String) -> TyCon -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyCon -> String
forall a. Outputable a => a -> String
showPpr

  isNumCls :: TyCon -> Bool
isNumCls TyCon
c  = Bool -> (Class -> Bool) -> Maybe Class -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False ((Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
isNumericClass)
                (TyCon -> Maybe Class
tyConClass_maybe TyCon
c)
  isFracCls :: TyCon -> Bool
isFracCls TyCon
c = Bool -> (Class -> Bool) -> Maybe Class -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False ((Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
isFractionalClass)
                (TyCon -> Maybe Class
tyConClass_maybe TyCon
c)
  isOrdCls :: TyCon -> Bool
isOrdCls TyCon
c  = Bool -> (Class -> Bool) -> Maybe Class -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Class -> Bool
isOrdClass
                (TyCon -> Maybe Class
tyConClass_maybe TyCon
c)
  isEqCls :: TyCon -> Bool
isEqCls  TyCon
c  = TyCon -> Bool
isPrelEqTyCon TyCon
c

isClassOrSubClass :: (Class -> Bool) -> Class -> Bool
isClassOrSubClass :: (Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
p Class
cls
  = Class -> Bool
p Class
cls Bool -> Bool -> Bool
|| ((Class, [Type]) -> Bool) -> [(Class, [Type])] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
p (Class -> Bool)
-> ((Class, [Type]) -> Class) -> (Class, [Type]) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Class, [Type]) -> Class
forall a b. (a, b) -> a
fst)
                 ((Type -> Maybe (Class, [Type])) -> [Type] -> [(Class, [Type])]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe Type -> Maybe (Class, [Type])
getClassPredTys_maybe (Class -> [Type]
classSCTheta Class
cls))

-- MOVE TO TYPES
instance TyConable Symbol where
  isFun :: Symbol -> Bool
isFun   Symbol
s = Symbol
F.funConName Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== Symbol
s
  isList :: Symbol -> Bool
isList  Symbol
s = Symbol
F.listConName Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== Symbol
s
  isTuple :: Symbol -> Bool
isTuple Symbol
s = Symbol
F.tupConName Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== Symbol
s
  ppTycon :: Symbol -> Doc
ppTycon   = String -> Doc
text (String -> Doc) -> (Symbol -> String) -> Symbol -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> String
F.symbolString

instance TyConable F.LocSymbol where
  isFun :: LocSymbol -> Bool
isFun   = Symbol -> Bool
forall c. TyConable c => c -> Bool
isFun   (Symbol -> Bool) -> (LocSymbol -> Symbol) -> LocSymbol -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocSymbol -> Symbol
forall a. Located a -> a
F.val
  isList :: LocSymbol -> Bool
isList  = Symbol -> Bool
forall c. TyConable c => c -> Bool
isList  (Symbol -> Bool) -> (LocSymbol -> Symbol) -> LocSymbol -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocSymbol -> Symbol
forall a. Located a -> a
F.val
  isTuple :: LocSymbol -> Bool
isTuple = Symbol -> Bool
forall c. TyConable c => c -> Bool
isTuple (Symbol -> Bool) -> (LocSymbol -> Symbol) -> LocSymbol -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocSymbol -> Symbol
forall a. Located a -> a
F.val
  ppTycon :: LocSymbol -> Doc
ppTycon = Symbol -> Doc
forall c. TyConable c => c -> Doc
ppTycon (Symbol -> Doc) -> (LocSymbol -> Symbol) -> LocSymbol -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocSymbol -> Symbol
forall a. Located a -> a
F.val

instance TyConable BTyCon where
  isFun :: BTyCon -> Bool
isFun   = LocSymbol -> Bool
forall c. TyConable c => c -> Bool
isFun (LocSymbol -> Bool) -> (BTyCon -> LocSymbol) -> BTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc
  isList :: BTyCon -> Bool
isList  = LocSymbol -> Bool
forall c. TyConable c => c -> Bool
isList (LocSymbol -> Bool) -> (BTyCon -> LocSymbol) -> BTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc
  isTuple :: BTyCon -> Bool
isTuple = LocSymbol -> Bool
forall c. TyConable c => c -> Bool
isTuple (LocSymbol -> Bool) -> (BTyCon -> LocSymbol) -> BTyCon -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc
  isClass :: BTyCon -> Bool
isClass = BTyCon -> Bool
isClassBTyCon
  ppTycon :: BTyCon -> Doc
ppTycon = LocSymbol -> Doc
forall c. TyConable c => c -> Doc
ppTycon (LocSymbol -> Doc) -> (BTyCon -> LocSymbol) -> BTyCon -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc


instance Eq RTyCon where
  RTyCon
x == :: RTyCon -> RTyCon -> Bool
== RTyCon
y = RTyCon -> TyCon
rtc_tc RTyCon
x TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
== RTyCon -> TyCon
rtc_tc RTyCon
y

instance Eq BTyCon where
  BTyCon
x == :: BTyCon -> BTyCon -> Bool
== BTyCon
y = BTyCon -> LocSymbol
btc_tc BTyCon
x LocSymbol -> LocSymbol -> Bool
forall a. Eq a => a -> a -> Bool
== BTyCon -> LocSymbol
btc_tc BTyCon
y

instance Ord BTyCon where
  compare :: BTyCon -> BTyCon -> Ordering
compare BTyCon
x BTyCon
y = LocSymbol -> LocSymbol -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (BTyCon -> LocSymbol
btc_tc BTyCon
x) (BTyCon -> LocSymbol
btc_tc BTyCon
y)

instance F.Fixpoint RTyCon where
  toFix :: RTyCon -> Doc
toFix (RTyCon TyCon
c [PVar RSort]
_ TyConInfo
_) = String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ TyCon -> String
forall a. Outputable a => a -> String
showPpr TyCon
c

instance F.Fixpoint BTyCon where
  toFix :: BTyCon -> Doc
toFix = String -> Doc
text (String -> Doc) -> (BTyCon -> String) -> BTyCon -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> String
F.symbolString (Symbol -> String) -> (BTyCon -> Symbol) -> BTyCon -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocSymbol -> Symbol
forall a. Located a -> a
F.val (LocSymbol -> Symbol) -> (BTyCon -> LocSymbol) -> BTyCon -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc

instance F.Fixpoint Cinfo where
  toFix :: Cinfo -> Doc
toFix = String -> Doc
text (String -> Doc) -> (Cinfo -> String) -> Cinfo -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> String
forall a. Outputable a => a -> String
showPpr (SrcSpan -> String) -> (Cinfo -> SrcSpan) -> Cinfo -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cinfo -> SrcSpan
ci_loc

instance Show Cinfo where
  show :: Cinfo -> String
show = Doc -> String
forall a. Show a => a -> String
show (Doc -> String) -> (Cinfo -> Doc) -> Cinfo -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cinfo -> Doc
forall a. Fixpoint a => a -> Doc
F.toFix

instance F.PPrint RTyCon where
  pprintTidy :: Tidy -> RTyCon -> Doc
pprintTidy Tidy
k RTyCon
c
    | PPEnv -> Bool
ppDebug PPEnv
ppEnv = Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Symbol
tc  Doc -> Doc -> Doc
<-> Doc -> Doc
angleBrackets (Tidy -> [PVar RSort] -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k [PVar RSort]
pvs)
    | Bool
otherwise     = String -> Doc
text (String -> Doc) -> (RTyCon -> String) -> RTyCon -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyCon -> String
forall a. Outputable a => a -> String
showPpr (TyCon -> String) -> (RTyCon -> TyCon) -> RTyCon -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc (RTyCon -> Doc) -> RTyCon -> Doc
forall a b. (a -> b) -> a -> b
$ RTyCon
c
    where
      tc :: Symbol
tc            = TyCon -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (RTyCon -> TyCon
rtc_tc RTyCon
c)
      pvs :: [PVar RSort]
pvs           = RTyCon -> [PVar RSort]
rtc_pvars RTyCon
c

instance F.PPrint BTyCon where
  pprintTidy :: Tidy -> BTyCon -> Doc
pprintTidy Tidy
_ = String -> Doc
text (String -> Doc) -> (BTyCon -> String) -> BTyCon -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> String
F.symbolString (Symbol -> String) -> (BTyCon -> Symbol) -> BTyCon -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocSymbol -> Symbol
forall a. Located a -> a
F.val (LocSymbol -> Symbol) -> (BTyCon -> LocSymbol) -> BTyCon -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc

instance F.PPrint v => F.PPrint (RTVar v s) where
  pprintTidy :: Tidy -> RTVar v s -> Doc
pprintTidy Tidy
k (RTVar v
x RTVInfo s
_) = Tidy -> v -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k v
x

instance Show RTyCon where
  show :: RTyCon -> String
show = RTyCon -> String
forall a. PPrint a => a -> String
F.showpp

instance Show BTyCon where
  show :: BTyCon -> String
show = BTyCon -> String
forall a. PPrint a => a -> String
F.showpp

instance F.Loc BTyCon where
  srcSpan :: BTyCon -> SrcSpan
srcSpan = LocSymbol -> SrcSpan
forall a. Loc a => a -> SrcSpan
F.srcSpan (LocSymbol -> SrcSpan)
-> (BTyCon -> LocSymbol) -> BTyCon -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc

--------------------------------------------------------------------------------
-- | Refined Instances ---------------------------------------------------------
--------------------------------------------------------------------------------

data RInstance t = RI
  { forall t. RInstance t -> BTyCon
riclass :: BTyCon
  , forall t. RInstance t -> [t]
ritype  :: [t]
  , forall t. RInstance t -> [(LocSymbol, RISig t)]
risigs  :: [(F.LocSymbol, RISig t)]
  } deriving (RInstance t -> RInstance t -> Bool
(RInstance t -> RInstance t -> Bool)
-> (RInstance t -> RInstance t -> Bool) -> Eq (RInstance t)
forall t. Eq t => RInstance t -> RInstance t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall t. Eq t => RInstance t -> RInstance t -> Bool
== :: RInstance t -> RInstance t -> Bool
$c/= :: forall t. Eq t => RInstance t -> RInstance t -> Bool
/= :: RInstance t -> RInstance t -> Bool
Eq, (forall x. RInstance t -> Rep (RInstance t) x)
-> (forall x. Rep (RInstance t) x -> RInstance t)
-> Generic (RInstance t)
forall x. Rep (RInstance t) x -> RInstance t
forall x. RInstance t -> Rep (RInstance t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (RInstance t) x -> RInstance t
forall t x. RInstance t -> Rep (RInstance t) x
$cfrom :: forall t x. RInstance t -> Rep (RInstance t) x
from :: forall x. RInstance t -> Rep (RInstance t) x
$cto :: forall t x. Rep (RInstance t) x -> RInstance t
to :: forall x. Rep (RInstance t) x -> RInstance t
Generic, (forall a b. (a -> b) -> RInstance a -> RInstance b)
-> (forall a b. a -> RInstance b -> RInstance a)
-> Functor RInstance
forall a b. a -> RInstance b -> RInstance a
forall a b. (a -> b) -> RInstance a -> RInstance b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> RInstance a -> RInstance b
fmap :: forall a b. (a -> b) -> RInstance a -> RInstance b
$c<$ :: forall a b. a -> RInstance b -> RInstance a
<$ :: forall a b. a -> RInstance b -> RInstance a
Functor, Typeable (RInstance t)
Typeable (RInstance t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RInstance t -> c (RInstance t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RInstance t))
-> (RInstance t -> Constr)
-> (RInstance t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RInstance t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RInstance t)))
-> ((forall b. Data b => b -> b) -> RInstance t -> RInstance t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RInstance t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RInstance t -> r)
-> (forall u. (forall d. Data d => d -> u) -> RInstance t -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RInstance t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t))
-> Data (RInstance t)
RInstance t -> Constr
RInstance t -> DataType
(forall b. Data b => b -> b) -> RInstance t -> RInstance t
forall t. Data t => Typeable (RInstance t)
forall t. Data t => RInstance t -> Constr
forall t. Data t => RInstance t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> RInstance t -> RInstance t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> RInstance t -> u
forall t u.
Data t =>
(forall d. Data d => d -> u) -> RInstance t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RInstance t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> c (RInstance t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RInstance t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RInstance t -> u
forall u. (forall d. Data d => d -> u) -> RInstance t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RInstance t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> c (RInstance t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RInstance t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> c (RInstance t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> c (RInstance t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RInstance t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RInstance t)
$ctoConstr :: forall t. Data t => RInstance t -> Constr
toConstr :: RInstance t -> Constr
$cdataTypeOf :: forall t. Data t => RInstance t -> DataType
dataTypeOf :: RInstance t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RInstance t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RInstance t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> RInstance t -> RInstance t
gmapT :: (forall b. Data b => b -> b) -> RInstance t -> RInstance t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> RInstance t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RInstance t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> RInstance t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RInstance t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
Data, Typeable, Int -> RInstance t -> ShowS
[RInstance t] -> ShowS
RInstance t -> String
(Int -> RInstance t -> ShowS)
-> (RInstance t -> String)
-> ([RInstance t] -> ShowS)
-> Show (RInstance t)
forall t. Show t => Int -> RInstance t -> ShowS
forall t. Show t => [RInstance t] -> ShowS
forall t. Show t => RInstance t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> RInstance t -> ShowS
showsPrec :: Int -> RInstance t -> ShowS
$cshow :: forall t. Show t => RInstance t -> String
show :: RInstance t -> String
$cshowList :: forall t. Show t => [RInstance t] -> ShowS
showList :: [RInstance t] -> ShowS
Show)
    deriving Eq (RInstance t)
Eq (RInstance t) =>
(Int -> RInstance t -> Int)
-> (RInstance t -> Int) -> Hashable (RInstance t)
Int -> RInstance t -> Int
RInstance t -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall t. Hashable t => Eq (RInstance t)
forall t. Hashable t => Int -> RInstance t -> Int
forall t. Hashable t => RInstance t -> Int
$chashWithSalt :: forall t. Hashable t => Int -> RInstance t -> Int
hashWithSalt :: Int -> RInstance t -> Int
$chash :: forall t. Hashable t => RInstance t -> Int
hash :: RInstance t -> Int
Hashable via Generically (RInstance t)

data RILaws ty = RIL
  { forall ty. RILaws ty -> BTyCon
rilName    :: BTyCon
  , forall ty. RILaws ty -> [ty]
rilSupers  :: [ty]
  , forall ty. RILaws ty -> [ty]
rilTyArgs  :: [ty]
  , forall ty. RILaws ty -> [(LocSymbol, LocSymbol)]
rilEqus    :: [(F.LocSymbol, F.LocSymbol)]
  , forall ty. RILaws ty -> Located ()
rilPos     :: F.Located ()
  } deriving (RILaws ty -> RILaws ty -> Bool
(RILaws ty -> RILaws ty -> Bool)
-> (RILaws ty -> RILaws ty -> Bool) -> Eq (RILaws ty)
forall ty. Eq ty => RILaws ty -> RILaws ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall ty. Eq ty => RILaws ty -> RILaws ty -> Bool
== :: RILaws ty -> RILaws ty -> Bool
$c/= :: forall ty. Eq ty => RILaws ty -> RILaws ty -> Bool
/= :: RILaws ty -> RILaws ty -> Bool
Eq, Int -> RILaws ty -> ShowS
[RILaws ty] -> ShowS
RILaws ty -> String
(Int -> RILaws ty -> ShowS)
-> (RILaws ty -> String)
-> ([RILaws ty] -> ShowS)
-> Show (RILaws ty)
forall ty. Show ty => Int -> RILaws ty -> ShowS
forall ty. Show ty => [RILaws ty] -> ShowS
forall ty. Show ty => RILaws ty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall ty. Show ty => Int -> RILaws ty -> ShowS
showsPrec :: Int -> RILaws ty -> ShowS
$cshow :: forall ty. Show ty => RILaws ty -> String
show :: RILaws ty -> String
$cshowList :: forall ty. Show ty => [RILaws ty] -> ShowS
showList :: [RILaws ty] -> ShowS
Show, (forall a b. (a -> b) -> RILaws a -> RILaws b)
-> (forall a b. a -> RILaws b -> RILaws a) -> Functor RILaws
forall a b. a -> RILaws b -> RILaws a
forall a b. (a -> b) -> RILaws a -> RILaws b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> RILaws a -> RILaws b
fmap :: forall a b. (a -> b) -> RILaws a -> RILaws b
$c<$ :: forall a b. a -> RILaws b -> RILaws a
<$ :: forall a b. a -> RILaws b -> RILaws a
Functor, Typeable (RILaws ty)
Typeable (RILaws ty) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RILaws ty))
-> (RILaws ty -> Constr)
-> (RILaws ty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RILaws ty)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RILaws ty)))
-> ((forall b. Data b => b -> b) -> RILaws ty -> RILaws ty)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RILaws ty -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RILaws ty -> r)
-> (forall u. (forall d. Data d => d -> u) -> RILaws ty -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RILaws ty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty))
-> Data (RILaws ty)
RILaws ty -> Constr
RILaws ty -> DataType
(forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
forall ty. Data ty => Typeable (RILaws ty)
forall ty. Data ty => RILaws ty -> Constr
forall ty. Data ty => RILaws ty -> DataType
forall ty.
Data ty =>
(forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
forall ty u.
Data ty =>
Int -> (forall d. Data d => d -> u) -> RILaws ty -> u
forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RILaws ty -> [u]
forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
forall ty r r'.
Data ty =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
forall ty (c :: * -> *).
Data ty =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RILaws ty)
forall ty (c :: * -> *).
Data ty =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty)
forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
forall ty (t :: * -> * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RILaws ty))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RILaws ty -> u
forall u. (forall d. Data d => d -> u) -> RILaws ty -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RILaws ty)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RILaws ty))
$cgfoldl :: forall ty (c :: * -> *).
Data ty =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty)
$cgunfold :: forall ty (c :: * -> *).
Data ty =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RILaws ty)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RILaws ty)
$ctoConstr :: forall ty. Data ty => RILaws ty -> Constr
toConstr :: RILaws ty -> Constr
$cdataTypeOf :: forall ty. Data ty => RILaws ty -> DataType
dataTypeOf :: RILaws ty -> DataType
$cdataCast1 :: forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
$cdataCast2 :: forall ty (t :: * -> * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RILaws ty))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RILaws ty))
$cgmapT :: forall ty.
Data ty =>
(forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
gmapT :: (forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
$cgmapQl :: forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
$cgmapQr :: forall ty r r'.
Data ty =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RILaws ty -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RILaws ty -> [u]
$cgmapQi :: forall ty u.
Data ty =>
Int -> (forall d. Data d => d -> u) -> RILaws ty -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RILaws ty -> u
$cgmapM :: forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
$cgmapMp :: forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
$cgmapMo :: forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
Data, Typeable, (forall x. RILaws ty -> Rep (RILaws ty) x)
-> (forall x. Rep (RILaws ty) x -> RILaws ty)
-> Generic (RILaws ty)
forall x. Rep (RILaws ty) x -> RILaws ty
forall x. RILaws ty -> Rep (RILaws ty) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty x. Rep (RILaws ty) x -> RILaws ty
forall ty x. RILaws ty -> Rep (RILaws ty) x
$cfrom :: forall ty x. RILaws ty -> Rep (RILaws ty) x
from :: forall x. RILaws ty -> Rep (RILaws ty) x
$cto :: forall ty x. Rep (RILaws ty) x -> RILaws ty
to :: forall x. Rep (RILaws ty) x -> RILaws ty
Generic)
    deriving Eq (RILaws ty)
Eq (RILaws ty) =>
(Int -> RILaws ty -> Int)
-> (RILaws ty -> Int) -> Hashable (RILaws ty)
Int -> RILaws ty -> Int
RILaws ty -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall ty. Hashable ty => Eq (RILaws ty)
forall ty. Hashable ty => Int -> RILaws ty -> Int
forall ty. Hashable ty => RILaws ty -> Int
$chashWithSalt :: forall ty. Hashable ty => Int -> RILaws ty -> Int
hashWithSalt :: Int -> RILaws ty -> Int
$chash :: forall ty. Hashable ty => RILaws ty -> Int
hash :: RILaws ty -> Int
Hashable via Generically (RILaws ty)

data RISig t = RIAssumed t | RISig t
  deriving (RISig t -> RISig t -> Bool
(RISig t -> RISig t -> Bool)
-> (RISig t -> RISig t -> Bool) -> Eq (RISig t)
forall t. Eq t => RISig t -> RISig t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall t. Eq t => RISig t -> RISig t -> Bool
== :: RISig t -> RISig t -> Bool
$c/= :: forall t. Eq t => RISig t -> RISig t -> Bool
/= :: RISig t -> RISig t -> Bool
Eq, (forall x. RISig t -> Rep (RISig t) x)
-> (forall x. Rep (RISig t) x -> RISig t) -> Generic (RISig t)
forall x. Rep (RISig t) x -> RISig t
forall x. RISig t -> Rep (RISig t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (RISig t) x -> RISig t
forall t x. RISig t -> Rep (RISig t) x
$cfrom :: forall t x. RISig t -> Rep (RISig t) x
from :: forall x. RISig t -> Rep (RISig t) x
$cto :: forall t x. Rep (RISig t) x -> RISig t
to :: forall x. Rep (RISig t) x -> RISig t
Generic, (forall a b. (a -> b) -> RISig a -> RISig b)
-> (forall a b. a -> RISig b -> RISig a) -> Functor RISig
forall a b. a -> RISig b -> RISig a
forall a b. (a -> b) -> RISig a -> RISig b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> RISig a -> RISig b
fmap :: forall a b. (a -> b) -> RISig a -> RISig b
$c<$ :: forall a b. a -> RISig b -> RISig a
<$ :: forall a b. a -> RISig b -> RISig a
Functor, Typeable (RISig t)
Typeable (RISig t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RISig t -> c (RISig t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RISig t))
-> (RISig t -> Constr)
-> (RISig t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RISig t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t)))
-> ((forall b. Data b => b -> b) -> RISig t -> RISig t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RISig t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RISig t -> r)
-> (forall u. (forall d. Data d => d -> u) -> RISig t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RISig t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RISig t -> m (RISig t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RISig t -> m (RISig t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RISig t -> m (RISig t))
-> Data (RISig t)
RISig t -> Constr
RISig t -> DataType
(forall b. Data b => b -> b) -> RISig t -> RISig t
forall t. Data t => Typeable (RISig t)
forall t. Data t => RISig t -> Constr
forall t. Data t => RISig t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> RISig t -> RISig t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> RISig t -> u
forall t u.
Data t =>
(forall d. Data d => d -> u) -> RISig t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RISig t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> c (RISig t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RISig t -> u
forall u. (forall d. Data d => d -> u) -> RISig t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RISig t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> c (RISig t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> c (RISig t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> c (RISig t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RISig t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RISig t)
$ctoConstr :: forall t. Data t => RISig t -> Constr
toConstr :: RISig t -> Constr
$cdataTypeOf :: forall t. Data t => RISig t -> DataType
dataTypeOf :: RISig t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> RISig t -> RISig t
gmapT :: (forall b. Data b => b -> b) -> RISig t -> RISig t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> RISig t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RISig t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> RISig t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RISig t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
Data, Typeable, Int -> RISig t -> ShowS
[RISig t] -> ShowS
RISig t -> String
(Int -> RISig t -> ShowS)
-> (RISig t -> String) -> ([RISig t] -> ShowS) -> Show (RISig t)
forall t. Show t => Int -> RISig t -> ShowS
forall t. Show t => [RISig t] -> ShowS
forall t. Show t => RISig t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> RISig t -> ShowS
showsPrec :: Int -> RISig t -> ShowS
$cshow :: forall t. Show t => RISig t -> String
show :: RISig t -> String
$cshowList :: forall t. Show t => [RISig t] -> ShowS
showList :: [RISig t] -> ShowS
Show)
  deriving Eq (RISig t)
Eq (RISig t) =>
(Int -> RISig t -> Int) -> (RISig t -> Int) -> Hashable (RISig t)
Int -> RISig t -> Int
RISig t -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall t. Hashable t => Eq (RISig t)
forall t. Hashable t => Int -> RISig t -> Int
forall t. Hashable t => RISig t -> Int
$chashWithSalt :: forall t. Hashable t => Int -> RISig t -> Int
hashWithSalt :: Int -> RISig t -> Int
$chash :: forall t. Hashable t => RISig t -> Int
hash :: RISig t -> Int
Hashable via Generically (RISig t)

instance F.PPrint t => F.PPrint (RISig t) where
  pprintTidy :: Tidy -> RISig t -> Doc
pprintTidy Tidy
k = Tidy -> Doc -> RISig t -> Doc
forall k t. (PPrint k, PPrint t) => Tidy -> k -> RISig t -> Doc
ppRISig Tidy
k (Doc
empty :: Doc)

ppRISig :: (F.PPrint k, F.PPrint t) => F.Tidy -> k -> RISig t -> Doc
ppRISig :: forall k t. (PPrint k, PPrint t) => Tidy -> k -> RISig t -> Doc
ppRISig Tidy
k k
x (RIAssumed t
t) = Doc
"assume" Doc -> Doc -> Doc
<+> Tidy -> k -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k k
x Doc -> Doc -> Doc
<+> Doc
"::" Doc -> Doc -> Doc
<+> Tidy -> t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k t
t
ppRISig Tidy
k k
x (RISig t
t)     =              Tidy -> k -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k k
x Doc -> Doc -> Doc
<+> Doc
"::" Doc -> Doc -> Doc
<+> Tidy -> t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k t
t

instance F.PPrint t => F.PPrint (RInstance t) where
  pprintTidy :: Tidy -> RInstance t -> Doc
pprintTidy Tidy
k (RI BTyCon
n [t]
ts [(LocSymbol, RISig t)]
mts) = Tidy -> Doc -> BTyCon -> [t] -> [(LocSymbol, RISig t)] -> Doc
forall x t a n.
(PPrint x, PPrint t, PPrint a, PPrint n) =>
Tidy -> Doc -> n -> [a] -> [(x, RISig t)] -> Doc
ppMethods Tidy
k Doc
"instance" BTyCon
n [t]
ts [(LocSymbol, RISig t)]
mts


instance (B.Binary t) => B.Binary (RInstance t)
instance (B.Binary t) => B.Binary (RISig t)
instance (B.Binary t) => B.Binary (RILaws t)

newtype DEnv x ty = DEnv (M.HashMap x (M.HashMap Symbol (RISig ty)))
                    deriving (NonEmpty (DEnv x ty) -> DEnv x ty
DEnv x ty -> DEnv x ty -> DEnv x ty
(DEnv x ty -> DEnv x ty -> DEnv x ty)
-> (NonEmpty (DEnv x ty) -> DEnv x ty)
-> (forall b. Integral b => b -> DEnv x ty -> DEnv x ty)
-> Semigroup (DEnv x ty)
forall b. Integral b => b -> DEnv x ty -> DEnv x ty
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall x ty. Hashable x => NonEmpty (DEnv x ty) -> DEnv x ty
forall x ty. Hashable x => DEnv x ty -> DEnv x ty -> DEnv x ty
forall x ty b.
(Hashable x, Integral b) =>
b -> DEnv x ty -> DEnv x ty
$c<> :: forall x ty. Hashable x => DEnv x ty -> DEnv x ty -> DEnv x ty
<> :: DEnv x ty -> DEnv x ty -> DEnv x ty
$csconcat :: forall x ty. Hashable x => NonEmpty (DEnv x ty) -> DEnv x ty
sconcat :: NonEmpty (DEnv x ty) -> DEnv x ty
$cstimes :: forall x ty b.
(Hashable x, Integral b) =>
b -> DEnv x ty -> DEnv x ty
stimes :: forall b. Integral b => b -> DEnv x ty -> DEnv x ty
Semigroup, Semigroup (DEnv x ty)
DEnv x ty
Semigroup (DEnv x ty) =>
DEnv x ty
-> (DEnv x ty -> DEnv x ty -> DEnv x ty)
-> ([DEnv x ty] -> DEnv x ty)
-> Monoid (DEnv x ty)
[DEnv x ty] -> DEnv x ty
DEnv x ty -> DEnv x ty -> DEnv x ty
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall x ty. Hashable x => Semigroup (DEnv x ty)
forall x ty. Hashable x => DEnv x ty
forall x ty. Hashable x => [DEnv x ty] -> DEnv x ty
forall x ty. Hashable x => DEnv x ty -> DEnv x ty -> DEnv x ty
$cmempty :: forall x ty. Hashable x => DEnv x ty
mempty :: DEnv x ty
$cmappend :: forall x ty. Hashable x => DEnv x ty -> DEnv x ty -> DEnv x ty
mappend :: DEnv x ty -> DEnv x ty -> DEnv x ty
$cmconcat :: forall x ty. Hashable x => [DEnv x ty] -> DEnv x ty
mconcat :: [DEnv x ty] -> DEnv x ty
Monoid, Int -> DEnv x ty -> ShowS
[DEnv x ty] -> ShowS
DEnv x ty -> String
(Int -> DEnv x ty -> ShowS)
-> (DEnv x ty -> String)
-> ([DEnv x ty] -> ShowS)
-> Show (DEnv x ty)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall x ty. (Show x, Show ty) => Int -> DEnv x ty -> ShowS
forall x ty. (Show x, Show ty) => [DEnv x ty] -> ShowS
forall x ty. (Show x, Show ty) => DEnv x ty -> String
$cshowsPrec :: forall x ty. (Show x, Show ty) => Int -> DEnv x ty -> ShowS
showsPrec :: Int -> DEnv x ty -> ShowS
$cshow :: forall x ty. (Show x, Show ty) => DEnv x ty -> String
show :: DEnv x ty -> String
$cshowList :: forall x ty. (Show x, Show ty) => [DEnv x ty] -> ShowS
showList :: [DEnv x ty] -> ShowS
Show, (forall a b. (a -> b) -> DEnv x a -> DEnv x b)
-> (forall a b. a -> DEnv x b -> DEnv x a) -> Functor (DEnv x)
forall a b. a -> DEnv x b -> DEnv x a
forall a b. (a -> b) -> DEnv x a -> DEnv x b
forall x a b. a -> DEnv x b -> DEnv x a
forall x a b. (a -> b) -> DEnv x a -> DEnv x b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall x a b. (a -> b) -> DEnv x a -> DEnv x b
fmap :: forall a b. (a -> b) -> DEnv x a -> DEnv x b
$c<$ :: forall x a b. a -> DEnv x b -> DEnv x a
<$ :: forall a b. a -> DEnv x b -> DEnv x a
Functor)

type RDEnv = DEnv Var SpecType

data MethodType t = MT {forall t. MethodType t -> Maybe t
tyInstance :: !(Maybe t), forall t. MethodType t -> Maybe t
tyClass :: !(Maybe t) }
  deriving (Int -> MethodType t -> ShowS
[MethodType t] -> ShowS
MethodType t -> String
(Int -> MethodType t -> ShowS)
-> (MethodType t -> String)
-> ([MethodType t] -> ShowS)
-> Show (MethodType t)
forall t. Show t => Int -> MethodType t -> ShowS
forall t. Show t => [MethodType t] -> ShowS
forall t. Show t => MethodType t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall t. Show t => Int -> MethodType t -> ShowS
showsPrec :: Int -> MethodType t -> ShowS
$cshow :: forall t. Show t => MethodType t -> String
show :: MethodType t -> String
$cshowList :: forall t. Show t => [MethodType t] -> ShowS
showList :: [MethodType t] -> ShowS
Show)

getMethodType :: MethodType t -> Maybe t
getMethodType :: forall t. MethodType t -> Maybe t
getMethodType (MT (Just t
t) Maybe t
_ ) = t -> Maybe t
forall a. a -> Maybe a
Just t
t
getMethodType (MT Maybe t
_ Maybe t
t) = Maybe t
t

--------------------------------------------------------------------------
-- | Values Related to Specifications ------------------------------------
--------------------------------------------------------------------------

data Axiom b s e = Axiom
  { forall b s e. Axiom b s e -> (Var, Maybe DataCon)
aname  :: (Var, Maybe DataCon)
  , forall b s e. Axiom b s e -> Maybe b
rname  :: Maybe b
  , forall b s e. Axiom b s e -> [b]
abinds :: [b]
  , forall b s e. Axiom b s e -> [s]
atypes :: [s]
  , forall b s e. Axiom b s e -> e
alhs   :: e
  , forall b s e. Axiom b s e -> e
arhs   :: e
  }

type HAxiom = Axiom Var    Type CoreExpr

-- type AxiomEq = F.Equation

instance Show (Axiom Var Type CoreExpr) where
  show :: Axiom Var Type CoreExpr -> String
show (Axiom (Var
n, Maybe DataCon
c) Maybe Var
v [Var]
bs [Type]
_ts CoreExpr
lhs CoreExpr
rhs) = String
"Axiom : " String -> ShowS
forall a. [a] -> [a] -> [a]
++
                                         String
"\nFun Name: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Var -> String
forall a. Outputable a => a -> String
showPpr Var
n String -> ShowS
forall a. [a] -> [a] -> [a]
++
                                         String
"\nReal Name: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Var -> String
forall a. Outputable a => a -> String
showPpr Maybe Var
v String -> ShowS
forall a. [a] -> [a] -> [a]
++
                                         String
"\nData Con: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe DataCon -> String
forall a. Outputable a => a -> String
showPpr Maybe DataCon
c String -> ShowS
forall a. [a] -> [a] -> [a]
++
                                         String
"\nArguments:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Var] -> String
forall a. Outputable a => a -> String
showPpr [Var]
bs  String -> ShowS
forall a. [a] -> [a] -> [a]
++
                                         -- "\nTypes    :" ++ (showPpr ts)  ++
                                         String
"\nLHS      :" String -> ShowS
forall a. [a] -> [a] -> [a]
++ CoreExpr -> String
forall a. Outputable a => a -> String
showPpr CoreExpr
lhs String -> ShowS
forall a. [a] -> [a] -> [a]
++
                                         String
"\nRHS      :" String -> ShowS
forall a. [a] -> [a] -> [a]
++ CoreExpr -> String
forall a. Outputable a => a -> String
showPpr CoreExpr
rhs

--------------------------------------------------------------------------------
-- | Data type refinements
--------------------------------------------------------------------------------
data DataDecl   = DataDecl
  { DataDecl -> DataName
tycName   :: DataName              -- ^ Type  Constructor Name
  , DataDecl -> [Symbol]
tycTyVars :: [Symbol]              -- ^ Tyvar Parameters
  , DataDecl -> [PVar BSort]
tycPVars  :: [PVar BSort]          -- ^ PVar  Parameters
  , DataDecl -> Maybe [DataCtor]
tycDCons  :: Maybe [DataCtor]      -- ^ Data Constructors (Nothing is reserved for non-GADT style empty data declarations)
  , DataDecl -> SourcePos
tycSrcPos :: !F.SourcePos          -- ^ Source Position
  , DataDecl -> Maybe SizeFun
tycSFun   :: Maybe SizeFun         -- ^ Default termination measure
  , DataDecl -> Maybe BareType
tycPropTy :: Maybe BareType        -- ^ Type of Ind-Prop
  , DataDecl -> DataDeclKind
tycKind   :: !DataDeclKind         -- ^ User-defined or Auto-lifted
  } deriving (Typeable DataDecl
Typeable DataDecl =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataDecl -> c DataDecl)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataDecl)
-> (DataDecl -> Constr)
-> (DataDecl -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataDecl))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl))
-> ((forall b. Data b => b -> b) -> DataDecl -> DataDecl)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDecl -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDecl -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataDecl -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataDecl -> m DataDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDecl -> m DataDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDecl -> m DataDecl)
-> Data DataDecl
DataDecl -> Constr
DataDecl -> DataType
(forall b. Data b => b -> b) -> DataDecl -> DataDecl
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u
forall u. (forall d. Data d => d -> u) -> DataDecl -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDecl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDecl -> c DataDecl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDecl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDecl -> c DataDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDecl -> c DataDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDecl
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDecl
$ctoConstr :: DataDecl -> Constr
toConstr :: DataDecl -> Constr
$cdataTypeOf :: DataDecl -> DataType
dataTypeOf :: DataDecl -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl)
$cgmapT :: (forall b. Data b => b -> b) -> DataDecl -> DataDecl
gmapT :: (forall b. Data b => b -> b) -> DataDecl -> DataDecl
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDecl -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataDecl -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
Data, Typeable, (forall x. DataDecl -> Rep DataDecl x)
-> (forall x. Rep DataDecl x -> DataDecl) -> Generic DataDecl
forall x. Rep DataDecl x -> DataDecl
forall x. DataDecl -> Rep DataDecl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataDecl -> Rep DataDecl x
from :: forall x. DataDecl -> Rep DataDecl x
$cto :: forall x. Rep DataDecl x -> DataDecl
to :: forall x. Rep DataDecl x -> DataDecl
Generic)
    deriving Eq DataDecl
Eq DataDecl =>
(Int -> DataDecl -> Int) -> (DataDecl -> Int) -> Hashable DataDecl
Int -> DataDecl -> Int
DataDecl -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> DataDecl -> Int
hashWithSalt :: Int -> DataDecl -> Int
$chash :: DataDecl -> Int
hash :: DataDecl -> Int
Hashable via Generically DataDecl

-- | The name of the `TyCon` corresponding to a `DataDecl`
data DataName
  = DnName !F.LocSymbol                -- ^ for 'isVanillyAlgTyCon' we can directly use the `TyCon` name
  | DnCon  !F.LocSymbol                -- ^ for 'FamInst' TyCon we save some `DataCon` name
  deriving (DataName -> DataName -> Bool
(DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool) -> Eq DataName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataName -> DataName -> Bool
== :: DataName -> DataName -> Bool
$c/= :: DataName -> DataName -> Bool
/= :: DataName -> DataName -> Bool
Eq, Eq DataName
Eq DataName =>
(DataName -> DataName -> Ordering)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> DataName)
-> (DataName -> DataName -> DataName)
-> Ord DataName
DataName -> DataName -> Bool
DataName -> DataName -> Ordering
DataName -> DataName -> DataName
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DataName -> DataName -> Ordering
compare :: DataName -> DataName -> Ordering
$c< :: DataName -> DataName -> Bool
< :: DataName -> DataName -> Bool
$c<= :: DataName -> DataName -> Bool
<= :: DataName -> DataName -> Bool
$c> :: DataName -> DataName -> Bool
> :: DataName -> DataName -> Bool
$c>= :: DataName -> DataName -> Bool
>= :: DataName -> DataName -> Bool
$cmax :: DataName -> DataName -> DataName
max :: DataName -> DataName -> DataName
$cmin :: DataName -> DataName -> DataName
min :: DataName -> DataName -> DataName
Ord, Typeable DataName
Typeable DataName =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataName -> c DataName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataName)
-> (DataName -> Constr)
-> (DataName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName))
-> ((forall b. Data b => b -> b) -> DataName -> DataName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataName -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataName -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataName -> m DataName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataName -> m DataName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataName -> m DataName)
-> Data DataName
DataName -> Constr
DataName -> DataType
(forall b. Data b => b -> b) -> DataName -> DataName
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u
forall u. (forall d. Data d => d -> u) -> DataName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataName -> c DataName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataName -> c DataName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataName -> c DataName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataName
$ctoConstr :: DataName -> Constr
toConstr :: DataName -> Constr
$cdataTypeOf :: DataName -> DataType
dataTypeOf :: DataName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName)
$cgmapT :: (forall b. Data b => b -> b) -> DataName -> DataName
gmapT :: (forall b. Data b => b -> b) -> DataName -> DataName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataName -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
Data, Typeable, (forall x. DataName -> Rep DataName x)
-> (forall x. Rep DataName x -> DataName) -> Generic DataName
forall x. Rep DataName x -> DataName
forall x. DataName -> Rep DataName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataName -> Rep DataName x
from :: forall x. DataName -> Rep DataName x
$cto :: forall x. Rep DataName x -> DataName
to :: forall x. Rep DataName x -> DataName
Generic)

-- | Data Constructor
data DataCtor = DataCtor
  { DataCtor -> LocSymbol
dcName   :: F.LocSymbol            -- ^ DataCon name
  , DataCtor -> [Symbol]
dcTyVars :: [F.Symbol]             -- ^ Type parameters
  , DataCtor -> [BareType]
dcTheta  :: [BareType]             -- ^ The GHC ThetaType corresponding to DataCon.dataConSig
  , DataCtor -> [(Symbol, BareType)]
dcFields :: [(Symbol, BareType)]   -- ^ field-name and field-Type pairs
  , DataCtor -> Maybe BareType
dcResult :: Maybe BareType         -- ^ Possible output (if in GADT form)
  } deriving (Typeable DataCtor
Typeable DataCtor =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataCtor -> c DataCtor)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataCtor)
-> (DataCtor -> Constr)
-> (DataCtor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataCtor))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor))
-> ((forall b. Data b => b -> b) -> DataCtor -> DataCtor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataCtor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataCtor -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataCtor -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataCtor -> m DataCtor)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataCtor -> m DataCtor)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataCtor -> m DataCtor)
-> Data DataCtor
DataCtor -> Constr
DataCtor -> DataType
(forall b. Data b => b -> b) -> DataCtor -> DataCtor
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u
forall u. (forall d. Data d => d -> u) -> DataCtor -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataCtor
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataCtor -> c DataCtor
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataCtor)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataCtor -> c DataCtor
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataCtor -> c DataCtor
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataCtor
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataCtor
$ctoConstr :: DataCtor -> Constr
toConstr :: DataCtor -> Constr
$cdataTypeOf :: DataCtor -> DataType
dataTypeOf :: DataCtor -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataCtor)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataCtor)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor)
$cgmapT :: (forall b. Data b => b -> b) -> DataCtor -> DataCtor
gmapT :: (forall b. Data b => b -> b) -> DataCtor -> DataCtor
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataCtor -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataCtor -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
Data, Typeable, (forall x. DataCtor -> Rep DataCtor x)
-> (forall x. Rep DataCtor x -> DataCtor) -> Generic DataCtor
forall x. Rep DataCtor x -> DataCtor
forall x. DataCtor -> Rep DataCtor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataCtor -> Rep DataCtor x
from :: forall x. DataCtor -> Rep DataCtor x
$cto :: forall x. Rep DataCtor x -> DataCtor
to :: forall x. Rep DataCtor x -> DataCtor
Generic, DataCtor -> DataCtor -> Bool
(DataCtor -> DataCtor -> Bool)
-> (DataCtor -> DataCtor -> Bool) -> Eq DataCtor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataCtor -> DataCtor -> Bool
== :: DataCtor -> DataCtor -> Bool
$c/= :: DataCtor -> DataCtor -> Bool
/= :: DataCtor -> DataCtor -> Bool
Eq)
    deriving Eq DataCtor
Eq DataCtor =>
(Int -> DataCtor -> Int) -> (DataCtor -> Int) -> Hashable DataCtor
Int -> DataCtor -> Int
DataCtor -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> DataCtor -> Int
hashWithSalt :: Int -> DataCtor -> Int
$chash :: DataCtor -> Int
hash :: DataCtor -> Int
Hashable via Generically DataCtor

-- | Termination expressions
data SizeFun
  = IdSizeFun              -- ^ \x -> F.EVar x
  | SymSizeFun F.LocSymbol -- ^ \x -> f x
  deriving (Typeable SizeFun
Typeable SizeFun =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> SizeFun -> c SizeFun)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SizeFun)
-> (SizeFun -> Constr)
-> (SizeFun -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SizeFun))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SizeFun))
-> ((forall b. Data b => b -> b) -> SizeFun -> SizeFun)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SizeFun -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SizeFun -> r)
-> (forall u. (forall d. Data d => d -> u) -> SizeFun -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SizeFun -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SizeFun -> m SizeFun)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SizeFun -> m SizeFun)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SizeFun -> m SizeFun)
-> Data SizeFun
SizeFun -> Constr
SizeFun -> DataType
(forall b. Data b => b -> b) -> SizeFun -> SizeFun
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SizeFun -> u
forall u. (forall d. Data d => d -> u) -> SizeFun -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SizeFun -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SizeFun -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SizeFun
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SizeFun -> c SizeFun
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SizeFun)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SizeFun)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SizeFun -> c SizeFun
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SizeFun -> c SizeFun
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SizeFun
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SizeFun
$ctoConstr :: SizeFun -> Constr
toConstr :: SizeFun -> Constr
$cdataTypeOf :: SizeFun -> DataType
dataTypeOf :: SizeFun -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SizeFun)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SizeFun)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SizeFun)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SizeFun)
$cgmapT :: (forall b. Data b => b -> b) -> SizeFun -> SizeFun
gmapT :: (forall b. Data b => b -> b) -> SizeFun -> SizeFun
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SizeFun -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SizeFun -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SizeFun -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SizeFun -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SizeFun -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> SizeFun -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SizeFun -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SizeFun -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SizeFun -> m SizeFun
Data, Typeable, (forall x. SizeFun -> Rep SizeFun x)
-> (forall x. Rep SizeFun x -> SizeFun) -> Generic SizeFun
forall x. Rep SizeFun x -> SizeFun
forall x. SizeFun -> Rep SizeFun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SizeFun -> Rep SizeFun x
from :: forall x. SizeFun -> Rep SizeFun x
$cto :: forall x. Rep SizeFun x -> SizeFun
to :: forall x. Rep SizeFun x -> SizeFun
Generic, SizeFun -> SizeFun -> Bool
(SizeFun -> SizeFun -> Bool)
-> (SizeFun -> SizeFun -> Bool) -> Eq SizeFun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SizeFun -> SizeFun -> Bool
== :: SizeFun -> SizeFun -> Bool
$c/= :: SizeFun -> SizeFun -> Bool
/= :: SizeFun -> SizeFun -> Bool
Eq)
  deriving Eq SizeFun
Eq SizeFun =>
(Int -> SizeFun -> Int) -> (SizeFun -> Int) -> Hashable SizeFun
Int -> SizeFun -> Int
SizeFun -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> SizeFun -> Int
hashWithSalt :: Int -> SizeFun -> Int
$chash :: SizeFun -> Int
hash :: SizeFun -> Int
Hashable via Generically SizeFun

-- | What kind of `DataDecl` is it?
data DataDeclKind
  = DataUser           -- ^ User defined data-definitions         (should have refined fields)
  | DataReflected      -- ^ Automatically lifted data-definitions (do not have refined fields)
  deriving (DataDeclKind -> DataDeclKind -> Bool
(DataDeclKind -> DataDeclKind -> Bool)
-> (DataDeclKind -> DataDeclKind -> Bool) -> Eq DataDeclKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataDeclKind -> DataDeclKind -> Bool
== :: DataDeclKind -> DataDeclKind -> Bool
$c/= :: DataDeclKind -> DataDeclKind -> Bool
/= :: DataDeclKind -> DataDeclKind -> Bool
Eq, Typeable DataDeclKind
Typeable DataDeclKind =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataDeclKind -> c DataDeclKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataDeclKind)
-> (DataDeclKind -> Constr)
-> (DataDeclKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataDeclKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DataDeclKind))
-> ((forall b. Data b => b -> b) -> DataDeclKind -> DataDeclKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataDeclKind -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind)
-> Data DataDeclKind
DataDeclKind -> Constr
DataDeclKind -> DataType
(forall b. Data b => b -> b) -> DataDeclKind -> DataDeclKind
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u
forall u. (forall d. Data d => d -> u) -> DataDeclKind -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclKind
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclKind -> c DataDeclKind
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclKind)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DataDeclKind)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclKind -> c DataDeclKind
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclKind -> c DataDeclKind
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclKind
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclKind
$ctoConstr :: DataDeclKind -> Constr
toConstr :: DataDeclKind -> Constr
$cdataTypeOf :: DataDeclKind -> DataType
dataTypeOf :: DataDeclKind -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclKind)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclKind)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DataDeclKind)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DataDeclKind)
$cgmapT :: (forall b. Data b => b -> b) -> DataDeclKind -> DataDeclKind
gmapT :: (forall b. Data b => b -> b) -> DataDeclKind -> DataDeclKind
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclKind -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclKind -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind
Data, Typeable, (forall x. DataDeclKind -> Rep DataDeclKind x)
-> (forall x. Rep DataDeclKind x -> DataDeclKind)
-> Generic DataDeclKind
forall x. Rep DataDeclKind x -> DataDeclKind
forall x. DataDeclKind -> Rep DataDeclKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataDeclKind -> Rep DataDeclKind x
from :: forall x. DataDeclKind -> Rep DataDeclKind x
$cto :: forall x. Rep DataDeclKind x -> DataDeclKind
to :: forall x. Rep DataDeclKind x -> DataDeclKind
Generic, Int -> DataDeclKind -> ShowS
[DataDeclKind] -> ShowS
DataDeclKind -> String
(Int -> DataDeclKind -> ShowS)
-> (DataDeclKind -> String)
-> ([DataDeclKind] -> ShowS)
-> Show DataDeclKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DataDeclKind -> ShowS
showsPrec :: Int -> DataDeclKind -> ShowS
$cshow :: DataDeclKind -> String
show :: DataDeclKind -> String
$cshowList :: [DataDeclKind] -> ShowS
showList :: [DataDeclKind] -> ShowS
Show)
  deriving Eq DataDeclKind
Eq DataDeclKind =>
(Int -> DataDeclKind -> Int)
-> (DataDeclKind -> Int) -> Hashable DataDeclKind
Int -> DataDeclKind -> Int
DataDeclKind -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> DataDeclKind -> Int
hashWithSalt :: Int -> DataDeclKind -> Int
$chash :: DataDeclKind -> Int
hash :: DataDeclKind -> Int
Hashable via Generically DataDeclKind

instance Show SizeFun where
  show :: SizeFun -> String
show SizeFun
IdSizeFun      = String
"IdSizeFun"
  show (SymSizeFun LocSymbol
x) = String
"SymSizeFun " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Symbol -> String
forall a. Show a => a -> String
show (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
x)

szFun :: SizeFun -> Symbol -> Expr
szFun :: SizeFun -> Symbol -> Expr
szFun SizeFun
IdSizeFun      = Symbol -> Expr
F.EVar
szFun (SymSizeFun LocSymbol
f) = \Symbol
x -> LocSymbol -> [Expr] -> Expr
F.mkEApp (Symbol -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (Symbol -> Symbol) -> LocSymbol -> LocSymbol
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LocSymbol
f) [Symbol -> Expr
F.EVar Symbol
x]

data HasDataDecl
  = NoDecl  (Maybe SizeFun)
  | HasDecl
  deriving (Int -> HasDataDecl -> ShowS
[HasDataDecl] -> ShowS
HasDataDecl -> String
(Int -> HasDataDecl -> ShowS)
-> (HasDataDecl -> String)
-> ([HasDataDecl] -> ShowS)
-> Show HasDataDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HasDataDecl -> ShowS
showsPrec :: Int -> HasDataDecl -> ShowS
$cshow :: HasDataDecl -> String
show :: HasDataDecl -> String
$cshowList :: [HasDataDecl] -> ShowS
showList :: [HasDataDecl] -> ShowS
Show)

instance F.PPrint HasDataDecl where
  pprintTidy :: Tidy -> HasDataDecl -> Doc
pprintTidy Tidy
_ HasDataDecl
HasDecl    = String -> Doc
text String
"HasDecl"
  pprintTidy Tidy
k (NoDecl Maybe SizeFun
z) = String -> Doc
text String
"NoDecl" Doc -> Doc -> Doc
<+> Doc -> Doc
parens (Tidy -> Maybe SizeFun -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Maybe SizeFun
z)

hasDecl :: DataDecl -> HasDataDecl
hasDecl :: DataDecl -> HasDataDecl
hasDecl DataDecl
d
  | Maybe [DataCtor] -> Bool
forall a. Maybe a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (DataDecl -> Maybe [DataCtor]
tycDCons DataDecl
d)
  = Maybe SizeFun -> HasDataDecl
NoDecl (DataDecl -> Maybe SizeFun
tycSFun DataDecl
d)
  -- // | Just s <- tycSFun d, null (tycDCons d)
  -- // = NoDecl (Just s)
  | Bool
otherwise
  = HasDataDecl
HasDecl

instance Hashable DataName where
  hashWithSalt :: Int -> DataName -> Int
hashWithSalt Int
i = Int -> Symbol -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
i (Symbol -> Int) -> (DataName -> Symbol) -> DataName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataName -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol


instance NFData   SizeFun
instance B.Binary SizeFun
instance NFData   DataDeclKind
instance B.Binary DataDeclKind
instance B.Binary DataName
instance B.Binary DataCtor
instance B.Binary DataDecl

instance Eq DataDecl where
  DataDecl
d1 == :: DataDecl -> DataDecl -> Bool
== DataDecl
d2 = DataDecl -> DataName
tycName DataDecl
d1 DataName -> DataName -> Bool
forall a. Eq a => a -> a -> Bool
== DataDecl -> DataName
tycName DataDecl
d2

instance Ord DataDecl where
  compare :: DataDecl -> DataDecl -> Ordering
compare DataDecl
d1 DataDecl
d2 = DataName -> DataName -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (DataDecl -> DataName
tycName DataDecl
d1) (DataDecl -> DataName
tycName DataDecl
d2)

instance F.Loc DataCtor where
  srcSpan :: DataCtor -> SrcSpan
srcSpan = LocSymbol -> SrcSpan
forall a. Loc a => a -> SrcSpan
F.srcSpan (LocSymbol -> SrcSpan)
-> (DataCtor -> LocSymbol) -> DataCtor -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCtor -> LocSymbol
dcName

instance F.Loc DataDecl where
  srcSpan :: DataDecl -> SrcSpan
srcSpan = SrcSpan -> SrcSpan
srcSpanFSrcSpan (SrcSpan -> SrcSpan)
-> (DataDecl -> SrcSpan) -> DataDecl -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourcePos -> SrcSpan
sourcePosSrcSpan (SourcePos -> SrcSpan)
-> (DataDecl -> SourcePos) -> DataDecl -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataDecl -> SourcePos
tycSrcPos

instance F.Loc DataName where
  srcSpan :: DataName -> SrcSpan
srcSpan (DnName LocSymbol
z) = LocSymbol -> SrcSpan
forall a. Loc a => a -> SrcSpan
F.srcSpan LocSymbol
z
  srcSpan (DnCon  LocSymbol
z) = LocSymbol -> SrcSpan
forall a. Loc a => a -> SrcSpan
F.srcSpan LocSymbol
z


-- | For debugging.
instance Show DataDecl where
  show :: DataDecl -> String
show DataDecl
dd = String -> String -> String -> String -> ShowS
forall r. PrintfType r => String -> r
printf String
"DataDecl: data = %s, tyvars = %s, sizeFun = %s, kind = %s" -- [at: %s]"
              (DataName -> String
forall a. Show a => a -> String
show (DataName -> String) -> DataName -> String
forall a b. (a -> b) -> a -> b
$ DataDecl -> DataName
tycName   DataDecl
dd)
              ([Symbol] -> String
forall a. Show a => a -> String
show ([Symbol] -> String) -> [Symbol] -> String
forall a b. (a -> b) -> a -> b
$ DataDecl -> [Symbol]
tycTyVars DataDecl
dd)
              (Maybe SizeFun -> String
forall a. Show a => a -> String
show (Maybe SizeFun -> String) -> Maybe SizeFun -> String
forall a b. (a -> b) -> a -> b
$ DataDecl -> Maybe SizeFun
tycSFun   DataDecl
dd)
              (DataDeclKind -> String
forall a. Show a => a -> String
show (DataDeclKind -> String) -> DataDeclKind -> String
forall a b. (a -> b) -> a -> b
$ DataDecl -> DataDeclKind
tycKind   DataDecl
dd)


instance Show DataName where
  show :: DataName -> String
show (DnName LocSymbol
n) =               Symbol -> String
forall a. Show a => a -> String
show (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
n)
  show (DnCon  LocSymbol
c) = String
"datacon:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Symbol -> String
forall a. Show a => a -> String
show (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
c)

instance F.PPrint SizeFun where
  pprintTidy :: Tidy -> SizeFun -> Doc
pprintTidy Tidy
_ SizeFun
IdSizeFun      = Doc
"[id]"
  pprintTidy Tidy
_ (SymSizeFun LocSymbol
x) = Doc -> Doc
brackets (Symbol -> Doc
forall a. PPrint a => a -> Doc
F.pprint (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
x))

instance F.Symbolic DataName where
  symbol :: DataName -> Symbol
symbol = LocSymbol -> Symbol
forall a. Located a -> a
F.val (LocSymbol -> Symbol)
-> (DataName -> LocSymbol) -> DataName -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataName -> LocSymbol
dataNameSymbol

instance F.Symbolic DataDecl where
  symbol :: DataDecl -> Symbol
symbol = DataName -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (DataName -> Symbol)
-> (DataDecl -> DataName) -> DataDecl -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataDecl -> DataName
tycName

instance F.PPrint DataName where
  pprintTidy :: Tidy -> DataName -> Doc
pprintTidy Tidy
k (DnName LocSymbol
n) = Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
n)
  pprintTidy Tidy
k (DnCon  LocSymbol
n) = Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
n)

  -- symbol (DnName z) = F.suffixSymbol "DnName" (F.val z)
  -- symbol (DnCon  z) = F.suffixSymbol "DnCon"  (F.val z)

dataNameSymbol :: DataName -> F.LocSymbol
dataNameSymbol :: DataName -> LocSymbol
dataNameSymbol (DnName LocSymbol
z) = LocSymbol
z
dataNameSymbol (DnCon  LocSymbol
z) = LocSymbol
z

--------------------------------------------------------------------------------
-- | Refinement Type Aliases
--------------------------------------------------------------------------------
data RTAlias x a = RTA
  { forall x a. RTAlias x a -> Symbol
rtName  :: Symbol             -- ^ name of the alias
  , forall x a. RTAlias x a -> [x]
rtTArgs :: [x]                -- ^ type parameters
  , forall x a. RTAlias x a -> [Symbol]
rtVArgs :: [Symbol]           -- ^ value parameters
  , forall x a. RTAlias x a -> a
rtBody  :: a                  -- ^ what the alias expands to
  -- , rtMod   :: !ModName           -- ^ module where alias was defined
  } deriving (RTAlias x a -> RTAlias x a -> Bool
(RTAlias x a -> RTAlias x a -> Bool)
-> (RTAlias x a -> RTAlias x a -> Bool) -> Eq (RTAlias x a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall x a. (Eq x, Eq a) => RTAlias x a -> RTAlias x a -> Bool
$c== :: forall x a. (Eq x, Eq a) => RTAlias x a -> RTAlias x a -> Bool
== :: RTAlias x a -> RTAlias x a -> Bool
$c/= :: forall x a. (Eq x, Eq a) => RTAlias x a -> RTAlias x a -> Bool
/= :: RTAlias x a -> RTAlias x a -> Bool
Eq, Typeable (RTAlias x a)
Typeable (RTAlias x a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RTAlias x a))
-> (RTAlias x a -> Constr)
-> (RTAlias x a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RTAlias x a)))
-> ((forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTAlias x a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a))
-> Data (RTAlias x a)
RTAlias x a -> Constr
RTAlias x a -> DataType
(forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u
forall u. (forall d. Data d => d -> u) -> RTAlias x a -> [u]
forall x a. (Data x, Data a) => Typeable (RTAlias x a)
forall x a. (Data x, Data a) => RTAlias x a -> Constr
forall x a. (Data x, Data a) => RTAlias x a -> DataType
forall x a.
(Data x, Data a) =>
(forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a
forall x a u.
(Data x, Data a) =>
Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u
forall x a u.
(Data x, Data a) =>
(forall d. Data d => d -> u) -> RTAlias x a -> [u]
forall x a r r'.
(Data x, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
forall x a r r'.
(Data x, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
forall x a (m :: * -> *).
(Data x, Data a, Monad m) =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
forall x a (m :: * -> *).
(Data x, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
forall x a (c :: * -> *).
(Data x, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTAlias x a)
forall x a (c :: * -> *).
(Data x, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a)
forall x a (t :: * -> *) (c :: * -> *).
(Data x, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
forall x a (t :: * -> * -> *) (c :: * -> *).
(Data x, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTAlias x a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
$cgfoldl :: forall x a (c :: * -> *).
(Data x, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a)
$cgunfold :: forall x a (c :: * -> *).
(Data x, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTAlias x a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTAlias x a)
$ctoConstr :: forall x a. (Data x, Data a) => RTAlias x a -> Constr
toConstr :: RTAlias x a -> Constr
$cdataTypeOf :: forall x a. (Data x, Data a) => RTAlias x a -> DataType
dataTypeOf :: RTAlias x a -> DataType
$cdataCast1 :: forall x a (t :: * -> *) (c :: * -> *).
(Data x, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
$cdataCast2 :: forall x a (t :: * -> * -> *) (c :: * -> *).
(Data x, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
$cgmapT :: forall x a.
(Data x, Data a) =>
(forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a
gmapT :: (forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a
$cgmapQl :: forall x a r r'.
(Data x, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
$cgmapQr :: forall x a r r'.
(Data x, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
$cgmapQ :: forall x a u.
(Data x, Data a) =>
(forall d. Data d => d -> u) -> RTAlias x a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTAlias x a -> [u]
$cgmapQi :: forall x a u.
(Data x, Data a) =>
Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u
$cgmapM :: forall x a (m :: * -> *).
(Data x, Data a, Monad m) =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
$cgmapMp :: forall x a (m :: * -> *).
(Data x, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
$cgmapMo :: forall x a (m :: * -> *).
(Data x, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
Data, Typeable, (forall x. RTAlias x a -> Rep (RTAlias x a) x)
-> (forall x. Rep (RTAlias x a) x -> RTAlias x a)
-> Generic (RTAlias x a)
forall x. Rep (RTAlias x a) x -> RTAlias x a
forall x. RTAlias x a -> Rep (RTAlias x a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall x a x. Rep (RTAlias x a) x -> RTAlias x a
forall x a x. RTAlias x a -> Rep (RTAlias x a) x
$cfrom :: forall x a x. RTAlias x a -> Rep (RTAlias x a) x
from :: forall x. RTAlias x a -> Rep (RTAlias x a) x
$cto :: forall x a x. Rep (RTAlias x a) x -> RTAlias x a
to :: forall x. Rep (RTAlias x a) x -> RTAlias x a
Generic, (forall a b. (a -> b) -> RTAlias x a -> RTAlias x b)
-> (forall a b. a -> RTAlias x b -> RTAlias x a)
-> Functor (RTAlias x)
forall a b. a -> RTAlias x b -> RTAlias x a
forall a b. (a -> b) -> RTAlias x a -> RTAlias x b
forall x a b. a -> RTAlias x b -> RTAlias x a
forall x a b. (a -> b) -> RTAlias x a -> RTAlias x b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall x a b. (a -> b) -> RTAlias x a -> RTAlias x b
fmap :: forall a b. (a -> b) -> RTAlias x a -> RTAlias x b
$c<$ :: forall x a b. a -> RTAlias x b -> RTAlias x a
<$ :: forall a b. a -> RTAlias x b -> RTAlias x a
Functor)
    deriving Eq (RTAlias x a)
Eq (RTAlias x a) =>
(Int -> RTAlias x a -> Int)
-> (RTAlias x a -> Int) -> Hashable (RTAlias x a)
Int -> RTAlias x a -> Int
RTAlias x a -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall x a. (Hashable x, Hashable a) => Eq (RTAlias x a)
forall x a. (Hashable x, Hashable a) => Int -> RTAlias x a -> Int
forall x a. (Hashable x, Hashable a) => RTAlias x a -> Int
$chashWithSalt :: forall x a. (Hashable x, Hashable a) => Int -> RTAlias x a -> Int
hashWithSalt :: Int -> RTAlias x a -> Int
$chash :: forall x a. (Hashable x, Hashable a) => RTAlias x a -> Int
hash :: RTAlias x a -> Int
Hashable via Generically (RTAlias x a)
-- TODO support ghosts in aliases?

instance (B.Binary x, B.Binary a) => B.Binary (RTAlias x a)

mapRTAVars :: (a -> b) -> RTAlias a ty -> RTAlias b ty
mapRTAVars :: forall a b ty. (a -> b) -> RTAlias a ty -> RTAlias b ty
mapRTAVars a -> b
f RTAlias a ty
rt = RTAlias a ty
rt { rtTArgs = f <$> rtTArgs rt }

lmapEAlias :: LMap -> F.Located (RTAlias Symbol Expr)
lmapEAlias :: LMap -> Located (RTAlias Symbol Expr)
lmapEAlias (LMap LocSymbol
v [Symbol]
ys Expr
e) = LocSymbol -> RTAlias Symbol Expr -> Located (RTAlias Symbol Expr)
forall l b. Loc l => l -> b -> Located b
F.atLoc LocSymbol
v (Symbol -> [Symbol] -> [Symbol] -> Expr -> RTAlias Symbol Expr
forall x a. Symbol -> [x] -> [Symbol] -> a -> RTAlias x a
RTA (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
v) [] [Symbol]
ys Expr
e) -- (F.loc v) (F.loc v)


--------------------------------------------------------------------------------
-- | Constructor and Destructors for RTypes ------------------------------------
--------------------------------------------------------------------------------
data RTypeRep c tv r = RTypeRep
  { forall c tv r. RTypeRep c tv r -> [(RTVar tv (RType c tv ()), r)]
ty_vars   :: [(RTVar tv (RType c tv ()), r)]
  , forall c tv r. RTypeRep c tv r -> [PVar (RType c tv ())]
ty_preds  :: [PVar (RType c tv ())]
  , forall c tv r. RTypeRep c tv r -> [Symbol]
ty_binds  :: [Symbol]
  , forall c tv r. RTypeRep c tv r -> [RFInfo]
ty_info   :: [RFInfo]
  , forall c tv r. RTypeRep c tv r -> [r]
ty_refts  :: [r]
  , forall c tv r. RTypeRep c tv r -> [RType c tv r]
ty_args   :: [RType c tv r]
  , forall c tv r. RTypeRep c tv r -> RType c tv r
ty_res    :: RType c tv r
  }

fromRTypeRep :: RTypeRep c tv r -> RType c tv r
fromRTypeRep :: forall c tv r. RTypeRep c tv r -> RType c tv r
fromRTypeRep RTypeRep{[r]
[(RTVar tv (RType c tv ()), r)]
[Symbol]
[RType c tv r]
[PVar (RType c tv ())]
[RFInfo]
RType c tv r
ty_vars :: forall c tv r. RTypeRep c tv r -> [(RTVar tv (RType c tv ()), r)]
ty_preds :: forall c tv r. RTypeRep c tv r -> [PVar (RType c tv ())]
ty_binds :: forall c tv r. RTypeRep c tv r -> [Symbol]
ty_info :: forall c tv r. RTypeRep c tv r -> [RFInfo]
ty_refts :: forall c tv r. RTypeRep c tv r -> [r]
ty_args :: forall c tv r. RTypeRep c tv r -> [RType c tv r]
ty_res :: forall c tv r. RTypeRep c tv r -> RType c tv r
ty_vars :: [(RTVar tv (RType c tv ()), r)]
ty_preds :: [PVar (RType c tv ())]
ty_binds :: [Symbol]
ty_info :: [RFInfo]
ty_refts :: [r]
ty_args :: [RType c tv r]
ty_res :: RType c tv r
..}
  = [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [(Symbol, RFInfo, RType c tv r, r)]
-> RType c tv r
-> RType c tv r
forall tv c r.
[(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [(Symbol, RFInfo, RType c tv r, r)]
-> RType c tv r
-> RType c tv r
mkArrow [(RTVar tv (RType c tv ()), r)]
ty_vars [PVar (RType c tv ())]
ty_preds [(Symbol, RFInfo, RType c tv r, r)]
arrs RType c tv r
ty_res
  where
    arrs :: [(Symbol, RFInfo, RType c tv r, r)]
arrs = String
-> [Symbol]
-> [RFInfo]
-> [RType c tv r]
-> [r]
-> [(Symbol, RFInfo, RType c tv r, r)]
forall t1 t2 t3 t4.
String -> [t1] -> [t2] -> [t3] -> [t4] -> [(t1, t2, t3, t4)]
safeZip4WithError (String
"fromRTypeRep: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Int, Int, Int, Int) -> String
forall a. Show a => a -> String
show ([Symbol] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
ty_binds, [RFInfo] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [RFInfo]
ty_info, [RType c tv r] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [RType c tv r]
ty_args, [r] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [r]
ty_refts)) [Symbol]
ty_binds [RFInfo]
ty_info [RType c tv r]
ty_args [r]
ty_refts

--------------------------------------------------------------------------------
toRTypeRep           :: RType c tv r -> RTypeRep c tv r
--------------------------------------------------------------------------------
toRTypeRep :: forall c tv r. RType c tv r -> RTypeRep c tv r
toRTypeRep RType c tv r
t         = [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [Symbol]
-> [RFInfo]
-> [r]
-> [RType c tv r]
-> RType c tv r
-> RTypeRep c tv r
forall c tv r.
[(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [Symbol]
-> [RFInfo]
-> [r]
-> [RType c tv r]
-> RType c tv r
-> RTypeRep c tv r
RTypeRep [(RTVar tv (RType c tv ()), r)]
αs [PVar (RType c tv ())]
πs [Symbol]
xs [RFInfo]
is [r]
rs [RType c tv r]
ts RType c tv r
t''
  where
    ([(RTVar tv (RType c tv ()), r)]
αs, [PVar (RType c tv ())]
πs, RType c tv r
t') = RType c tv r
-> ([(RTVar tv (RType c tv ()), r)], [PVar (RType c tv ())],
    RType c tv r)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv RType c tv r
t
    (([Symbol]
xs, [RFInfo]
is, [RType c tv r]
ts, [r]
rs), RType c tv r
t'') = RType c tv r
-> (([Symbol], [RFInfo], [RType c tv r], [r]), RType c tv r)
forall t t1 a.
RType t t1 a
-> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
bkArrow RType c tv r
t'

mkArrow :: [(RTVar tv (RType c tv ()), r)]
        -> [PVar (RType c tv ())]
        -> [(Symbol, RFInfo, RType c tv r, r)]
        -> RType c tv r
        -> RType c tv r
mkArrow :: forall tv c r.
[(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [(Symbol, RFInfo, RType c tv r, r)]
-> RType c tv r
-> RType c tv r
mkArrow [(RTVar tv (RType c tv ()), r)]
αs [PVar (RType c tv ())]
πs [(Symbol, RFInfo, RType c tv r, r)]
zts = [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())] -> RType c tv r -> RType c tv r
forall (t :: * -> *) (t1 :: * -> *) tv c r.
(Foldable t, Foldable t1) =>
t (RTVar tv (RType c tv ()), r)
-> t1 (PVar (RType c tv ())) -> RType c tv r -> RType c tv r
mkUnivs [(RTVar tv (RType c tv ()), r)]
αs [PVar (RType c tv ())]
πs (RType c tv r -> RType c tv r)
-> (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Symbol, RFInfo, RType c tv r, r)] -> RType c tv r -> RType c tv r
forall {t :: * -> *} {c} {tv} {r}.
Foldable t =>
t (Symbol, RFInfo, RType c tv r, r) -> RType c tv r -> RType c tv r
mkRFuns [(Symbol, RFInfo, RType c tv r, r)]
zts
  where
    mkRFuns :: t (Symbol, RFInfo, RType c tv r, r) -> RType c tv r -> RType c tv r
mkRFuns t (Symbol, RFInfo, RType c tv r, r)
xts RType c tv r
t = ((Symbol, RFInfo, RType c tv r, r) -> RType c tv r -> RType c tv r)
-> RType c tv r
-> t (Symbol, RFInfo, RType c tv r, r)
-> RType c tv r
forall a b. (a -> b -> b) -> b -> t a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(Symbol
b,RFInfo
i,RType c tv r
t1,r
r) RType c tv r
t2 -> Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
b RFInfo
i RType c tv r
t1 RType c tv r
t2 r
r) RType c tv r
t t (Symbol, RFInfo, RType c tv r, r)
xts

-- Do I need to keep track of implicits here too?
bkArrowDeep :: RType t t1 a -> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkArrowDeep :: forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkArrowDeep (RAllT RTVU t t1
_ RType t t1 a
t a
_)   = RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkArrowDeep RType t t1 a
t
bkArrowDeep (RAllP PVU t t1
_ RType t t1 a
t)     = RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkArrowDeep RType t t1 a
t
bkArrowDeep (RFun Symbol
x RFInfo
i RType t t1 a
t RType t t1 a
t' a
r) = let ([Symbol]
xs, [RFInfo]
is, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t'') = RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkArrowDeep RType t t1 a
t' in
                                (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
xs, RFInfo
iRFInfo -> [RFInfo] -> [RFInfo]
forall a. a -> [a] -> [a]
:[RFInfo]
is, RType t t1 a
tRType t t1 a -> [RType t t1 a] -> [RType t t1 a]
forall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
ra -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs, RType t t1 a
t'')
bkArrowDeep RType t t1 a
t               = ([], [], [], [], RType t t1 a
t)

bkArrow :: RType t t1 a -> ( ([Symbol], [RFInfo], [RType t t1 a], [a])
                           , RType t t1 a )
bkArrow :: forall t t1 a.
RType t t1 a
-> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
bkArrow RType t t1 a
t                = (([Symbol]
xs,[RFInfo]
is,[RType t t1 a]
ts,[a]
rs),RType t t1 a
t')
  where
    ([Symbol]
xs, [RFInfo]
is, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t') = RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkFun RType t t1 a
t

bkFun :: RType t t1 a -> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkFun :: forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkFun (RFun Symbol
x RFInfo
i RType t t1 a
t RType t t1 a
t' a
r) = let ([Symbol]
xs, [RFInfo]
is, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t'') = RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
RType t t1 a
-> ([Symbol], [RFInfo], [RType t t1 a], [a], RType t t1 a)
bkFun RType t t1 a
t' in
                          (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
xs, RFInfo
iRFInfo -> [RFInfo] -> [RFInfo]
forall a. a -> [a] -> [a]
:[RFInfo]
is, RType t t1 a
tRType t t1 a -> [RType t t1 a] -> [RType t t1 a]
forall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
ra -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs, RType t t1 a
t'')
bkFun RType t t1 a
t                 = ([], [], [], [], RType t t1 a
t)

safeBkArrow ::(F.PPrint (RType t t1 a))
            => RType t t1 a -> ( ([Symbol], [RFInfo], [RType t t1 a], [a])
                               , RType t t1 a )
safeBkArrow :: forall t t1 a.
PPrint (RType t t1 a) =>
RType t t1 a
-> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
safeBkArrow t :: RType t t1 a
t@RAllT {} = String -> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
forall a. (?callStack::CallStack) => String -> a
Prelude.error {- panic Nothing -} (String
 -> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a))
-> String
-> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
forall a b. (a -> b) -> a -> b
$ String
"safeBkArrow on RAllT" String -> ShowS
forall a. [a] -> [a] -> [a]
++ RType t t1 a -> String
forall a. PPrint a => a -> String
F.showpp RType t t1 a
t
safeBkArrow (RAllP PVU t t1
_ RType t t1 a
_)     = String -> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
forall a. (?callStack::CallStack) => String -> a
Prelude.error {- panic Nothing -} String
"safeBkArrow on RAllP"
safeBkArrow RType t t1 a
t               = RType t t1 a
-> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
forall t t1 a.
RType t t1 a
-> (([Symbol], [RFInfo], [RType t t1 a], [a]), RType t t1 a)
bkArrow RType t t1 a
t

mkUnivs :: (Foldable t, Foldable t1)
        => t  (RTVar tv (RType c tv ()), r)
        -> t1 (PVar (RType c tv ()))
        -> RType c tv r
        -> RType c tv r
mkUnivs :: forall (t :: * -> *) (t1 :: * -> *) tv c r.
(Foldable t, Foldable t1) =>
t (RTVar tv (RType c tv ()), r)
-> t1 (PVar (RType c tv ())) -> RType c tv r -> RType c tv r
mkUnivs t (RTVar tv (RType c tv ()), r)
αs t1 (PVar (RType c tv ()))
πs RType c tv r
rt = ((RTVar tv (RType c tv ()), r) -> RType c tv r -> RType c tv r)
-> RType c tv r -> t (RTVar tv (RType c tv ()), r) -> RType c tv r
forall a b. (a -> b -> b) -> b -> t a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(RTVar tv (RType c tv ())
a,r
r) RType c tv r
t -> RTVar tv (RType c tv ()) -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVar tv (RType c tv ())
a RType c tv r
t r
r) ((PVar (RType c tv ()) -> RType c tv r -> RType c tv r)
-> RType c tv r -> t1 (PVar (RType c tv ())) -> RType c tv r
forall a b. (a -> b -> b) -> b -> t1 a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr PVar (RType c tv ()) -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP RType c tv r
rt t1 (PVar (RType c tv ()))
πs) t (RTVar tv (RType c tv ()), r)
αs

bkUnivClass :: SpecType -> ([(SpecRTVar, RReft)],[PVar RSort], [(RTyCon, [SpecType])], SpecType )
bkUnivClass :: SpecType
-> ([(SpecRTVar, UReft Reft)], [PVar RSort],
    [(RTyCon, [SpecType])], SpecType)
bkUnivClass SpecType
t        = ([(SpecRTVar, UReft Reft)]
as, [PVar RSort]
ps, [(RTyCon, [SpecType])]
cs, SpecType
t2)
  where
    ([(SpecRTVar, UReft Reft)]
as, [PVar RSort]
ps, SpecType
t1) = SpecType -> ([(SpecRTVar, UReft Reft)], [PVar RSort], SpecType)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv  SpecType
t
    ([(RTyCon, [SpecType])]
cs, SpecType
t2)     = SpecType -> ([(RTyCon, [SpecType])], SpecType)
forall c tv r.
(PPrint c, TyConable c) =>
RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
bkClass SpecType
t1


bkUniv :: RType tv c r -> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())], RType tv c r)
bkUniv :: forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv (RAllT RTVU tv c
α RType tv c r
t r
r) = let ([(RTVU tv c, r)]
αs, [PVar (RType tv c ())]
πs, RType tv c r
t') = RType tv c r
-> ([(RTVU tv c, r)], [PVar (RType tv c ())], RType tv c r)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv RType tv c r
t in ((RTVU tv c
α, r
r)(RTVU tv c, r) -> [(RTVU tv c, r)] -> [(RTVU tv c, r)]
forall a. a -> [a] -> [a]
:[(RTVU tv c, r)]
αs, [PVar (RType tv c ())]
πs, RType tv c r
t')
bkUniv (RAllP PVar (RType tv c ())
π RType tv c r
t)   = let ([(RTVU tv c, r)]
αs, [PVar (RType tv c ())]
πs, RType tv c r
t') = RType tv c r
-> ([(RTVU tv c, r)], [PVar (RType tv c ())], RType tv c r)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv RType tv c r
t in ([(RTVU tv c, r)]
αs, PVar (RType tv c ())
πPVar (RType tv c ())
-> [PVar (RType tv c ())] -> [PVar (RType tv c ())]
forall a. a -> [a] -> [a]
:[PVar (RType tv c ())]
πs, RType tv c r
t')
bkUniv RType tv c r
t             = ([], [], RType tv c r
t)


-- bkFun :: RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
-- bkFun (RFun x t t' r) = let (xs, ts, rs, t'') = bkFun t'  in (x:xs, t:ts, r:rs, t'')
-- bkFun t               = ([], [], [], t)

bkUnivClass' :: SpecType ->
  ([(SpecRTVar, RReft)], [PVar RSort], [(Symbol, SpecType, RReft)], SpecType)
bkUnivClass' :: SpecType
-> ([(SpecRTVar, UReft Reft)], [PVar RSort],
    [(Symbol, SpecType, UReft Reft)], SpecType)
bkUnivClass' SpecType
t = ([(SpecRTVar, UReft Reft)]
as, [PVar RSort]
ps, [Symbol]
-> [SpecType] -> [UReft Reft] -> [(Symbol, SpecType, UReft Reft)]
forall a b c. [a] -> [b] -> [c] -> [(a, b, c)]
zip3 [Symbol]
bs [SpecType]
ts [UReft Reft]
rs, SpecType
t2)
  where
    ([(SpecRTVar, UReft Reft)]
as, [PVar RSort]
ps, SpecType
t1) = SpecType -> ([(SpecRTVar, UReft Reft)], [PVar RSort], SpecType)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv  SpecType
t
    ([Symbol]
bs, [SpecType]
ts, [UReft Reft]
rs, SpecType
t2)     = SpecType -> ([Symbol], [SpecType], [UReft Reft], SpecType)
forall t t1 a.
TyConable t =>
RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkClass' SpecType
t1

bkClass' :: TyConable t => RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkClass' :: forall t t1 a.
TyConable t =>
RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkClass' (RFun Symbol
x RFInfo
_ t :: RType t t1 a
t@(RApp t
c [RType t t1 a]
_ [RTProp t t1 a]
_ a
_) RType t t1 a
t' a
r)
  | t -> Bool
forall c. TyConable c => c -> Bool
isClass t
c
  = let ([Symbol]
xs, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t'') = RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
TyConable t =>
RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkClass' RType t t1 a
t' in (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
xs, RType t t1 a
tRType t t1 a -> [RType t t1 a] -> [RType t t1 a]
forall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
ra -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs, RType t t1 a
t'')
bkClass' (RRTy [(Symbol, RType t t1 a)]
e a
r Oblig
o RType t t1 a
t)
  = let ([Symbol]
xs, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t'') = RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
TyConable t =>
RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkClass' RType t t1 a
t in ([Symbol]
xs, [RType t t1 a]
ts, [a]
rs, [(Symbol, RType t t1 a)]
-> a -> Oblig -> RType t t1 a -> RType t t1 a
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy [(Symbol, RType t t1 a)]
e a
r Oblig
o RType t t1 a
t'')
bkClass' RType t t1 a
t
  = ([], [],[],RType t t1 a
t)

bkClass :: (F.PPrint c, TyConable c) => RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
bkClass :: forall c tv r.
(PPrint c, TyConable c) =>
RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
bkClass (RFun Symbol
_ RFInfo
_ (RApp c
c [RType c tv r]
t [RTProp c tv r]
_ r
_) RType c tv r
t' r
_)
  | String -> Bool -> Bool
forall a. PPrint a => String -> a -> a
F.notracepp (String
"IS-CLASS: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ c -> String
forall a. PPrint a => a -> String
F.showpp c
c) (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ c -> Bool
forall c. TyConable c => c -> Bool
isClass c
c
  = let ([(c, [RType c tv r])]
cs, RType c tv r
t'') = RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
forall c tv r.
(PPrint c, TyConable c) =>
RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
bkClass RType c tv r
t' in ((c
c, [RType c tv r]
t)(c, [RType c tv r])
-> [(c, [RType c tv r])] -> [(c, [RType c tv r])]
forall a. a -> [a] -> [a]
:[(c, [RType c tv r])]
cs, RType c tv r
t'')
bkClass (RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t)
  = let ([(c, [RType c tv r])]
cs, RType c tv r
t') = RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
forall c tv r.
(PPrint c, TyConable c) =>
RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
bkClass RType c tv r
t in ([(c, [RType c tv r])]
cs, [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t')
bkClass RType c tv r
t
  = ([], RType c tv r
t)

rFun :: Monoid r => Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFun :: forall r c tv.
Monoid r =>
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFun Symbol
b RType c tv r
t RType c tv r
t' = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
b RFInfo
defRFInfo RType c tv r
t RType c tv r
t' r
forall a. Monoid a => a
mempty

rFun' :: Monoid r => RFInfo -> Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFun' :: forall r c tv.
Monoid r =>
RFInfo -> Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFun' RFInfo
i Symbol
b RType c tv r
t RType c tv r
t' = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
b RFInfo
i RType c tv r
t RType c tv r
t' r
forall a. Monoid a => a
mempty

rFunDebug :: Monoid r => Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFunDebug :: forall r c tv.
Monoid r =>
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFunDebug Symbol
b RType c tv r
t RType c tv r
t' = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
b (Bool -> RFInfo
classRFInfo Bool
True) RType c tv r
t RType c tv r
t' r
forall a. Monoid a => a
mempty

rCls :: Monoid r => TyCon -> [RType RTyCon tv r] -> RType RTyCon tv r
rCls :: forall r tv.
Monoid r =>
TyCon -> [RType RTyCon tv r] -> RType RTyCon tv r
rCls TyCon
c [RType RTyCon tv r]
ts   = RTyCon
-> [RType RTyCon tv r]
-> [RTProp RTyCon tv r]
-> r
-> RType RTyCon tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp (TyCon -> [PVar RSort] -> TyConInfo -> RTyCon
RTyCon TyCon
c [] TyConInfo
defaultTyConInfo) [RType RTyCon tv r]
ts [] r
forall a. Monoid a => a
mempty

rRCls :: Monoid r => c -> [RType c tv r] -> RType c tv r
rRCls :: forall r c tv. Monoid r => c -> [RType c tv r] -> RType c tv r
rRCls c
rc [RType c tv r]
ts = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
rc [RType c tv r]
ts [] r
forall a. Monoid a => a
mempty

addInvCond :: SpecType -> RReft -> SpecType
addInvCond :: SpecType -> UReft Reft -> SpecType
addInvCond SpecType
t UReft Reft
r'
  | Reft -> Bool
forall r. Reftable r => r -> Bool
F.isTauto (Reft -> Bool) -> Reft -> Bool
forall a b. (a -> b) -> a -> b
$ UReft Reft -> Reft
forall r. UReft r -> r
ur_reft UReft Reft
r' -- null rv
  = SpecType
t
  | Bool
otherwise
  = RTypeRep RTyCon RTyVar (UReft Reft) -> SpecType
forall c tv r. RTypeRep c tv r -> RType c tv r
fromRTypeRep (RTypeRep RTyCon RTyVar (UReft Reft) -> SpecType)
-> RTypeRep RTyCon RTyVar (UReft Reft) -> SpecType
forall a b. (a -> b) -> a -> b
$ RTypeRep RTyCon RTyVar (UReft Reft)
trep {ty_res = RRTy [(x', tbd)] r OInv tbd}
  where
    trep :: RTypeRep RTyCon RTyVar (UReft Reft)
trep = SpecType -> RTypeRep RTyCon RTyVar (UReft Reft)
forall c tv r. RType c tv r -> RTypeRep c tv r
toRTypeRep SpecType
t
    tbd :: SpecType
tbd  = RTypeRep RTyCon RTyVar (UReft Reft) -> SpecType
forall c tv r. RTypeRep c tv r -> RType c tv r
ty_res RTypeRep RTyCon RTyVar (UReft Reft)
trep
    r :: UReft Reft
r    = UReft Reft
r' {ur_reft = F.Reft (v, rx)}
    su :: (Symbol, Expr)
su   = (Symbol
v, Symbol -> Expr
F.EVar Symbol
x')
    x' :: Symbol
x'   = Symbol
"xInv"
    rx :: Expr
rx   = Expr -> Expr -> Expr
F.PIff (Symbol -> Expr
F.EVar Symbol
v) (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ Expr -> (Symbol, Expr) -> Expr
forall a. Subable a => a -> (Symbol, Expr) -> a
F.subst1 Expr
rv (Symbol, Expr)
su
    F.Reft(Symbol
v, Expr
rv) = UReft Reft -> Reft
forall r. UReft r -> r
ur_reft UReft Reft
r'

-------------------------------------------

class F.Reftable r => UReftable r where
  ofUReft :: UReft F.Reft -> r
  ofUReft (MkUReft Reft
r Predicate
_) = Reft -> r
forall r. Reftable r => Reft -> r
F.ofReft Reft
r


instance UReftable (UReft F.Reft) where
   ofUReft :: UReft Reft -> UReft Reft
ofUReft UReft Reft
r = UReft Reft
r

instance UReftable () where
   ofUReft :: UReft Reft -> ()
ofUReft UReft Reft
_ = ()
forall a. Monoid a => a
mempty

instance (F.PPrint r, F.Reftable r) => F.Reftable (UReft r) where
  isTauto :: UReft r -> Bool
isTauto               = UReft r -> Bool
forall r. Reftable r => UReft r -> Bool
isTautoUreft
  ppTy :: UReft r -> Doc -> Doc
ppTy                  = UReft r -> Doc -> Doc
forall r. Reftable r => UReft r -> Doc -> Doc
ppTyUreft
  toReft :: UReft r -> Reft
toReft (MkUReft r
r Predicate
ps) = r -> Reft
forall r. Reftable r => r -> Reft
F.toReft r
r Reft -> Reft -> Reft
forall r. Reftable r => r -> r -> r
`F.meet` Predicate -> Reft
forall r. Reftable r => r -> Reft
F.toReft Predicate
ps
  params :: UReft r -> [Symbol]
params (MkUReft r
r Predicate
_)  = r -> [Symbol]
forall r. Reftable r => r -> [Symbol]
F.params r
r
  bot :: UReft r -> UReft r
bot (MkUReft r
r Predicate
_)     = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (r -> r
forall r. Reftable r => r -> r
F.bot r
r) ([UsedPVar] -> Predicate
Pr [])
  top :: UReft r -> UReft r
top (MkUReft r
r Predicate
p)     = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (r -> r
forall r. Reftable r => r -> r
F.top r
r) (Predicate -> Predicate
forall r. Reftable r => r -> r
F.top Predicate
p)
  ofReft :: Reft -> UReft r
ofReft Reft
r              = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (Reft -> r
forall r. Reftable r => Reft -> r
F.ofReft Reft
r) Predicate
forall a. Monoid a => a
mempty

instance F.Expression (UReft ()) where
  expr :: UReft () -> Expr
expr = Reft -> Expr
forall a. Expression a => a -> Expr
F.expr (Reft -> Expr) -> (UReft () -> Reft) -> UReft () -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UReft () -> Reft
forall r. Reftable r => r -> Reft
F.toReft



isTautoUreft :: F.Reftable r => UReft r -> Bool
isTautoUreft :: forall r. Reftable r => UReft r -> Bool
isTautoUreft UReft r
u = r -> Bool
forall r. Reftable r => r -> Bool
F.isTauto (UReft r -> r
forall r. UReft r -> r
ur_reft UReft r
u) Bool -> Bool -> Bool
&& Predicate -> Bool
forall r. Reftable r => r -> Bool
F.isTauto (UReft r -> Predicate
forall r. UReft r -> Predicate
ur_pred UReft r
u)

ppTyUreft :: F.Reftable r => UReft r -> Doc -> Doc
ppTyUreft :: forall r. Reftable r => UReft r -> Doc -> Doc
ppTyUreft u :: UReft r
u@(MkUReft r
r Predicate
p) Doc
d
  | UReft r -> Bool
forall r. Reftable r => UReft r -> Bool
isTautoUreft UReft r
u = Doc
d
  | Bool
otherwise      = r -> Doc -> Doc
forall r. Reftable r => r -> Doc -> Doc
pprReft r
r (Predicate -> Doc -> Doc
forall r. Reftable r => r -> Doc -> Doc
F.ppTy Predicate
p Doc
d)

pprReft :: (F.Reftable r) => r -> Doc -> Doc
pprReft :: forall r. Reftable r => r -> Doc -> Doc
pprReft r
r Doc
d = Doc -> Doc
braces (Symbol -> Doc
forall a. PPrint a => a -> Doc
F.pprint Symbol
v Doc -> Doc -> Doc
<+> Doc
colon Doc -> Doc -> Doc
<+> Doc
d Doc -> Doc -> Doc
<+> String -> Doc
text String
"|" Doc -> Doc -> Doc
<+> Reft -> Doc
forall a. PPrint a => a -> Doc
F.pprint Reft
r')
  where
    r' :: Reft
r'@(F.Reft (Symbol
v, Expr
_)) = r -> Reft
forall r. Reftable r => r -> Reft
F.toReft r
r

instance F.Subable r => F.Subable (UReft r) where
  syms :: UReft r -> [Symbol]
syms (MkUReft r
r Predicate
p)     = r -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms r
r [Symbol] -> [Symbol] -> [Symbol]
forall a. [a] -> [a] -> [a]
++ Predicate -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms Predicate
p
  subst :: Subst -> UReft r -> UReft r
subst Subst
s (MkUReft r
r Predicate
z)  = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (Subst -> r -> r
forall a. Subable a => Subst -> a -> a
F.subst Subst
s r
r)  (Subst -> Predicate -> Predicate
forall a. Subable a => Subst -> a -> a
F.subst Subst
s Predicate
z)
  substf :: (Symbol -> Expr) -> UReft r -> UReft r
substf Symbol -> Expr
f (MkUReft r
r Predicate
z) = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft ((Symbol -> Expr) -> r -> r
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f r
r) ((Symbol -> Expr) -> Predicate -> Predicate
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f Predicate
z)
  substa :: (Symbol -> Symbol) -> UReft r -> UReft r
substa Symbol -> Symbol
f (MkUReft r
r Predicate
z) = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft ((Symbol -> Symbol) -> r -> r
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f r
r) ((Symbol -> Symbol) -> Predicate -> Predicate
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f Predicate
z)

instance (F.Reftable r, TyConable c) => F.Subable (RTProp c tv r) where
  syms :: RTProp c tv r -> [Symbol]
syms (RProp  [(Symbol, RType c tv ())]
ss RType c tv r
r)     = ((Symbol, RType c tv ()) -> Symbol
forall a b. (a, b) -> a
fst ((Symbol, RType c tv ()) -> Symbol)
-> [(Symbol, RType c tv ())] -> [Symbol]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv ())]
ss) [Symbol] -> [Symbol] -> [Symbol]
forall a. [a] -> [a] -> [a]
++ RType c tv r -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms RType c tv r
r

  subst :: Subst -> RTProp c tv r -> RTProp c tv r
subst Subst
su (RProp [(Symbol, RType c tv ())]
ss (RHole r
r)) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole (Subst -> r -> r
forall a. Subable a => Subst -> a -> a
F.subst Subst
su r
r))
  subst Subst
su (RProp  [(Symbol, RType c tv ())]
ss RType c tv r
t) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (Subst -> r -> r
forall a. Subable a => Subst -> a -> a
F.subst Subst
su (r -> r) -> RType c tv r -> RType c tv r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RType c tv r
t)

  substf :: (Symbol -> Expr) -> RTProp c tv r -> RTProp c tv r
substf Symbol -> Expr
f (RProp [(Symbol, RType c tv ())]
ss (RHole r
r)) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole ((Symbol -> Expr) -> r -> r
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f r
r))
  substf Symbol -> Expr
f (RProp  [(Symbol, RType c tv ())]
ss RType c tv r
t) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss ((Symbol -> Expr) -> r -> r
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f (r -> r) -> RType c tv r -> RType c tv r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RType c tv r
t)

  substa :: (Symbol -> Symbol) -> RTProp c tv r -> RTProp c tv r
substa Symbol -> Symbol
f (RProp [(Symbol, RType c tv ())]
ss (RHole r
r)) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole ((Symbol -> Symbol) -> r -> r
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f r
r))
  substa Symbol -> Symbol
f (RProp  [(Symbol, RType c tv ())]
ss RType c tv r
t) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss ((Symbol -> Symbol) -> r -> r
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f (r -> r) -> RType c tv r -> RType c tv r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RType c tv r
t)


instance (F.Subable r, F.Reftable r, TyConable c) => F.Subable (RType c tv r) where
  syms :: RType c tv r -> [Symbol]
syms        = Bool
-> (SEnv (RType c tv r) -> r -> [Symbol] -> [Symbol])
-> [Symbol]
-> RType c tv r
-> [Symbol]
forall r c tv a.
(Reftable r, TyConable c) =>
Bool
-> (SEnv (RType c tv r) -> r -> a -> a) -> a -> RType c tv r -> a
foldReft Bool
False (\SEnv (RType c tv r)
_ r
r [Symbol]
acc -> r -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms r
r [Symbol] -> [Symbol] -> [Symbol]
forall a. [a] -> [a] -> [a]
++ [Symbol]
acc) []
  -- 'substa' will substitute bound vars
  substa :: (Symbol -> Symbol) -> RType c tv r -> RType c tv r
substa Symbol -> Symbol
f    = ([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ -> (Symbol -> Symbol) -> Expr -> Expr
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f) []      (RType c tv r -> RType c tv r)
-> (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (r -> r) -> RType c tv r -> RType c tv r
forall r1 r2 c tv. (r1 -> r2) -> RType c tv r1 -> RType c tv r2
mapReft  ((Symbol -> Symbol) -> r -> r
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f)
  -- 'substf' will NOT substitute bound vars
  substf :: (Symbol -> Expr) -> RType c tv r -> RType c tv r
substf Symbol -> Expr
f    = ([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ -> (Symbol -> Expr) -> Expr -> Expr
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f) []      (RType c tv r -> RType c tv r)
-> (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Symbol] -> r -> r) -> [Symbol] -> RType c tv r -> RType c tv r
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft ((Symbol -> Expr) -> r -> r
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf ((Symbol -> Expr) -> r -> r)
-> ([Symbol] -> Symbol -> Expr) -> [Symbol] -> r -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Symbol -> Expr) -> [Symbol] -> Symbol -> Expr
F.substfExcept Symbol -> Expr
f) []
  subst :: Subst -> RType c tv r -> RType c tv r
subst Subst
su    = ([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ -> Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst Subst
su) []      (RType c tv r -> RType c tv r)
-> (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Symbol] -> r -> r) -> [Symbol] -> RType c tv r -> RType c tv r
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft (Subst -> r -> r
forall a. Subable a => Subst -> a -> a
F.subst  (Subst -> r -> r) -> ([Symbol] -> Subst) -> [Symbol] -> r -> r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Subst -> [Symbol] -> Subst
F.substExcept Subst
su) []
  subst1 :: RType c tv r -> (Symbol, Expr) -> RType c tv r
subst1 RType c tv r
t (Symbol, Expr)
su = ([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ Expr
e -> Expr -> (Symbol, Expr) -> Expr
forall a. Subable a => a -> (Symbol, Expr) -> a
F.subst1 Expr
e (Symbol, Expr)
su) [] (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall a b. (a -> b) -> a -> b
$ ([Symbol] -> r -> r) -> [Symbol] -> RType c tv r -> RType c tv r
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft (\[Symbol]
xs r
r -> [Symbol] -> r -> (Symbol, Expr) -> r
forall a. Subable a => [Symbol] -> a -> (Symbol, Expr) -> a
F.subst1Except [Symbol]
xs r
r (Symbol, Expr)
su) [] RType c tv r
t


instance F.Reftable Predicate where
  isTauto :: Predicate -> Bool
isTauto (Pr [UsedPVar]
ps)      = [UsedPVar] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [UsedPVar]
ps

  bot :: Predicate -> Predicate
bot (Pr [UsedPVar]
_)           = Maybe SrcSpan -> String -> Predicate
forall a. Maybe SrcSpan -> String -> a
panic Maybe SrcSpan
forall a. Maybe a
Nothing String
"No BOT instance for Predicate"
  ppTy :: Predicate -> Doc -> Doc
ppTy Predicate
r Doc
d | Predicate -> Bool
forall r. Reftable r => r -> Bool
F.isTauto Predicate
r      = Doc
d
           | Bool -> Bool
not (PPEnv -> Bool
ppPs PPEnv
ppEnv) = Doc
d
           | Bool
otherwise        = Doc
d Doc -> Doc -> Doc
<-> Doc -> Doc
angleBrackets (Predicate -> Doc
forall a. PPrint a => a -> Doc
F.pprint Predicate
r)

  toReft :: Predicate -> Reft
toReft (Pr ps :: [UsedPVar]
ps@(UsedPVar
p:[UsedPVar]
_))        = (Symbol, Expr) -> Reft
F.Reft (UsedPVar -> Symbol
forall t. PVar t -> Symbol
parg UsedPVar
p, [Expr] -> Expr
F.pAnd ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ UsedPVar -> Expr
forall a. PVar a -> Expr
pToRef (UsedPVar -> Expr) -> [UsedPVar] -> [Expr]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UsedPVar]
ps)
  toReft Predicate
_                    = Reft
forall a. Monoid a => a
mempty
  params :: Predicate -> [Symbol]
params                      = Maybe SrcSpan -> String -> Predicate -> [Symbol]
forall a. Maybe SrcSpan -> String -> a
todo Maybe SrcSpan
forall a. Maybe a
Nothing String
"TODO: instance of params for Predicate"

  ofReft :: Reft -> Predicate
ofReft = Maybe SrcSpan -> String -> Reft -> Predicate
forall a. Maybe SrcSpan -> String -> a
todo Maybe SrcSpan
forall a. Maybe a
Nothing String
"TODO: Predicate.ofReft"

pToRef :: PVar a -> F.Expr
pToRef :: forall a. PVar a -> Expr
pToRef PVar a
p = Symbol -> [Expr] -> Expr
pApp (PVar a -> Symbol
forall t. PVar t -> Symbol
pname PVar a
p) ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ Symbol -> Expr
F.EVar (PVar a -> Symbol
forall t. PVar t -> Symbol
parg PVar a
p) Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: ((a, Symbol, Expr) -> Expr
forall a b c. (a, b, c) -> c
thd3 ((a, Symbol, Expr) -> Expr) -> [(a, Symbol, Expr)] -> [Expr]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PVar a -> [(a, Symbol, Expr)]
forall t. PVar t -> [(t, Symbol, Expr)]
pargs PVar a
p)

pApp      :: Symbol -> [Expr] -> Expr
pApp :: Symbol -> [Expr] -> Expr
pApp Symbol
p [Expr]
es = LocSymbol -> [Expr] -> Expr
F.mkEApp LocSymbol
fn (Symbol -> Expr
F.EVar Symbol
pExpr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
:[Expr]
es)
  where
    fn :: LocSymbol
fn    = Symbol -> LocSymbol
forall a. a -> Located a
F.dummyLoc (Int -> Symbol
forall a. Show a => a -> Symbol
pappSym Int
n)
    n :: Int
n     = [Expr] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Expr]
es

pappSym :: Show a => a -> Symbol
pappSym :: forall a. Show a => a -> Symbol
pappSym a
n  = String -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (String -> Symbol) -> String -> Symbol
forall a b. (a -> b) -> a -> b
$ String
"papp" String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
n

--------------------------------------------------------------------------------
-- | Visitors ------------------------------------------------------------------
--------------------------------------------------------------------------------
mapExprReft :: (Symbol -> Expr -> Expr) -> RType c tv RReft -> RType c tv RReft
mapExprReft :: forall c tv.
(Symbol -> Expr -> Expr)
-> RType c tv (UReft Reft) -> RType c tv (UReft Reft)
mapExprReft Symbol -> Expr -> Expr
f = (UReft Reft -> UReft Reft)
-> RType c tv (UReft Reft) -> RType c tv (UReft Reft)
forall r1 r2 c tv. (r1 -> r2) -> RType c tv r1 -> RType c tv r2
mapReft UReft Reft -> UReft Reft
g
  where
    g :: UReft Reft -> UReft Reft
g (MkUReft (F.Reft (Symbol
x, Expr
e)) Predicate
p) = Reft -> Predicate -> UReft Reft
forall r. r -> Predicate -> UReft r
MkUReft ((Symbol, Expr) -> Reft
F.Reft (Symbol
x, Symbol -> Expr -> Expr
f Symbol
x Expr
e)) Predicate
p

-- const False (not dropping dict) is probably fine since there will not be refinement on
-- dictionaries
isTrivial :: (F.Reftable r, TyConable c) => RType c tv r -> Bool
isTrivial :: forall r c tv. (Reftable r, TyConable c) => RType c tv r -> Bool
isTrivial = Bool
-> (SEnv (RType c tv r) -> r -> Bool -> Bool)
-> Bool
-> RType c tv r
-> Bool
forall r c tv a.
(Reftable r, TyConable c) =>
Bool
-> (SEnv (RType c tv r) -> r -> a -> a) -> a -> RType c tv r -> a
foldReft Bool
False (\SEnv (RType c tv r)
_ r
r Bool
b -> r -> Bool
forall r. Reftable r => r -> Bool
F.isTauto r
r Bool -> Bool -> Bool
&& Bool
b) Bool
True

mapReft ::  (r1 -> r2) -> RType c tv r1 -> RType c tv r2
mapReft :: forall r1 r2 c tv. (r1 -> r2) -> RType c tv r1 -> RType c tv r2
mapReft r1 -> r2
f = ([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft ((r1 -> r2) -> [Symbol] -> r1 -> r2
forall a b. a -> b -> a
const r1 -> r2
f) []

emapReft ::  ([Symbol] -> r1 -> r2) -> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft :: forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RVar tv
α r1
r)        = tv -> r2 -> RType c tv r2
forall c tv r. tv -> r -> RType c tv r
RVar  tv
α ([Symbol] -> r1 -> r2
f [Symbol]
γ r1
r)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RAllT RTVU c tv
α RType c tv r1
t r1
r)     = RTVU c tv -> RType c tv r2 -> r2 -> RType c tv r2
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t) ([Symbol] -> r1 -> r2
f [Symbol]
γ r1
r)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RAllP PVU c tv
π RType c tv r1
t)       = PVU c tv -> RType c tv r2 -> RType c tv r2
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RFun Symbol
x RFInfo
i RType c tv r1
t RType c tv r1
t' r1
r) = Symbol
-> RFInfo -> RType c tv r2 -> RType c tv r2 -> r2 -> RType c tv r2
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun  Symbol
x RFInfo
i (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t) (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
γ) RType c tv r1
t') ([Symbol] -> r1 -> r2
f (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
γ) r1
r)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RApp c
c [RType c tv r1]
ts [RTProp c tv r1]
rs r1
r)  = c -> [RType c tv r2] -> [RTProp c tv r2] -> r2 -> RType c tv r2
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RType c tv r1 -> RType c tv r2)
-> [RType c tv r1] -> [RType c tv r2]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r1]
ts) (([Symbol] -> r1 -> r2)
-> [Symbol] -> RTProp c tv r1 -> RTProp c tv r2
forall t s c tv.
([Symbol] -> t -> s) -> [Symbol] -> RTProp c tv t -> RTProp c tv s
emapRef [Symbol] -> r1 -> r2
f [Symbol]
γ (RTProp c tv r1 -> RTProp c tv r2)
-> [RTProp c tv r1] -> [RTProp c tv r2]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r1]
rs) ([Symbol] -> r1 -> r2
f [Symbol]
γ r1
r)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RAllE Symbol
z RType c tv r1
t RType c tv r1
t')    = Symbol -> RType c tv r2 -> RType c tv r2 -> RType c tv r2
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t) (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t')
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (REx Symbol
z RType c tv r1
t RType c tv r1
t')      = Symbol -> RType c tv r2 -> RType c tv r2 -> RType c tv r2
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx   Symbol
z (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t) (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t')
emapReft [Symbol] -> r1 -> r2
_ [Symbol]
_ (RExprArg Located Expr
e)      = Located Expr -> RType c tv r2
forall c tv r. Located Expr -> RType c tv r
RExprArg Located Expr
e
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RAppTy RType c tv r1
t RType c tv r1
t' r1
r)   = RType c tv r2 -> RType c tv r2 -> r2 -> RType c tv r2
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t) (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t') ([Symbol] -> r1 -> r2
f [Symbol]
γ r1
r)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RRTy [(Symbol, RType c tv r1)]
e r1
r Oblig
o RType c tv r1
t)    = [(Symbol, RType c tv r2)]
-> r2 -> Oblig -> RType c tv r2 -> RType c tv r2
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy  ((RType c tv r1 -> RType c tv r2)
-> (Symbol, RType c tv r1) -> (Symbol, RType c tv r2)
forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ) ((Symbol, RType c tv r1) -> (Symbol, RType c tv r2))
-> [(Symbol, RType c tv r1)] -> [(Symbol, RType c tv r2)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r1)]
e) ([Symbol] -> r1 -> r2
f [Symbol]
γ r1
r) Oblig
o (([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ RType c tv r1
t)
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ (RHole r1
r)         = r2 -> RType c tv r2
forall c tv r. r -> RType c tv r
RHole ([Symbol] -> r1 -> r2
f [Symbol]
γ r1
r)

emapRef :: ([Symbol] -> t -> s) ->  [Symbol] -> RTProp c tv t -> RTProp c tv s
emapRef :: forall t s c tv.
([Symbol] -> t -> s) -> [Symbol] -> RTProp c tv t -> RTProp c tv s
emapRef  [Symbol] -> t -> s
f [Symbol]
γ (RProp [(Symbol, RType c tv ())]
s (RHole t
r))  = [(Symbol, RType c tv ())]
-> RType c tv s -> Ref (RType c tv ()) (RType c tv s)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
s (RType c tv s -> Ref (RType c tv ()) (RType c tv s))
-> RType c tv s -> Ref (RType c tv ()) (RType c tv s)
forall a b. (a -> b) -> a -> b
$ s -> RType c tv s
forall c tv r. r -> RType c tv r
RHole ([Symbol] -> t -> s
f [Symbol]
γ t
r)
emapRef  [Symbol] -> t -> s
f [Symbol]
γ (RProp [(Symbol, RType c tv ())]
s RType c tv t
t)         = [(Symbol, RType c tv ())]
-> RType c tv s -> Ref (RType c tv ()) (RType c tv s)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
s (RType c tv s -> Ref (RType c tv ()) (RType c tv s))
-> RType c tv s -> Ref (RType c tv ()) (RType c tv s)
forall a b. (a -> b) -> a -> b
$ ([Symbol] -> t -> s) -> [Symbol] -> RType c tv t -> RType c tv s
forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> t -> s
f [Symbol]
γ RType c tv t
t

emapExprArg :: ([Symbol] -> Expr -> Expr) -> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg :: forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg [Symbol] -> Expr -> Expr
f = [Symbol] -> RType c tv r -> RType c tv r
forall {c} {tv} {r}. [Symbol] -> RType c tv r -> RType c tv r
go
  where
    go :: [Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
_ t :: RType c tv r
t@RVar{}          = RType c tv r
t
    go [Symbol]
_ t :: RType c tv r
t@RHole{}         = RType c tv r
t
    go [Symbol]
γ (RAllT RTVU c tv
α RType c tv r
t r
r)     = RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t) r
r
    go [Symbol]
γ (RAllP PVU c tv
π RType c tv r
t)       = PVU c tv -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t)
    go [Symbol]
γ (RFun Symbol
x RFInfo
i RType c tv r
t RType c tv r
t' r
r) = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun  Symbol
x RFInfo
i ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t) ([Symbol] -> RType c tv r -> RType c tv r
go (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
γ) RType c tv r
t') r
r
    go [Symbol]
γ (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)  = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ (RType c tv r -> RType c tv r) -> [RType c tv r] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) ([Symbol] -> RTProp c tv r -> RTProp c tv r
mo [Symbol]
γ (RTProp c tv r -> RTProp c tv r)
-> [RTProp c tv r] -> [RTProp c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r]
rs) r
r
    go [Symbol]
γ (RAllE Symbol
z RType c tv r
t RType c tv r
t')    = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t) ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t')
    go [Symbol]
γ (REx Symbol
z RType c tv r
t RType c tv r
t')      = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx   Symbol
z ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t) ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t')
    go [Symbol]
γ (RExprArg Located Expr
e)      = Located Expr -> RType c tv r
forall c tv r. Located Expr -> RType c tv r
RExprArg ([Symbol] -> Expr -> Expr
f [Symbol]
γ (Expr -> Expr) -> Located Expr -> Located Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Located Expr -> Located Expr
forall a. PPrint a => String -> a -> a
F.notracepp String
"RExprArg" Located Expr
e) -- <---- actual substitution
    go [Symbol]
γ (RAppTy RType c tv r
t RType c tv r
t' r
r)   = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t) ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t') r
r
    go [Symbol]
γ (RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t)    = [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy  ((RType c tv r -> RType c tv r)
-> (Symbol, RType c tv r) -> (Symbol, RType c tv r)
forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ) ((Symbol, RType c tv r) -> (Symbol, RType c tv r))
-> [(Symbol, RType c tv r)] -> [(Symbol, RType c tv r)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e) r
r Oblig
o ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t)

    mo :: [Symbol] -> RTProp c tv r -> RTProp c tv r
mo [Symbol]
_ t :: RTProp c tv r
t@(RProp [(Symbol, RType c tv ())]
_ RHole{}) = RTProp c tv r
t
    mo [Symbol]
γ (RProp [(Symbol, RType c tv ())]
s RType c tv r
t)         = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
s ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ RType c tv r
t)

foldRType :: (acc -> RType c tv r -> acc) -> acc -> RType c tv r -> acc
foldRType :: forall acc c tv r.
(acc -> RType c tv r -> acc) -> acc -> RType c tv r -> acc
foldRType acc -> RType c tv r -> acc
f = acc -> RType c tv r -> acc
go
  where
    step :: acc -> RType c tv r -> acc
step acc
a RType c tv r
t                = acc -> RType c tv r -> acc
go (acc -> RType c tv r -> acc
f acc
a RType c tv r
t) RType c tv r
t
    prep :: acc -> RTProp c tv r -> acc
prep acc
a (RProp [(Symbol, RType c tv ())]
_ RHole{}) = acc
a
    prep acc
a (RProp [(Symbol, RType c tv ())]
_ RType c tv r
t)      = acc -> RType c tv r -> acc
step acc
a RType c tv r
t
    go :: acc -> RType c tv r -> acc
go acc
a RVar{}             = acc
a
    go acc
a RHole{}            = acc
a
    go acc
a RExprArg{}         = acc
a
    go acc
a (RAllT RTVU c tv
_ RType c tv r
t r
_)      = acc -> RType c tv r -> acc
step acc
a RType c tv r
t
    go acc
a (RAllP PVU c tv
_ RType c tv r
t)        = acc -> RType c tv r -> acc
step acc
a RType c tv r
t
    go acc
a (RFun Symbol
_ RFInfo
_ RType c tv r
t RType c tv r
t' r
_)  = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (RAllE Symbol
_ RType c tv r
t RType c tv r
t')     = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (REx Symbol
_ RType c tv r
t RType c tv r
t')       = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (RAppTy RType c tv r
t RType c tv r
t' r
_)    = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (RApp c
_ [RType c tv r]
ts [RTProp c tv r]
rs r
_)   = (acc -> RTProp c tv r -> acc) -> acc -> [RTProp c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RTProp c tv r -> acc
prep ((acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r]
ts) [RTProp c tv r]
rs
    go acc
a (RRTy [(Symbol, RType c tv r)]
e r
_ Oblig
_ RType c tv r
t)     = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a (RType c tv r
t RType c tv r -> [RType c tv r] -> [RType c tv r]
forall a. a -> [a] -> [a]
: ((Symbol, RType c tv r) -> RType c tv r
forall a b. (a, b) -> b
snd ((Symbol, RType c tv r) -> RType c tv r)
-> [(Symbol, RType c tv r)] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e))

------------------------------------------------------------------------------------------------------
-- isBase' x t = traceShow ("isBase: " ++ showpp x) $ isBase t
-- same as GhcMisc isBaseType

-- isBase :: RType a -> Bool

-- set all types to basic types, haskell `tx -> t` is translated to Arrow tx t
-- isBase _ = True

isBase :: RType t t1 t2 -> Bool
isBase :: forall c tv r. RType c tv r -> Bool
isBase (RAllT RTVU t t1
_ RType t t1 t2
t t2
_)    = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t
isBase (RAllP PVU t t1
_ RType t t1 t2
t)      = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t
isBase (RVar t1
_ t2
_)       = Bool
True
isBase (RApp t
_ [RType t t1 t2]
ts [RTProp t t1 t2]
_ t2
_)  = (RType t t1 t2 -> Bool) -> [RType t t1 t2] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase [RType t t1 t2]
ts
isBase RFun{}           = Bool
False
isBase (RAppTy RType t t1 t2
t1 RType t t1 t2
t2 t2
_) = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t1 Bool -> Bool -> Bool
&& RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t2
isBase (RRTy [(Symbol, RType t t1 t2)]
_ t2
_ Oblig
_ RType t t1 t2
t)   = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t
isBase (RAllE Symbol
_ RType t t1 t2
_ RType t t1 t2
t)    = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t
isBase (REx Symbol
_ RType t t1 t2
_ RType t t1 t2
t)      = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t
isBase RType t t1 t2
_                = Bool
False

hasHoleTy :: RType t t1 t2 -> Bool
hasHoleTy :: forall c tv r. RType c tv r -> Bool
hasHoleTy (RVar t1
_ t2
_)        = Bool
False
hasHoleTy (RAllT RTVU t t1
_ RType t t1 t2
t t2
_)     = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t
hasHoleTy (RAllP PVU t t1
_ RType t t1 t2
t)       = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t
hasHoleTy (RFun Symbol
_ RFInfo
_ RType t t1 t2
t RType t t1 t2
t' t2
_) = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> Bool
|| RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t'
hasHoleTy (RApp t
_ [RType t t1 t2]
ts [RTProp t t1 t2]
_ t2
_)   = (RType t t1 t2 -> Bool) -> [RType t t1 t2] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy [RType t t1 t2]
ts
hasHoleTy (RAllE Symbol
_ RType t t1 t2
t RType t t1 t2
t')    = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> Bool
|| RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t'
hasHoleTy (REx Symbol
_ RType t t1 t2
t RType t t1 t2
t')      = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> Bool
|| RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t'
hasHoleTy (RExprArg Located Expr
_)      = Bool
False
hasHoleTy (RAppTy RType t t1 t2
t RType t t1 t2
t' t2
_)   = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> Bool
|| RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t'
hasHoleTy (RHole t2
_)         = Bool
True
hasHoleTy (RRTy [(Symbol, RType t t1 t2)]
xts t2
_ Oblig
_ RType t t1 t2
t)  = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> Bool
|| (RType t t1 t2 -> Bool) -> [RType t t1 t2] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
hasHoleTy ((Symbol, RType t t1 t2) -> RType t t1 t2
forall a b. (a, b) -> b
snd ((Symbol, RType t t1 t2) -> RType t t1 t2)
-> [(Symbol, RType t t1 t2)] -> [RType t t1 t2]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType t t1 t2)]
xts)

isFunTy :: RType t t1 t2 -> Bool
isFunTy :: forall c tv r. RType c tv r -> Bool
isFunTy (RAllE Symbol
_ RType t t1 t2
_ RType t t1 t2
t)    = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isFunTy RType t t1 t2
t
isFunTy (RAllT RTVU t t1
_ RType t t1 t2
t t2
_)    = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isFunTy RType t t1 t2
t
isFunTy (RAllP PVU t t1
_ RType t t1 t2
t)      = RType t t1 t2 -> Bool
forall c tv r. RType c tv r -> Bool
isFunTy RType t t1 t2
t
isFunTy RFun{}           = Bool
True
isFunTy RType t t1 t2
_                = Bool
False

mapReftM :: (Monad m) => (r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM :: forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f (RVar tv
α r1
r)        = (r2 -> RType c tv r2) -> m r2 -> m (RType c tv r2)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   (tv -> r2 -> RType c tv r2
forall c tv r. tv -> r -> RType c tv r
RVar  tv
α)  (r1 -> m r2
f r1
r)
mapReftM r1 -> m r2
f (RAllT RTVU c tv
α RType c tv r1
t r1
r)     = (RType c tv r2 -> r2 -> RType c tv r2)
-> m (RType c tv r2) -> m r2 -> m (RType c tv r2)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (RTVU c tv -> RType c tv r2 -> r2 -> RType c tv r2
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α)  ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t)         (r1 -> m r2
f r1
r)
mapReftM r1 -> m r2
f (RAllP PVU c tv
π RType c tv r1
t)       = (RType c tv r2 -> RType c tv r2)
-> m (RType c tv r2) -> m (RType c tv r2)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   (PVU c tv -> RType c tv r2 -> RType c tv r2
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π)  ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t)
mapReftM r1 -> m r2
f (RFun Symbol
x RFInfo
i RType c tv r1
t RType c tv r1
t' r1
r) = (RType c tv r2 -> RType c tv r2 -> r2 -> RType c tv r2)
-> m (RType c tv r2)
-> m (RType c tv r2)
-> m r2
-> m (RType c tv r2)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (Symbol
-> RFInfo -> RType c tv r2 -> RType c tv r2 -> r2 -> RType c tv r2
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i) ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t)         ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t')       (r1 -> m r2
f r1
r)
mapReftM r1 -> m r2
f (RApp c
c [RType c tv r1]
ts [RTProp c tv r1]
rs r1
r)  = ([RType c tv r2] -> [RTProp c tv r2] -> r2 -> RType c tv r2)
-> m [RType c tv r2]
-> m [RTProp c tv r2]
-> m r2
-> m (RType c tv r2)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (c -> [RType c tv r2] -> [RTProp c tv r2] -> r2 -> RType c tv r2
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c)  ((RType c tv r1 -> m (RType c tv r2))
-> [RType c tv r1] -> m [RType c tv r2]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f) [RType c tv r1]
ts) ((RTProp c tv r1 -> m (RTProp c tv r2))
-> [RTProp c tv r1] -> m [RTProp c tv r2]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((r1 -> m r2) -> RTProp c tv r1 -> m (RTProp c tv r2)
forall (m :: * -> *) t s c tv.
Monad m =>
(t -> m s) -> RTProp c tv t -> m (RTProp c tv s)
mapRefM r1 -> m r2
f) [RTProp c tv r1]
rs) (r1 -> m r2
f r1
r)
mapReftM r1 -> m r2
f (RAllE Symbol
z RType c tv r1
t RType c tv r1
t')    = (RType c tv r2 -> RType c tv r2 -> RType c tv r2)
-> m (RType c tv r2) -> m (RType c tv r2) -> m (RType c tv r2)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (Symbol -> RType c tv r2 -> RType c tv r2 -> RType c tv r2
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z)  ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t)         ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t')
mapReftM r1 -> m r2
f (REx Symbol
z RType c tv r1
t RType c tv r1
t')      = (RType c tv r2 -> RType c tv r2 -> RType c tv r2)
-> m (RType c tv r2) -> m (RType c tv r2) -> m (RType c tv r2)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (Symbol -> RType c tv r2 -> RType c tv r2 -> RType c tv r2
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
z)    ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t)         ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t')
mapReftM r1 -> m r2
_ (RExprArg Located Expr
e)      = RType c tv r2 -> m (RType c tv r2)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (RType c tv r2 -> m (RType c tv r2))
-> RType c tv r2 -> m (RType c tv r2)
forall a b. (a -> b) -> a -> b
$ Located Expr -> RType c tv r2
forall c tv r. Located Expr -> RType c tv r
RExprArg Located Expr
e
mapReftM r1 -> m r2
f (RAppTy RType c tv r1
t RType c tv r1
t' r1
r)   = (RType c tv r2 -> RType c tv r2 -> r2 -> RType c tv r2)
-> m (RType c tv r2)
-> m (RType c tv r2)
-> m r2
-> m (RType c tv r2)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 RType c tv r2 -> RType c tv r2 -> r2 -> RType c tv r2
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t) ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t') (r1 -> m r2
f r1
r)
mapReftM r1 -> m r2
f (RHole r1
r)         = (r2 -> RType c tv r2) -> m r2 -> m (RType c tv r2)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   r2 -> RType c tv r2
forall c tv r. r -> RType c tv r
RHole      (r1 -> m r2
f r1
r)
mapReftM r1 -> m r2
f (RRTy [(Symbol, RType c tv r1)]
xts r1
r Oblig
o RType c tv r1
t)  = ([(Symbol, RType c tv r2)]
 -> r2 -> Oblig -> RType c tv r2 -> RType c tv r2)
-> m [(Symbol, RType c tv r2)]
-> m r2
-> m Oblig
-> m (RType c tv r2)
-> m (RType c tv r2)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 [(Symbol, RType c tv r2)]
-> r2 -> Oblig -> RType c tv r2 -> RType c tv r2
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy (((Symbol, RType c tv r1) -> m (Symbol, RType c tv r2))
-> [(Symbol, RType c tv r1)] -> m [(Symbol, RType c tv r2)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((RType c tv r1 -> m (RType c tv r2))
-> (Symbol, RType c tv r1) -> m (Symbol, RType c tv r2)
forall (m :: * -> *) b c a.
Applicative m =>
(b -> m c) -> (a, b) -> m (a, c)
mapSndM ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f)) [(Symbol, RType c tv r1)]
xts) (r1 -> m r2
f r1
r) (Oblig -> m Oblig
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Oblig
o) ((r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM r1 -> m r2
f RType c tv r1
t)

mapRefM  :: (Monad m) => (t -> m s) -> RTProp c tv t -> m (RTProp c tv s)
mapRefM :: forall (m :: * -> *) t s c tv.
Monad m =>
(t -> m s) -> RTProp c tv t -> m (RTProp c tv s)
mapRefM  t -> m s
f (RProp [(Symbol, RType c tv ())]
s RType c tv t
t)        = (RType c tv s -> RTProp c tv s)
-> m (RType c tv s) -> m (RTProp c tv s)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap    ([(Symbol, RType c tv ())] -> RType c tv s -> RTProp c tv s
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
s)      ((t -> m s) -> RType c tv t -> m (RType c tv s)
forall (m :: * -> *) r1 r2 c tv.
Monad m =>
(r1 -> m r2) -> RType c tv r1 -> m (RType c tv r2)
mapReftM t -> m s
f RType c tv t
t)

mapPropM :: (Monad m) => (RTProp c tv r -> m (RTProp c tv r)) -> RType c tv r -> m (RType c tv r)
mapPropM :: forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
_ (RVar tv
α r
r)        = RType c tv r -> m (RType c tv r)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (RType c tv r -> m (RType c tv r))
-> RType c tv r -> m (RType c tv r)
forall a b. (a -> b) -> a -> b
$ tv -> r -> RType c tv r
forall c tv r. tv -> r -> RType c tv r
RVar  tv
α r
r
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RAllT RTVU c tv
α RType c tv r
t r
r)     = (RType c tv r -> r -> RType c tv r)
-> m (RType c tv r) -> m r -> m (RType c tv r)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α)   ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t)          (r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return r
r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RAllP PVU c tv
π RType c tv r
t)       = (RType c tv r -> RType c tv r)
-> m (RType c tv r) -> m (RType c tv r)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   (PVU c tv -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π)   ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RFun Symbol
x RFInfo
i RType c tv r
t RType c tv r
t' r
r) = (RType c tv r -> RType c tv r -> r -> RType c tv r)
-> m (RType c tv r) -> m (RType c tv r) -> m r -> m (RType c tv r)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i)  ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t)          ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t') (r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return r
r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)  = ([RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r)
-> m [RType c tv r] -> m [RTProp c tv r] -> m r -> m (RType c tv r)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c)   ((RType c tv r -> m (RType c tv r))
-> [RType c tv r] -> m [RType c tv r]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f) [RType c tv r]
ts)  ((RTProp c tv r -> m (RTProp c tv r))
-> [RTProp c tv r] -> m [RTProp c tv r]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM RTProp c tv r -> m (RTProp c tv r)
f [RTProp c tv r]
rs)     (r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return r
r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RAllE Symbol
z RType c tv r
t RType c tv r
t')    = (RType c tv r -> RType c tv r -> RType c tv r)
-> m (RType c tv r) -> m (RType c tv r) -> m (RType c tv r)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z)   ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t)          ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t')
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (REx Symbol
z RType c tv r
t RType c tv r
t')      = (RType c tv r -> RType c tv r -> RType c tv r)
-> m (RType c tv r) -> m (RType c tv r) -> m (RType c tv r)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
z)     ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t)          ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t')
mapPropM RTProp c tv r -> m (RTProp c tv r)
_ (RExprArg Located Expr
e)      = RType c tv r -> m (RType c tv r)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (RType c tv r -> m (RType c tv r))
-> RType c tv r -> m (RType c tv r)
forall a b. (a -> b) -> a -> b
$ Located Expr -> RType c tv r
forall c tv r. Located Expr -> RType c tv r
RExprArg Located Expr
e
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RAppTy RType c tv r
t RType c tv r
t' r
r)   = (RType c tv r -> RType c tv r -> r -> RType c tv r)
-> m (RType c tv r) -> m (RType c tv r) -> m r -> m (RType c tv r)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t) ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t') (r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return r
r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
_ (RHole r
r)         = RType c tv r -> m (RType c tv r)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (RType c tv r -> m (RType c tv r))
-> RType c tv r -> m (RType c tv r)
forall a b. (a -> b) -> a -> b
$ r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r
mapPropM RTProp c tv r -> m (RTProp c tv r)
f (RRTy [(Symbol, RType c tv r)]
xts r
r Oblig
o RType c tv r
t)  = ([(Symbol, RType c tv r)]
 -> r -> Oblig -> RType c tv r -> RType c tv r)
-> m [(Symbol, RType c tv r)]
-> m r
-> m Oblig
-> m (RType c tv r)
-> m (RType c tv r)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy (((Symbol, RType c tv r) -> m (Symbol, RType c tv r))
-> [(Symbol, RType c tv r)] -> m [(Symbol, RType c tv r)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((RType c tv r -> m (RType c tv r))
-> (Symbol, RType c tv r) -> m (Symbol, RType c tv r)
forall (m :: * -> *) b c a.
Applicative m =>
(b -> m c) -> (a, b) -> m (a, c)
mapSndM ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f)) [(Symbol, RType c tv r)]
xts) (r -> m r
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return r
r) (Oblig -> m Oblig
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Oblig
o) ((RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
forall (m :: * -> *) c tv r.
Monad m =>
(RTProp c tv r -> m (RTProp c tv r))
-> RType c tv r -> m (RType c tv r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
f RType c tv r
t)


--------------------------------------------------------------------------------
-- foldReft :: (F.Reftable r, TyConable c) => (r -> a -> a) -> a -> RType c tv r -> a
--------------------------------------------------------------------------------
-- foldReft f = efoldReft (\_ _ -> []) (\_ -> ()) (\_ _ -> f) (\_ γ -> γ) emptyF.SEnv

--------------------------------------------------------------------------------
foldReft :: (F.Reftable r, TyConable c) => BScope -> (F.SEnv (RType c tv r) -> r -> a -> a) -> a -> RType c tv r -> a
--------------------------------------------------------------------------------
foldReft :: forall r c tv a.
(Reftable r, TyConable c) =>
Bool
-> (SEnv (RType c tv r) -> r -> a -> a) -> a -> RType c tv r -> a
foldReft Bool
bsc SEnv (RType c tv r) -> r -> a -> a
f = (Symbol -> RType c tv r -> Bool)
-> Bool
-> (RType c tv r -> RType c tv r)
-> (SEnv (RType c tv r) -> Maybe (RType c tv r) -> r -> a -> a)
-> a
-> RType c tv r
-> a
forall r c tv b a.
(Reftable r, TyConable c) =>
(Symbol -> RType c tv r -> Bool)
-> Bool
-> (RType c tv r -> b)
-> (SEnv b -> Maybe (RType c tv r) -> r -> a -> a)
-> a
-> RType c tv r
-> a
foldReft'  (\Symbol
_ RType c tv r
_ -> Bool
False) Bool
bsc RType c tv r -> RType c tv r
forall a. a -> a
id (\SEnv (RType c tv r)
γ Maybe (RType c tv r)
_ -> SEnv (RType c tv r) -> r -> a -> a
f SEnv (RType c tv r)
γ)

--------------------------------------------------------------------------------
foldReft' :: (F.Reftable r, TyConable c)
          => (Symbol -> RType c tv r -> Bool)
          -> BScope
          -> (RType c tv r -> b)
          -> (F.SEnv b -> Maybe (RType c tv r) -> r -> a -> a)
          -> a -> RType c tv r -> a
--------------------------------------------------------------------------------
foldReft' :: forall r c tv b a.
(Reftable r, TyConable c) =>
(Symbol -> RType c tv r -> Bool)
-> Bool
-> (RType c tv r -> b)
-> (SEnv b -> Maybe (RType c tv r) -> r -> a -> a)
-> a
-> RType c tv r
-> a
foldReft' Symbol -> RType c tv r -> Bool
logicBind Bool
bsc RType c tv r -> b
g SEnv b -> Maybe (RType c tv r) -> r -> a -> a
f
  = (Symbol -> RType c tv r -> Bool)
-> Bool
-> (c -> [RType c tv r] -> [(Symbol, b)])
-> (RTVar tv (RType c tv ()) -> [(Symbol, b)])
-> (RType c tv r -> b)
-> (SEnv b -> Maybe (RType c tv r) -> r -> a -> a)
-> (PVar (RType c tv ()) -> SEnv b -> SEnv b)
-> SEnv b
-> a
-> RType c tv r
-> a
forall r c tv a b.
(Reftable r, TyConable c) =>
(Symbol -> RType c tv r -> Bool)
-> Bool
-> (c -> [RType c tv r] -> [(Symbol, a)])
-> (RTVar tv (RType c tv ()) -> [(Symbol, a)])
-> (RType c tv r -> a)
-> (SEnv a -> Maybe (RType c tv r) -> r -> b -> b)
-> (PVar (RType c tv ()) -> SEnv a -> SEnv a)
-> SEnv a
-> b
-> RType c tv r
-> b
efoldReft Symbol -> RType c tv r -> Bool
logicBind Bool
bsc
              (\c
_ [RType c tv r]
_ -> [])
              ([(Symbol, b)] -> RTVar tv (RType c tv ()) -> [(Symbol, b)]
forall a b. a -> b -> a
const [])
              RType c tv r -> b
g
              (\SEnv b
γ Maybe (RType c tv r)
t r
r a
z -> SEnv b -> Maybe (RType c tv r) -> r -> a -> a
f SEnv b
γ Maybe (RType c tv r)
t r
r a
z)
              (\PVar (RType c tv ())
_ SEnv b
γ -> SEnv b
γ)
              SEnv b
forall a. SEnv a
F.emptySEnv



-- efoldReft :: F.Reftable r =>(p -> [RType c tv r] -> [(Symbol, a)])-> (RType c tv r -> a)-> (SEnv a -> Maybe (RType c tv r) -> r -> c1 -> c1)-> SEnv a-> c1-> RType c tv r-> c1
efoldReft :: (F.Reftable r, TyConable c)
          => (Symbol -> RType c tv r -> Bool)
          -> BScope
          -> (c  -> [RType c tv r] -> [(Symbol, a)])
          -> (RTVar tv (RType c tv ()) -> [(Symbol, a)])
          -> (RType c tv r -> a)
          -> (F.SEnv a -> Maybe (RType c tv r) -> r -> b -> b)
          -> (PVar (RType c tv ()) -> F.SEnv a -> F.SEnv a)
          -> F.SEnv a
          -> b
          -> RType c tv r
          -> b
efoldReft :: forall r c tv a b.
(Reftable r, TyConable c) =>
(Symbol -> RType c tv r -> Bool)
-> Bool
-> (c -> [RType c tv r] -> [(Symbol, a)])
-> (RTVar tv (RType c tv ()) -> [(Symbol, a)])
-> (RType c tv r -> a)
-> (SEnv a -> Maybe (RType c tv r) -> r -> b -> b)
-> (PVar (RType c tv ()) -> SEnv a -> SEnv a)
-> SEnv a
-> b
-> RType c tv r
-> b
efoldReft Symbol -> RType c tv r -> Bool
logicBind Bool
bsc c -> [RType c tv r] -> [(Symbol, a)]
cb RTVar tv (RType c tv ()) -> [(Symbol, a)]
dty RType c tv r -> a
g SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f PVar (RType c tv ()) -> SEnv a -> SEnv a
fp = SEnv a -> b -> RType c tv r -> b
go
  where
    -- folding over RType
    go :: SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z me :: RType c tv r
me@(RVar tv
_ r
r)                = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r b
z
    go SEnv a
γ b
z me :: RType c tv r
me@(RAllT RTVar tv (RType c tv ())
a RType c tv r
t r
r)
       | RTVar tv (RType c tv ()) -> Bool
forall tv s. RTVar tv s -> Bool
tyVarIsVal RTVar tv (RType c tv ())
a                   = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go (SEnv a -> [(Symbol, a)] -> SEnv a
forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv SEnv a
γ (RTVar tv (RType c tv ()) -> [(Symbol, a)]
dty RTVar tv (RType c tv ())
a)) b
z RType c tv r
t)
       | Bool
otherwise                      = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t)
    go SEnv a
γ b
z (RAllP PVar (RType c tv ())
p RType c tv r
t)                  = SEnv a -> b -> RType c tv r -> b
go (PVar (RType c tv ()) -> SEnv a -> SEnv a
fp PVar (RType c tv ())
p SEnv a
γ) b
z RType c tv r
t
    go SEnv a
γ b
z me :: RType c tv r
me@(RFun Symbol
_ RFInfo{permitTC :: RFInfo -> Maybe Bool
permitTC = Maybe Bool
permitTC} (RApp c
c [RType c tv r]
ts [RTProp c tv r]
_ r
_) RType c tv r
t' r
r)
       | (if Maybe Bool
permitTC Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True then c -> Bool
forall c. TyConable c => c -> Bool
isEmbeddedDict else c -> Bool
forall c. TyConable c => c -> Bool
isClass)
         c
c  = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go (SEnv a -> [(Symbol, a)] -> SEnv a
forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv SEnv a
γ (c -> [RType c tv r] -> [(Symbol, a)]
cb c
c [RType c tv r]
ts)) (SEnv a -> b -> [RType c tv r] -> b
go' SEnv a
γ b
z [RType c tv r]
ts) RType c tv r
t')
    go SEnv a
γ b
z me :: RType c tv r
me@(RFun Symbol
x RFInfo
_ RType c tv r
t RType c tv r
t' r
r)
       | Symbol -> RType c tv r -> Bool
logicBind Symbol
x RType c tv r
t                  = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ' (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t) RType c tv r
t')
       | Bool
otherwise                      = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ  (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t) RType c tv r
t')
       where
         γ' :: SEnv a
γ'                             = Symbol -> a -> SEnv a -> SEnv a
forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv Symbol
x (RType c tv r -> a
g RType c tv r
t) SEnv a
γ
    go SEnv a
γ b
z me :: RType c tv r
me@(RApp c
_ [RType c tv r]
ts [RTProp c tv r]
rs r
r)          = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> [RTProp c tv r] -> b
ho' SEnv a
γ (SEnv a -> b -> [RType c tv r] -> b
go' SEnv a
γ' b
z [RType c tv r]
ts) [RTProp c tv r]
rs)
       where γ' :: SEnv a
γ' = if Bool
bsc then Symbol -> a -> SEnv a -> SEnv a
forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv (RType c tv r -> Symbol
forall r c tv. Reftable r => RType c tv r -> Symbol
rTypeValueVar RType c tv r
me) (RType c tv r -> a
g RType c tv r
me) SEnv a
γ else SEnv a
γ

    go SEnv a
γ b
z (RAllE Symbol
x RType c tv r
t RType c tv r
t')               = SEnv a -> b -> RType c tv r -> b
go (Symbol -> a -> SEnv a -> SEnv a
forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv Symbol
x (RType c tv r -> a
g RType c tv r
t) SEnv a
γ) (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t) RType c tv r
t'
    go SEnv a
γ b
z (REx Symbol
x RType c tv r
t RType c tv r
t')                 = SEnv a -> b -> RType c tv r -> b
go (Symbol -> a -> SEnv a -> SEnv a
forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv Symbol
x (RType c tv r -> a
g RType c tv r
t) SEnv a
γ) (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t) RType c tv r
t'
    go SEnv a
γ b
z me :: RType c tv r
me@(RRTy [] r
r Oblig
_ RType c tv r
t)           = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t)
    go SEnv a
γ b
z me :: RType c tv r
me@(RRTy [(Symbol, RType c tv r)]
xts r
r Oblig
_ RType c tv r
t)          = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z ([(Symbol, RType c tv r)] -> RType c tv r
forall {r} {c} {tv}.
Monoid r =>
[(Symbol, RType c tv r)] -> RType c tv r
envtoType [(Symbol, RType c tv r)]
xts)) RType c tv r
t)
    go SEnv a
γ b
z me :: RType c tv r
me@(RAppTy RType c tv r
t RType c tv r
t' r
r)           = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ (SEnv a -> b -> RType c tv r -> b
go SEnv a
γ b
z RType c tv r
t) RType c tv r
t')
    go SEnv a
_ b
z (RExprArg Located Expr
_)                 = b
z
    go SEnv a
γ b
z me :: RType c tv r
me@(RHole r
r)                 = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (RType c tv r -> Maybe (RType c tv r)
forall a. a -> Maybe a
Just RType c tv r
me) r
r b
z

    -- folding over Ref
    ho :: SEnv a -> b -> RTProp c tv r -> b
ho  SEnv a
γ b
z (RProp [(Symbol, RType c tv ())]
ss (RHole r
r))       = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f (SEnv a -> [(Symbol, a)] -> SEnv a
forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv SEnv a
γ ((RType c tv () -> a) -> (Symbol, RType c tv ()) -> (Symbol, a)
forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (RType c tv r -> a
g (RType c tv r -> a)
-> (RType c tv () -> RType c tv r) -> RType c tv () -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RType c tv () -> RType c tv r
forall r c tv. Reftable r => RType c tv () -> RType c tv r
ofRSort) ((Symbol, RType c tv ()) -> (Symbol, a))
-> [(Symbol, RType c tv ())] -> [(Symbol, a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv ())]
ss)) Maybe (RType c tv r)
forall a. Maybe a
Nothing r
r b
z
    ho  SEnv a
γ b
z (RProp [(Symbol, RType c tv ())]
ss RType c tv r
t)               = SEnv a -> b -> RType c tv r -> b
go (SEnv a -> [(Symbol, a)] -> SEnv a
forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv SEnv a
γ ((RType c tv () -> a) -> (Symbol, RType c tv ()) -> (Symbol, a)
forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (RType c tv r -> a
g (RType c tv r -> a)
-> (RType c tv () -> RType c tv r) -> RType c tv () -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RType c tv () -> RType c tv r
forall r c tv. Reftable r => RType c tv () -> RType c tv r
ofRSort) ((Symbol, RType c tv ()) -> (Symbol, a))
-> [(Symbol, RType c tv ())] -> [(Symbol, a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv ())]
ss)) b
z RType c tv r
t

    -- folding over [RType]
    go' :: SEnv a -> b -> [RType c tv r] -> b
go' SEnv a
γ b
z [RType c tv r]
ts                 = (RType c tv r -> b -> b) -> b -> [RType c tv r] -> b
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((b -> RType c tv r -> b) -> RType c tv r -> b -> b
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((b -> RType c tv r -> b) -> RType c tv r -> b -> b)
-> (b -> RType c tv r -> b) -> RType c tv r -> b -> b
forall a b. (a -> b) -> a -> b
$ SEnv a -> b -> RType c tv r -> b
go SEnv a
γ) b
z [RType c tv r]
ts

    -- folding over [Ref]
    ho' :: SEnv a -> b -> [RTProp c tv r] -> b
ho' SEnv a
γ b
z [RTProp c tv r]
rs                 = (RTProp c tv r -> b -> b) -> b -> [RTProp c tv r] -> b
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((b -> RTProp c tv r -> b) -> RTProp c tv r -> b -> b
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((b -> RTProp c tv r -> b) -> RTProp c tv r -> b -> b)
-> (b -> RTProp c tv r -> b) -> RTProp c tv r -> b -> b
forall a b. (a -> b) -> a -> b
$ SEnv a -> b -> RTProp c tv r -> b
ho SEnv a
γ) b
z [RTProp c tv r]
rs

    envtoType :: [(Symbol, RType c tv r)] -> RType c tv r
envtoType [(Symbol, RType c tv r)]
xts = ((Symbol, RType c tv r) -> RType c tv r -> RType c tv r)
-> RType c tv r -> [(Symbol, RType c tv r)] -> RType c tv r
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(Symbol
x,RType c tv r
t1) RType c tv r
t2 -> Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall r c tv.
Monoid r =>
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rFun Symbol
x RType c tv r
t1 RType c tv r
t2) ((Symbol, RType c tv r) -> RType c tv r
forall a b. (a, b) -> b
snd ((Symbol, RType c tv r) -> RType c tv r)
-> (Symbol, RType c tv r) -> RType c tv r
forall a b. (a -> b) -> a -> b
$ [(Symbol, RType c tv r)] -> (Symbol, RType c tv r)
forall a. (?callStack::CallStack) => [a] -> a
last [(Symbol, RType c tv r)]
xts) ([(Symbol, RType c tv r)] -> [(Symbol, RType c tv r)]
forall a. (?callStack::CallStack) => [a] -> [a]
init [(Symbol, RType c tv r)]
xts)

mapRFInfo :: (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo :: forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f (RAllT RTVU c tv
α RType c tv r
t r
r)     = RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t) r
r
mapRFInfo RFInfo -> RFInfo
f (RAllP PVU c tv
π RType c tv r
t)       = PVU c tv -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t)
mapRFInfo RFInfo -> RFInfo
f (RFun Symbol
x RFInfo
i RType c tv r
t RType c tv r
t' r
r) = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x (RFInfo -> RFInfo
f RFInfo
i) ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t) ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t') r
r
mapRFInfo RFInfo -> RFInfo
f (RAppTy RType c tv r
t RType c tv r
t' r
r)   = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t) ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t') r
r
mapRFInfo RFInfo -> RFInfo
f (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)  = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f (RType c tv r -> RType c tv r) -> [RType c tv r] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) ((RFInfo -> RFInfo) -> RTProp c tv r -> RTProp c tv r
forall τ c tv r.
(RFInfo -> RFInfo) -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapRFInfoRef RFInfo -> RFInfo
f (RTProp c tv r -> RTProp c tv r)
-> [RTProp c tv r] -> [RTProp c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r]
rs) r
r
mapRFInfo RFInfo -> RFInfo
f (REx Symbol
b RType c tv r
t1 RType c tv r
t2)     = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
b  ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t1) ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t2)
mapRFInfo RFInfo -> RFInfo
f (RAllE Symbol
b RType c tv r
t1 RType c tv r
t2)   = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
b ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t1) ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t2)
mapRFInfo RFInfo -> RFInfo
f (RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t)    = [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy ((RType c tv r -> RType c tv r)
-> (Symbol, RType c tv r) -> (Symbol, RType c tv r)
forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f) ((Symbol, RType c tv r) -> (Symbol, RType c tv r))
-> [(Symbol, RType c tv r)] -> [(Symbol, RType c tv r)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e) r
r Oblig
o ((RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t)
mapRFInfo RFInfo -> RFInfo
_ RType c tv r
t'                = RType c tv r
t'

mapRFInfoRef :: (RFInfo -> RFInfo)
          -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapRFInfoRef :: forall τ c tv r.
(RFInfo -> RFInfo) -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapRFInfoRef RFInfo -> RFInfo
_ (RProp [(Symbol, τ)]
s (RHole r
r)) = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s (RType c tv r -> Ref τ (RType c tv r))
-> RType c tv r -> Ref τ (RType c tv r)
forall a b. (a -> b) -> a -> b
$ r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r
mapRFInfoRef RFInfo -> RFInfo
f (RProp [(Symbol, τ)]
s RType c tv r
t)    = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp  [(Symbol, τ)]
s (RType c tv r -> Ref τ (RType c tv r))
-> RType c tv r -> Ref τ (RType c tv r)
forall a b. (a -> b) -> a -> b
$ (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t

mapBot :: (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot :: forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f (RAllT RTVU c tv
α RType c tv r
t r
r)     = RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t) r
r
mapBot RType c tv r -> RType c tv r
f (RAllP PVU c tv
π RType c tv r
t)       = PVU c tv -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t)
mapBot RType c tv r -> RType c tv r
f (RFun Symbol
x RFInfo
i RType c tv r
t RType c tv r
t' r
r) = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t) ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t') r
r
mapBot RType c tv r -> RType c tv r
f (RAppTy RType c tv r
t RType c tv r
t' r
r)   = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t) ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t') r
r
mapBot RType c tv r -> RType c tv r
f (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)  = RType c tv r -> RType c tv r
f (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall a b. (a -> b) -> a -> b
$ c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f (RType c tv r -> RType c tv r) -> [RType c tv r] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) ((RType c tv r -> RType c tv r) -> RTProp c tv r -> RTProp c tv r
forall c tv r τ.
(RType c tv r -> RType c tv r)
-> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBotRef RType c tv r -> RType c tv r
f (RTProp c tv r -> RTProp c tv r)
-> [RTProp c tv r] -> [RTProp c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r]
rs) r
r
mapBot RType c tv r -> RType c tv r
f (REx Symbol
b RType c tv r
t1 RType c tv r
t2)     = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
b  ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t1) ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t2)
mapBot RType c tv r -> RType c tv r
f (RAllE Symbol
b RType c tv r
t1 RType c tv r
t2)   = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
b  ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t1) ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t2)
mapBot RType c tv r -> RType c tv r
f (RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t)    = [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy ((RType c tv r -> RType c tv r)
-> (Symbol, RType c tv r) -> (Symbol, RType c tv r)
forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f) ((Symbol, RType c tv r) -> (Symbol, RType c tv r))
-> [(Symbol, RType c tv r)] -> [(Symbol, RType c tv r)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e) r
r Oblig
o ((RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t)
mapBot RType c tv r -> RType c tv r
f RType c tv r
t'                = RType c tv r -> RType c tv r
f RType c tv r
t'

mapBotRef :: (RType c tv r -> RType c tv r)
          -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBotRef :: forall c tv r τ.
(RType c tv r -> RType c tv r)
-> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBotRef RType c tv r -> RType c tv r
_ (RProp [(Symbol, τ)]
s (RHole r
r)) = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s (RType c tv r -> Ref τ (RType c tv r))
-> RType c tv r -> Ref τ (RType c tv r)
forall a b. (a -> b) -> a -> b
$ r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r
mapBotRef RType c tv r -> RType c tv r
f (RProp [(Symbol, τ)]
s RType c tv r
t)         = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s (RType c tv r -> Ref τ (RType c tv r))
-> RType c tv r -> Ref τ (RType c tv r)
forall a b. (a -> b) -> a -> b
$ (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall c tv r.
(RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
mapBot RType c tv r -> RType c tv r
f RType c tv r
t

mapBind :: (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind :: forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f (RAllT RTVU c tv
α RType c tv r
t r
r)      = RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t) r
r
mapBind Symbol -> Symbol
f (RAllP PVU c tv
π RType c tv r
t)        = PVU c tv -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t)
mapBind Symbol -> Symbol
f (RFun Symbol
b RFInfo
i RType c tv r
t1 RType c tv r
t2 r
r) = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun (Symbol -> Symbol
f Symbol
b) RFInfo
i ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t1) ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t2) r
r
mapBind Symbol -> Symbol
f (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)   = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f (RType c tv r -> RType c tv r) -> [RType c tv r] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) ((Symbol -> Symbol) -> RTProp c tv r -> RTProp c tv r
forall τ c tv r.
(Symbol -> Symbol) -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBindRef Symbol -> Symbol
f (RTProp c tv r -> RTProp c tv r)
-> [RTProp c tv r] -> [RTProp c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r]
rs) r
r
mapBind Symbol -> Symbol
f (RAllE Symbol
b RType c tv r
t1 RType c tv r
t2)    = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE  (Symbol -> Symbol
f Symbol
b) ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t1) ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t2)
mapBind Symbol -> Symbol
f (REx Symbol
b RType c tv r
t1 RType c tv r
t2)      = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx    (Symbol -> Symbol
f Symbol
b) ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t1) ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t2)
mapBind Symbol -> Symbol
_ (RVar tv
α r
r)         = tv -> r -> RType c tv r
forall c tv r. tv -> r -> RType c tv r
RVar tv
α r
r
mapBind Symbol -> Symbol
_ (RHole r
r)          = r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r
mapBind Symbol -> Symbol
f (RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t)     = [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t)
mapBind Symbol -> Symbol
_ (RExprArg Located Expr
e)       = Located Expr -> RType c tv r
forall c tv r. Located Expr -> RType c tv r
RExprArg Located Expr
e
mapBind Symbol -> Symbol
f (RAppTy RType c tv r
t RType c tv r
t' r
r)    = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t) ((Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t') r
r

mapBindRef :: (Symbol -> Symbol)
           -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBindRef :: forall τ c tv r.
(Symbol -> Symbol) -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBindRef Symbol -> Symbol
f (RProp [(Symbol, τ)]
s (RHole r
r)) = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp ((Symbol -> Symbol) -> (Symbol, τ) -> (Symbol, τ)
forall a c b. (a -> c) -> (a, b) -> (c, b)
mapFst Symbol -> Symbol
f ((Symbol, τ) -> (Symbol, τ)) -> [(Symbol, τ)] -> [(Symbol, τ)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, τ)]
s) (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r)
mapBindRef Symbol -> Symbol
f (RProp [(Symbol, τ)]
s RType c tv r
t)         = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp ((Symbol -> Symbol) -> (Symbol, τ) -> (Symbol, τ)
forall a c b. (a -> c) -> (a, b) -> (c, b)
mapFst Symbol -> Symbol
f ((Symbol, τ) -> (Symbol, τ)) -> [(Symbol, τ)] -> [(Symbol, τ)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, τ)]
s) (RType c tv r -> Ref τ (RType c tv r))
-> RType c tv r -> Ref τ (RType c tv r)
forall a b. (a -> b) -> a -> b
$ (Symbol -> Symbol) -> RType c tv r -> RType c tv r
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t


--------------------------------------------------
ofRSort ::  F.Reftable r => RType c tv () -> RType c tv r
ofRSort :: forall r c tv. Reftable r => RType c tv () -> RType c tv r
ofRSort = (() -> r) -> RType c tv () -> RType c tv r
forall a b. (a -> b) -> RType c tv a -> RType c tv b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap () -> r
forall a. Monoid a => a
mempty

toRSort :: RType c tv r -> RType c tv ()
toRSort :: forall c tv r. RType c tv r -> RType c tv ()
toRSort = RType c tv () -> RType c tv ()
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations (RType c tv () -> RType c tv ())
-> (RType c tv r -> RType c tv ()) -> RType c tv r -> RType c tv ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Symbol -> Symbol) -> RType c tv () -> RType c tv ()
forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind (Symbol -> Symbol -> Symbol
forall a b. a -> b -> a
const Symbol
F.dummySymbol) (RType c tv () -> RType c tv ())
-> (RType c tv r -> RType c tv ()) -> RType c tv r -> RType c tv ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RType c tv r -> RType c tv ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void

stripAnnotations :: RType c tv r -> RType c tv r
stripAnnotations :: forall c tv r. RType c tv r -> RType c tv r
stripAnnotations (RAllT RTVU c tv
α RType c tv r
t r
r)     = RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t) r
r
stripAnnotations (RAllP PVU c tv
_ RType c tv r
t)       = RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t
stripAnnotations (RAllE Symbol
_ RType c tv r
_ RType c tv r
t)     = RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t
stripAnnotations (REx Symbol
_ RType c tv r
_ RType c tv r
t)       = RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t
stripAnnotations (RFun Symbol
x RFInfo
i RType c tv r
t RType c tv r
t' r
r) = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t') r
r
stripAnnotations (RAppTy RType c tv r
t RType c tv r
t' r
r)   = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t') r
r
stripAnnotations (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)  = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations (RType c tv r -> RType c tv r) -> [RType c tv r] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) (RTProp c tv r -> RTProp c tv r
forall τ c tv r. Ref τ (RType c tv r) -> Ref τ (RType c tv r)
stripAnnotationsRef (RTProp c tv r -> RTProp c tv r)
-> [RTProp c tv r] -> [RTProp c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r]
rs) r
r
stripAnnotations (RRTy [(Symbol, RType c tv r)]
_ r
_ Oblig
_ RType c tv r
t)    = RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t
stripAnnotations RType c tv r
t                 = RType c tv r
t

stripAnnotationsRef :: Ref τ (RType c tv r) -> Ref τ (RType c tv r)
stripAnnotationsRef :: forall τ c tv r. Ref τ (RType c tv r) -> Ref τ (RType c tv r)
stripAnnotationsRef (RProp [(Symbol, τ)]
s (RHole r
r)) = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r)
stripAnnotationsRef (RProp [(Symbol, τ)]
s RType c tv r
t)         = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s (RType c tv r -> Ref τ (RType c tv r))
-> RType c tv r -> Ref τ (RType c tv r)
forall a b. (a -> b) -> a -> b
$ RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t

insertSEnv :: F.Symbol -> a -> F.SEnv a -> F.SEnv a
insertSEnv :: forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv = Symbol -> a -> SEnv a -> SEnv a
forall a. Symbol -> a -> SEnv a -> SEnv a
F.insertSEnv

insertsSEnv :: F.SEnv a -> [(Symbol, a)] -> F.SEnv a
insertsSEnv :: forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv  = ((Symbol, a) -> SEnv a -> SEnv a)
-> SEnv a -> [(Symbol, a)] -> SEnv a
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(Symbol
x, a
t) SEnv a
γ -> Symbol -> a -> SEnv a -> SEnv a
forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv Symbol
x a
t SEnv a
γ)

rTypeValueVar :: (F.Reftable r) => RType c tv r -> Symbol
rTypeValueVar :: forall r c tv. Reftable r => RType c tv r -> Symbol
rTypeValueVar RType c tv r
t = Symbol
vv where F.Reft (Symbol
vv,Expr
_) =  RType c tv r -> Reft
forall r c tv. Reftable r => RType c tv r -> Reft
rTypeReft RType c tv r
t

rTypeReft :: (F.Reftable r) => RType c tv r -> F.Reft
rTypeReft :: forall r c tv. Reftable r => RType c tv r -> Reft
rTypeReft = Reft -> (r -> Reft) -> Maybe r -> Reft
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Reft
F.trueReft r -> Reft
forall r. Reftable r => r -> Reft
F.toReft (Maybe r -> Reft)
-> (RType c tv r -> Maybe r) -> RType c tv r -> Reft
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RType c tv r -> Maybe r
forall c tv r. RType c tv r -> Maybe r
stripRTypeBase

-- stripRTypeBase ::  RType a -> Maybe a
stripRTypeBase :: RType c tv r -> Maybe r
stripRTypeBase :: forall c tv r. RType c tv r -> Maybe r
stripRTypeBase (RApp c
_ [RType c tv r]
_ [RTProp c tv r]
_ r
x)   = r -> Maybe r
forall a. a -> Maybe a
Just r
x
stripRTypeBase (RVar tv
_ r
x)       = r -> Maybe r
forall a. a -> Maybe a
Just r
x
stripRTypeBase (RFun Symbol
_ RFInfo
_ RType c tv r
_ RType c tv r
_ r
x) = r -> Maybe r
forall a. a -> Maybe a
Just r
x
stripRTypeBase (RAppTy RType c tv r
_ RType c tv r
_ r
x)   = r -> Maybe r
forall a. a -> Maybe a
Just r
x
stripRTypeBase (RAllT RTVU c tv
_ RType c tv r
_ r
x)    = r -> Maybe r
forall a. a -> Maybe a
Just r
x
stripRTypeBase RType c tv r
_                = Maybe r
forall a. Maybe a
Nothing

topRTypeBase :: (F.Reftable r) => RType c tv r -> RType c tv r
topRTypeBase :: forall r c tv. Reftable r => RType c tv r -> RType c tv r
topRTypeBase = (r -> r) -> RType c tv r -> RType c tv r
forall r c tv. (r -> r) -> RType c tv r -> RType c tv r
mapRBase r -> r
forall r. Reftable r => r -> r
F.top

mapRBase :: (r -> r) -> RType c tv r -> RType c tv r
mapRBase :: forall r c tv. (r -> r) -> RType c tv r -> RType c tv r
mapRBase r -> r
f (RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs r
r)   = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c [RType c tv r]
ts [RTProp c tv r]
rs (r -> RType c tv r) -> r -> RType c tv r
forall a b. (a -> b) -> a -> b
$ r -> r
f r
r
mapRBase r -> r
f (RVar tv
a r
r)         = tv -> r -> RType c tv r
forall c tv r. tv -> r -> RType c tv r
RVar tv
a (r -> RType c tv r) -> r -> RType c tv r
forall a b. (a -> b) -> a -> b
$ r -> r
f r
r
mapRBase r -> r
f (RFun Symbol
x RFInfo
i RType c tv r
t1 RType c tv r
t2 r
r) = Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i RType c tv r
t1 RType c tv r
t2 (r -> RType c tv r) -> r -> RType c tv r
forall a b. (a -> b) -> a -> b
$ r -> r
f r
r
mapRBase r -> r
f (RAppTy RType c tv r
t1 RType c tv r
t2 r
r)   = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy RType c tv r
t1 RType c tv r
t2 (r -> RType c tv r) -> r -> RType c tv r
forall a b. (a -> b) -> a -> b
$ r -> r
f r
r
mapRBase r -> r
_ RType c tv r
t                  = RType c tv r
t

-----------------------------------------------------------------------------
-- | F.PPrint -----------------------------------------------------------------
-----------------------------------------------------------------------------

instance F.PPrint (PVar a) where
  pprintTidy :: Tidy -> PVar a -> Doc
pprintTidy Tidy
_ = PVar a -> Doc
forall a. PVar a -> Doc
pprPvar

pprPvar :: PVar a -> Doc
pprPvar :: forall a. PVar a -> Doc
pprPvar (PV Symbol
s PVKind a
_ Symbol
_ [(a, Symbol, Expr)]
xts) = Symbol -> Doc
forall a. PPrint a => a -> Doc
F.pprint Symbol
s Doc -> Doc -> Doc
<+> [Doc] -> Doc
hsep (Expr -> Doc
forall a. PPrint a => a -> Doc
F.pprint (Expr -> Doc) -> [Expr] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(a, Symbol, Expr)] -> [Expr]
forall {a}. [(a, Symbol, Expr)] -> [Expr]
dargs [(a, Symbol, Expr)]
xts)
  where
    dargs :: [(a, Symbol, Expr)] -> [Expr]
dargs              = ((a, Symbol, Expr) -> Expr) -> [(a, Symbol, Expr)] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (a, Symbol, Expr) -> Expr
forall a b c. (a, b, c) -> c
thd3 ([(a, Symbol, Expr)] -> [Expr])
-> ([(a, Symbol, Expr)] -> [(a, Symbol, Expr)])
-> [(a, Symbol, Expr)]
-> [Expr]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, Symbol, Expr) -> Bool)
-> [(a, Symbol, Expr)] -> [(a, Symbol, Expr)]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (\(a
_, Symbol
x, Expr
y) -> Symbol -> Expr
F.EVar Symbol
x Expr -> Expr -> Bool
forall a. Eq a => a -> a -> Bool
/= Expr
y)


instance F.PPrint Predicate where
  pprintTidy :: Tidy -> Predicate -> Doc
pprintTidy Tidy
_ (Pr [])  = String -> Doc
text String
"True"
  pprintTidy Tidy
k (Pr [UsedPVar]
pvs) = [Doc] -> Doc
hsep ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ Doc -> [Doc] -> [Doc]
punctuate (String -> Doc
text String
"&") (Tidy -> UsedPVar -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (UsedPVar -> Doc) -> [UsedPVar] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UsedPVar]
pvs)


-- | The type used during constraint generation, used
--   also to define contexts for errors, hence in this
--   file, and NOT in elsewhere. **DO NOT ATTEMPT TO MOVE**
--   Am splitting into
--   + global : many bindings, shared across all constraints
--   + local  : few bindings, relevant to particular constraints

type REnv = AREnv SpecType

data AREnv t = REnv
  { forall t. AREnv t -> HashMap Symbol t
reGlobal :: M.HashMap Symbol t -- ^ the "global" names for module
  , forall t. AREnv t -> HashMap Symbol t
reLocal  :: M.HashMap Symbol t -- ^ the "local" names for sub-exprs
  }

instance Functor AREnv where
  fmap :: forall a b. (a -> b) -> AREnv a -> AREnv b
fmap a -> b
f (REnv HashMap Symbol a
g HashMap Symbol a
l) = HashMap Symbol b -> HashMap Symbol b -> AREnv b
forall t. HashMap Symbol t -> HashMap Symbol t -> AREnv t
REnv ((a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall a b. (a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f HashMap Symbol a
g) ((a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall a b. (a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f HashMap Symbol a
l)

instance (F.PPrint t) => F.PPrint (AREnv t) where
  pprintTidy :: Tidy -> AREnv t -> Doc
pprintTidy Tidy
k AREnv t
re =
    Doc
"RENV LOCAL"
    Doc -> Doc -> Doc
$+$
    Doc
""
    Doc -> Doc -> Doc
$+$
    Tidy -> HashMap Symbol t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (AREnv t -> HashMap Symbol t
forall t. AREnv t -> HashMap Symbol t
reLocal AREnv t
re)
    Doc -> Doc -> Doc
$+$
    Doc
""
    Doc -> Doc -> Doc
$+$
    Doc
"RENV GLOBAL"
    Doc -> Doc -> Doc
$+$
    Doc
""
    Doc -> Doc -> Doc
$+$
    Tidy -> HashMap Symbol t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (AREnv t -> HashMap Symbol t
forall t. AREnv t -> HashMap Symbol t
reGlobal AREnv t
re)

instance Semigroup REnv where
  REnv HashMap Symbol SpecType
g1 HashMap Symbol SpecType
l1 <> :: REnv -> REnv -> REnv
<> REnv HashMap Symbol SpecType
g2 HashMap Symbol SpecType
l2 = HashMap Symbol SpecType -> HashMap Symbol SpecType -> REnv
forall t. HashMap Symbol t -> HashMap Symbol t -> AREnv t
REnv (HashMap Symbol SpecType
g1 HashMap Symbol SpecType
-> HashMap Symbol SpecType -> HashMap Symbol SpecType
forall a. Semigroup a => a -> a -> a
<> HashMap Symbol SpecType
g2) (HashMap Symbol SpecType
l1 HashMap Symbol SpecType
-> HashMap Symbol SpecType -> HashMap Symbol SpecType
forall a. Semigroup a => a -> a -> a
<> HashMap Symbol SpecType
l2)

instance Monoid REnv where
  mempty :: REnv
mempty = HashMap Symbol SpecType -> HashMap Symbol SpecType -> REnv
forall t. HashMap Symbol t -> HashMap Symbol t -> AREnv t
REnv HashMap Symbol SpecType
forall a. Monoid a => a
mempty HashMap Symbol SpecType
forall a. Monoid a => a
mempty

instance NFData REnv where
  rnf :: REnv -> ()
rnf REnv{} = ()

--------------------------------------------------------------------------------
-- | Diagnostic info -----------------------------------------------------------
--------------------------------------------------------------------------------

data Warning = Warning {
    Warning -> SrcSpan
warnSpan :: SrcSpan
  , Warning -> Doc
warnDoc  :: Doc
  } deriving (Warning -> Warning -> Bool
(Warning -> Warning -> Bool)
-> (Warning -> Warning -> Bool) -> Eq Warning
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Warning -> Warning -> Bool
== :: Warning -> Warning -> Bool
$c/= :: Warning -> Warning -> Bool
/= :: Warning -> Warning -> Bool
Eq, Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> String
(Int -> Warning -> ShowS)
-> (Warning -> String) -> ([Warning] -> ShowS) -> Show Warning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Warning -> ShowS
showsPrec :: Int -> Warning -> ShowS
$cshow :: Warning -> String
show :: Warning -> String
$cshowList :: [Warning] -> ShowS
showList :: [Warning] -> ShowS
Show)

mkWarning :: SrcSpan -> Doc -> Warning
mkWarning :: SrcSpan -> Doc -> Warning
mkWarning = SrcSpan -> Doc -> Warning
Warning

data Diagnostics = Diagnostics {
    Diagnostics -> [Warning]
dWarnings :: [Warning]
  , Diagnostics -> [Error]
dErrors   :: [Error]
  } deriving Diagnostics -> Diagnostics -> Bool
(Diagnostics -> Diagnostics -> Bool)
-> (Diagnostics -> Diagnostics -> Bool) -> Eq Diagnostics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Diagnostics -> Diagnostics -> Bool
== :: Diagnostics -> Diagnostics -> Bool
$c/= :: Diagnostics -> Diagnostics -> Bool
/= :: Diagnostics -> Diagnostics -> Bool
Eq

instance Semigroup Diagnostics where
  (Diagnostics [Warning]
w1 [Error]
e1) <> :: Diagnostics -> Diagnostics -> Diagnostics
<> (Diagnostics [Warning]
w2 [Error]
e2) = [Warning] -> [Error] -> Diagnostics
Diagnostics ([Warning]
w1 [Warning] -> [Warning] -> [Warning]
forall a. Semigroup a => a -> a -> a
<> [Warning]
w2) ([Error]
e1 [Error] -> [Error] -> [Error]
forall a. Semigroup a => a -> a -> a
<> [Error]
e2)

instance Monoid Diagnostics where
  mempty :: Diagnostics
mempty  = Diagnostics
emptyDiagnostics
  mappend :: Diagnostics -> Diagnostics -> Diagnostics
mappend = Diagnostics -> Diagnostics -> Diagnostics
forall a. Semigroup a => a -> a -> a
(<>)

mkDiagnostics :: [Warning] -> [Error] -> Diagnostics
mkDiagnostics :: [Warning] -> [Error] -> Diagnostics
mkDiagnostics = [Warning] -> [Error] -> Diagnostics
Diagnostics

emptyDiagnostics :: Diagnostics
emptyDiagnostics :: Diagnostics
emptyDiagnostics = [Warning] -> [Error] -> Diagnostics
Diagnostics [Warning]
forall a. Monoid a => a
mempty [Error]
forall a. Monoid a => a
mempty

noErrors :: Diagnostics -> Bool
noErrors :: Diagnostics -> Bool
noErrors = [Error] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
L.null ([Error] -> Bool)
-> (Diagnostics -> [Error]) -> Diagnostics -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Diagnostics -> [Error]
dErrors

allWarnings :: Diagnostics -> [Warning]
allWarnings :: Diagnostics -> [Warning]
allWarnings = Diagnostics -> [Warning]
dWarnings

allErrors :: Diagnostics -> [Error]
allErrors :: Diagnostics -> [Error]
allErrors = Diagnostics -> [Error]
dErrors

--------------------------------------------------------------------------------
-- | Printing Warnings ---------------------------------------------------------
--------------------------------------------------------------------------------

printWarning :: Logger -> Warning -> IO ()
printWarning :: Logger -> Warning -> IO ()
printWarning Logger
logger (Warning SrcSpan
srcSpan Doc
doc) = Logger -> SrcSpan -> Doc -> IO ()
GHC.putWarnMsg Logger
logger SrcSpan
srcSpan Doc
doc

--------------------------------------------------------------------------------
-- | Error Data Type -----------------------------------------------------------
--------------------------------------------------------------------------------

type ErrorResult    = F.FixResult UserError
type Error          = TError SpecType


instance NFData a => NFData (TError a)

--------------------------------------------------------------------------------
-- | Source Information Associated With Constraints ----------------------------
--------------------------------------------------------------------------------

data Cinfo    = Ci
  { Cinfo -> SrcSpan
ci_loc :: !SrcSpan
  , Cinfo -> Maybe Error
ci_err :: !(Maybe Error)
  , Cinfo -> Maybe Var
ci_var :: !(Maybe Var)
  }
  deriving (Cinfo -> Cinfo -> Bool
(Cinfo -> Cinfo -> Bool) -> (Cinfo -> Cinfo -> Bool) -> Eq Cinfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Cinfo -> Cinfo -> Bool
== :: Cinfo -> Cinfo -> Bool
$c/= :: Cinfo -> Cinfo -> Bool
/= :: Cinfo -> Cinfo -> Bool
Eq, (forall x. Cinfo -> Rep Cinfo x)
-> (forall x. Rep Cinfo x -> Cinfo) -> Generic Cinfo
forall x. Rep Cinfo x -> Cinfo
forall x. Cinfo -> Rep Cinfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Cinfo -> Rep Cinfo x
from :: forall x. Cinfo -> Rep Cinfo x
$cto :: forall x. Rep Cinfo x -> Cinfo
to :: forall x. Rep Cinfo x -> Cinfo
Generic)

instance F.Loc Cinfo where
  srcSpan :: Cinfo -> SrcSpan
srcSpan = SrcSpan -> SrcSpan
srcSpanFSrcSpan (SrcSpan -> SrcSpan) -> (Cinfo -> SrcSpan) -> Cinfo -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cinfo -> SrcSpan
ci_loc

instance NFData Cinfo

instance F.PPrint Cinfo where
  pprintTidy :: Tidy -> Cinfo -> Doc
pprintTidy Tidy
k = Tidy -> SrcSpan -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (SrcSpan -> Doc) -> (Cinfo -> SrcSpan) -> Cinfo -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cinfo -> SrcSpan
ci_loc
--------------------------------------------------------------------------------
-- | Module Names --------------------------------------------------------------
--------------------------------------------------------------------------------

data ModName = ModName !ModType !ModuleName
  deriving (ModName -> ModName -> Bool
(ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool) -> Eq ModName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ModName -> ModName -> Bool
== :: ModName -> ModName -> Bool
$c/= :: ModName -> ModName -> Bool
/= :: ModName -> ModName -> Bool
Eq, Eq ModName
Eq ModName =>
(ModName -> ModName -> Ordering)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> ModName)
-> (ModName -> ModName -> ModName)
-> Ord ModName
ModName -> ModName -> Bool
ModName -> ModName -> Ordering
ModName -> ModName -> ModName
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ModName -> ModName -> Ordering
compare :: ModName -> ModName -> Ordering
$c< :: ModName -> ModName -> Bool
< :: ModName -> ModName -> Bool
$c<= :: ModName -> ModName -> Bool
<= :: ModName -> ModName -> Bool
$c> :: ModName -> ModName -> Bool
> :: ModName -> ModName -> Bool
$c>= :: ModName -> ModName -> Bool
>= :: ModName -> ModName -> Bool
$cmax :: ModName -> ModName -> ModName
max :: ModName -> ModName -> ModName
$cmin :: ModName -> ModName -> ModName
min :: ModName -> ModName -> ModName
Ord, Int -> ModName -> ShowS
[ModName] -> ShowS
ModName -> String
(Int -> ModName -> ShowS)
-> (ModName -> String) -> ([ModName] -> ShowS) -> Show ModName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ModName -> ShowS
showsPrec :: Int -> ModName -> ShowS
$cshow :: ModName -> String
show :: ModName -> String
$cshowList :: [ModName] -> ShowS
showList :: [ModName] -> ShowS
Show, (forall x. ModName -> Rep ModName x)
-> (forall x. Rep ModName x -> ModName) -> Generic ModName
forall x. Rep ModName x -> ModName
forall x. ModName -> Rep ModName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ModName -> Rep ModName x
from :: forall x. ModName -> Rep ModName x
$cto :: forall x. Rep ModName x -> ModName
to :: forall x. Rep ModName x -> ModName
Generic, Typeable ModName
Typeable ModName =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ModName -> c ModName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ModName)
-> (ModName -> Constr)
-> (ModName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ModName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName))
-> ((forall b. Data b => b -> b) -> ModName -> ModName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ModName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ModName -> r)
-> (forall u. (forall d. Data d => d -> u) -> ModName -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ModName -> m ModName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModName -> m ModName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModName -> m ModName)
-> Data ModName
ModName -> Constr
ModName -> DataType
(forall b. Data b => b -> b) -> ModName -> ModName
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u
forall u. (forall d. Data d => d -> u) -> ModName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModName -> c ModName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModName -> c ModName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModName -> c ModName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModName
$ctoConstr :: ModName -> Constr
toConstr :: ModName -> Constr
$cdataTypeOf :: ModName -> DataType
dataTypeOf :: ModName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName)
$cgmapT :: (forall b. Data b => b -> b) -> ModName -> ModName
gmapT :: (forall b. Data b => b -> b) -> ModName -> ModName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ModName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ModName -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
Data, Typeable)

data ModType = Target | SrcImport | SpecImport
  deriving (ModType -> ModType -> Bool
(ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool) -> Eq ModType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ModType -> ModType -> Bool
== :: ModType -> ModType -> Bool
$c/= :: ModType -> ModType -> Bool
/= :: ModType -> ModType -> Bool
Eq, Eq ModType
Eq ModType =>
(ModType -> ModType -> Ordering)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> ModType)
-> (ModType -> ModType -> ModType)
-> Ord ModType
ModType -> ModType -> Bool
ModType -> ModType -> Ordering
ModType -> ModType -> ModType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ModType -> ModType -> Ordering
compare :: ModType -> ModType -> Ordering
$c< :: ModType -> ModType -> Bool
< :: ModType -> ModType -> Bool
$c<= :: ModType -> ModType -> Bool
<= :: ModType -> ModType -> Bool
$c> :: ModType -> ModType -> Bool
> :: ModType -> ModType -> Bool
$c>= :: ModType -> ModType -> Bool
>= :: ModType -> ModType -> Bool
$cmax :: ModType -> ModType -> ModType
max :: ModType -> ModType -> ModType
$cmin :: ModType -> ModType -> ModType
min :: ModType -> ModType -> ModType
Ord, Int -> ModType -> ShowS
[ModType] -> ShowS
ModType -> String
(Int -> ModType -> ShowS)
-> (ModType -> String) -> ([ModType] -> ShowS) -> Show ModType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ModType -> ShowS
showsPrec :: Int -> ModType -> ShowS
$cshow :: ModType -> String
show :: ModType -> String
$cshowList :: [ModType] -> ShowS
showList :: [ModType] -> ShowS
Show, (forall x. ModType -> Rep ModType x)
-> (forall x. Rep ModType x -> ModType) -> Generic ModType
forall x. Rep ModType x -> ModType
forall x. ModType -> Rep ModType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ModType -> Rep ModType x
from :: forall x. ModType -> Rep ModType x
$cto :: forall x. Rep ModType x -> ModType
to :: forall x. Rep ModType x -> ModType
Generic, Typeable ModType
Typeable ModType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ModType -> c ModType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ModType)
-> (ModType -> Constr)
-> (ModType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ModType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModType))
-> ((forall b. Data b => b -> b) -> ModType -> ModType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ModType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ModType -> r)
-> (forall u. (forall d. Data d => d -> u) -> ModType -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ModType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ModType -> m ModType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModType -> m ModType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModType -> m ModType)
-> Data ModType
ModType -> Constr
ModType -> DataType
(forall b. Data b => b -> b) -> ModType -> ModType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ModType -> u
forall u. (forall d. Data d => d -> u) -> ModType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModType -> c ModType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModType -> c ModType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModType -> c ModType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModType
$ctoConstr :: ModType -> Constr
toConstr :: ModType -> Constr
$cdataTypeOf :: ModType -> DataType
dataTypeOf :: ModType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModType)
$cgmapT :: (forall b. Data b => b -> b) -> ModType -> ModType
gmapT :: (forall b. Data b => b -> b) -> ModType -> ModType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ModType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ModType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModType -> m ModType
Data, Typeable)

-- instance B.Binary ModType
-- instance B.Binary ModName

instance Hashable ModType

instance Hashable ModName where
  hashWithSalt :: Int -> ModName -> Int
hashWithSalt Int
i (ModName ModType
t ModuleName
n) = Int -> (ModType, String) -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
i (ModType
t, ModuleName -> String
forall a. Show a => a -> String
show ModuleName
n)

instance F.PPrint ModName where
  pprintTidy :: Tidy -> ModName -> Doc
pprintTidy Tidy
_ = String -> Doc
text (String -> Doc) -> (ModName -> String) -> ModName -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModName -> String
forall a. Show a => a -> String
show

instance F.Symbolic ModName where
  symbol :: ModName -> Symbol
symbol (ModName ModType
_ ModuleName
m) = ModuleName -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol ModuleName
m

instance F.Symbolic ModuleName where
  symbol :: ModuleName -> Symbol
symbol = FastString -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (FastString -> Symbol)
-> (ModuleName -> FastString) -> ModuleName -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> FastString
moduleNameFS


isTarget :: ModName -> Bool
isTarget :: ModName -> Bool
isTarget (ModName ModType
Target ModuleName
_) = Bool
True
isTarget ModName
_                  = Bool
False

isSrcImport :: ModName -> Bool
isSrcImport :: ModName -> Bool
isSrcImport (ModName ModType
SrcImport ModuleName
_) = Bool
True
isSrcImport ModName
_                     = Bool
False

isSpecImport :: ModName -> Bool
isSpecImport :: ModName -> Bool
isSpecImport (ModName ModType
SpecImport ModuleName
_) = Bool
True
isSpecImport ModName
_                      = Bool
False

getModName :: ModName -> ModuleName
getModName :: ModName -> ModuleName
getModName (ModName ModType
_ ModuleName
m) = ModuleName
m

getModString :: ModName -> String
getModString :: ModName -> String
getModString = ModuleName -> String
moduleNameString (ModuleName -> String)
-> (ModName -> ModuleName) -> ModName -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModName -> ModuleName
getModName

qualifyModName :: ModName -> Symbol -> Symbol
qualifyModName :: ModName -> Symbol -> Symbol
qualifyModName ModName
n = Symbol -> Symbol -> Symbol
qualifySymbol Symbol
nSym
  where
    nSym :: Symbol
nSym         = ModName -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol ModName
n

--------------------------------------------------------------------------------
-- | Refinement Type Aliases ---------------------------------------------------
--------------------------------------------------------------------------------
data RTEnv tv t = RTE
  { forall tv t. RTEnv tv t -> HashMap Symbol (Located (RTAlias tv t))
typeAliases :: M.HashMap Symbol (F.Located (RTAlias tv t))
  , forall tv t.
RTEnv tv t -> HashMap Symbol (Located (RTAlias Symbol Expr))
exprAliases :: M.HashMap Symbol (F.Located (RTAlias Symbol Expr))
  }


instance Monoid (RTEnv tv t) where
  mempty :: RTEnv tv t
mempty  = HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
forall tv t.
HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
RTE HashMap Symbol (Located (RTAlias tv t))
forall k v. HashMap k v
M.empty HashMap Symbol (Located (RTAlias Symbol Expr))
forall k v. HashMap k v
M.empty
  mappend :: RTEnv tv t -> RTEnv tv t -> RTEnv tv t
mappend = RTEnv tv t -> RTEnv tv t -> RTEnv tv t
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup (RTEnv tv t) where
  RTE HashMap Symbol (Located (RTAlias tv t))
x HashMap Symbol (Located (RTAlias Symbol Expr))
y <> :: RTEnv tv t -> RTEnv tv t -> RTEnv tv t
<> RTE HashMap Symbol (Located (RTAlias tv t))
x' HashMap Symbol (Located (RTAlias Symbol Expr))
y' = HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
forall tv t.
HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
RTE (HashMap Symbol (Located (RTAlias tv t))
x HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias tv t))
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
`M.union` HashMap Symbol (Located (RTAlias tv t))
x') (HashMap Symbol (Located (RTAlias Symbol Expr))
y HashMap Symbol (Located (RTAlias Symbol Expr))
-> HashMap Symbol (Located (RTAlias Symbol Expr))
-> HashMap Symbol (Located (RTAlias Symbol Expr))
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
`M.union` HashMap Symbol (Located (RTAlias Symbol Expr))
y')

-- mapRT :: (M.HashMap Symbol (RTAlias tv t) -> M.HashMap Symbol (RTAlias tv t))
--      -> RTEnv tv t -> RTEnv tv t
-- mapRT f e = e { typeAliases = f (typeAliases e) }

-- mapRE :: (M.HashMap Symbol (RTAlias Symbol Expr)
--       -> M.HashMap Symbol (RTAlias Symbol Expr))
--      -> RTEnv tv t -> RTEnv tv t
-- mapRE f e = e { exprAliases = f $ exprAliases e }


--------------------------------------------------------------------------------
-- | Measures
--------------------------------------------------------------------------------
data Body
  = E Expr          -- ^ Measure Refinement: {v | v = e }
  | P Expr          -- ^ Measure Refinement: {v | (? v) <=> p }
  | R Symbol Expr   -- ^ Measure Refinement: {v | p}
  deriving (Int -> Body -> ShowS
[Body] -> ShowS
Body -> String
(Int -> Body -> ShowS)
-> (Body -> String) -> ([Body] -> ShowS) -> Show Body
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Body -> ShowS
showsPrec :: Int -> Body -> ShowS
$cshow :: Body -> String
show :: Body -> String
$cshowList :: [Body] -> ShowS
showList :: [Body] -> ShowS
Show, Typeable Body
Typeable Body =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Body -> c Body)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Body)
-> (Body -> Constr)
-> (Body -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Body))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body))
-> ((forall b. Data b => b -> b) -> Body -> Body)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r)
-> (forall u. (forall d. Data d => d -> u) -> Body -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Body -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Body -> m Body)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Body -> m Body)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Body -> m Body)
-> Data Body
Body -> Constr
Body -> DataType
(forall b. Data b => b -> b) -> Body -> Body
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Body -> u
forall u. (forall d. Data d => d -> u) -> Body -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Body -> m Body
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Body -> m Body
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Body
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Body -> c Body
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Body)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Body -> c Body
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Body -> c Body
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Body
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Body
$ctoConstr :: Body -> Constr
toConstr :: Body -> Constr
$cdataTypeOf :: Body -> DataType
dataTypeOf :: Body -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Body)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Body)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body)
$cgmapT :: (forall b. Data b => b -> b) -> Body -> Body
gmapT :: (forall b. Data b => b -> b) -> Body -> Body
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Body -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Body -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Body -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Body -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Body -> m Body
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Body -> m Body
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Body -> m Body
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Body -> m Body
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Body -> m Body
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Body -> m Body
Data, Typeable, (forall x. Body -> Rep Body x)
-> (forall x. Rep Body x -> Body) -> Generic Body
forall x. Rep Body x -> Body
forall x. Body -> Rep Body x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Body -> Rep Body x
from :: forall x. Body -> Rep Body x
$cto :: forall x. Rep Body x -> Body
to :: forall x. Rep Body x -> Body
Generic, Body -> Body -> Bool
(Body -> Body -> Bool) -> (Body -> Body -> Bool) -> Eq Body
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Body -> Body -> Bool
== :: Body -> Body -> Bool
$c/= :: Body -> Body -> Bool
/= :: Body -> Body -> Bool
Eq)
  deriving Eq Body
Eq Body => (Int -> Body -> Int) -> (Body -> Int) -> Hashable Body
Int -> Body -> Int
Body -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Body -> Int
hashWithSalt :: Int -> Body -> Int
$chash :: Body -> Int
hash :: Body -> Int
Hashable via Generically Body

data Def ty ctor = Def
  { forall ty ctor. Def ty ctor -> LocSymbol
measure :: F.LocSymbol
  , forall ty ctor. Def ty ctor -> ctor
ctor    :: ctor
  , forall ty ctor. Def ty ctor -> Maybe ty
dsort   :: Maybe ty
  , forall ty ctor. Def ty ctor -> [(Symbol, Maybe ty)]
binds   :: [(Symbol, Maybe ty)]    -- measure binders: the ADT argument fields
  , forall ty ctor. Def ty ctor -> Body
body    :: Body
  } deriving (Int -> Def ty ctor -> ShowS
[Def ty ctor] -> ShowS
Def ty ctor -> String
(Int -> Def ty ctor -> ShowS)
-> (Def ty ctor -> String)
-> ([Def ty ctor] -> ShowS)
-> Show (Def ty ctor)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall ty ctor. (Show ctor, Show ty) => Int -> Def ty ctor -> ShowS
forall ty ctor. (Show ctor, Show ty) => [Def ty ctor] -> ShowS
forall ty ctor. (Show ctor, Show ty) => Def ty ctor -> String
$cshowsPrec :: forall ty ctor. (Show ctor, Show ty) => Int -> Def ty ctor -> ShowS
showsPrec :: Int -> Def ty ctor -> ShowS
$cshow :: forall ty ctor. (Show ctor, Show ty) => Def ty ctor -> String
show :: Def ty ctor -> String
$cshowList :: forall ty ctor. (Show ctor, Show ty) => [Def ty ctor] -> ShowS
showList :: [Def ty ctor] -> ShowS
Show, Typeable (Def ty ctor)
Typeable (Def ty ctor) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Def ty ctor))
-> (Def ty ctor -> Constr)
-> (Def ty ctor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Def ty ctor)))
-> ((forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r)
-> (forall u. (forall d. Data d => d -> u) -> Def ty ctor -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor))
-> Data (Def ty ctor)
Def ty ctor -> Constr
Def ty ctor -> DataType
(forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u
forall u. (forall d. Data d => d -> u) -> Def ty ctor -> [u]
forall ty ctor. (Data ty, Data ctor) => Typeable (Def ty ctor)
forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> Constr
forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> DataType
forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor
forall ty ctor u.
(Data ty, Data ctor) =>
Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u
forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> Def ty ctor -> [u]
forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
forall ty ctor r r'.
(Data ty, Data ctor) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
forall ty ctor (m :: * -> *).
(Data ty, Data ctor, Monad m) =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Def ty ctor)
forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor)
forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
forall ty ctor (t :: * -> * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Def ty ctor)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
$cgfoldl :: forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor)
$cgunfold :: forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Def ty ctor)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Def ty ctor)
$ctoConstr :: forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> Constr
toConstr :: Def ty ctor -> Constr
$cdataTypeOf :: forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> DataType
dataTypeOf :: Def ty ctor -> DataType
$cdataCast1 :: forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
$cdataCast2 :: forall ty ctor (t :: * -> * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
$cgmapT :: forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor
gmapT :: (forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor
$cgmapQl :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
$cgmapQr :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
$cgmapQ :: forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> Def ty ctor -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Def ty ctor -> [u]
$cgmapQi :: forall ty ctor u.
(Data ty, Data ctor) =>
Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u
$cgmapM :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, Monad m) =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
$cgmapMp :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
$cgmapMo :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
Data, Typeable, (forall x. Def ty ctor -> Rep (Def ty ctor) x)
-> (forall x. Rep (Def ty ctor) x -> Def ty ctor)
-> Generic (Def ty ctor)
forall x. Rep (Def ty ctor) x -> Def ty ctor
forall x. Def ty ctor -> Rep (Def ty ctor) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty ctor x. Rep (Def ty ctor) x -> Def ty ctor
forall ty ctor x. Def ty ctor -> Rep (Def ty ctor) x
$cfrom :: forall ty ctor x. Def ty ctor -> Rep (Def ty ctor) x
from :: forall x. Def ty ctor -> Rep (Def ty ctor) x
$cto :: forall ty ctor x. Rep (Def ty ctor) x -> Def ty ctor
to :: forall x. Rep (Def ty ctor) x -> Def ty ctor
Generic, Def ty ctor -> Def ty ctor -> Bool
(Def ty ctor -> Def ty ctor -> Bool)
-> (Def ty ctor -> Def ty ctor -> Bool) -> Eq (Def ty ctor)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall ty ctor.
(Eq ctor, Eq ty) =>
Def ty ctor -> Def ty ctor -> Bool
$c== :: forall ty ctor.
(Eq ctor, Eq ty) =>
Def ty ctor -> Def ty ctor -> Bool
== :: Def ty ctor -> Def ty ctor -> Bool
$c/= :: forall ty ctor.
(Eq ctor, Eq ty) =>
Def ty ctor -> Def ty ctor -> Bool
/= :: Def ty ctor -> Def ty ctor -> Bool
Eq, (forall a b. (a -> b) -> Def ty a -> Def ty b)
-> (forall a b. a -> Def ty b -> Def ty a) -> Functor (Def ty)
forall a b. a -> Def ty b -> Def ty a
forall a b. (a -> b) -> Def ty a -> Def ty b
forall ty a b. a -> Def ty b -> Def ty a
forall ty a b. (a -> b) -> Def ty a -> Def ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall ty a b. (a -> b) -> Def ty a -> Def ty b
fmap :: forall a b. (a -> b) -> Def ty a -> Def ty b
$c<$ :: forall ty a b. a -> Def ty b -> Def ty a
<$ :: forall a b. a -> Def ty b -> Def ty a
Functor)
    deriving Eq (Def ty ctor)
Eq (Def ty ctor) =>
(Int -> Def ty ctor -> Int)
-> (Def ty ctor -> Int) -> Hashable (Def ty ctor)
Int -> Def ty ctor -> Int
Def ty ctor -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall ty ctor. (Hashable ctor, Hashable ty) => Eq (Def ty ctor)
forall ty ctor.
(Hashable ctor, Hashable ty) =>
Int -> Def ty ctor -> Int
forall ty ctor. (Hashable ctor, Hashable ty) => Def ty ctor -> Int
$chashWithSalt :: forall ty ctor.
(Hashable ctor, Hashable ty) =>
Int -> Def ty ctor -> Int
hashWithSalt :: Int -> Def ty ctor -> Int
$chash :: forall ty ctor. (Hashable ctor, Hashable ty) => Def ty ctor -> Int
hash :: Def ty ctor -> Int
Hashable via Generically (Def ty ctor)

data Measure ty ctor = M
  { forall ty ctor. Measure ty ctor -> LocSymbol
msName :: F.LocSymbol
  , forall ty ctor. Measure ty ctor -> ty
msSort :: ty
  , forall ty ctor. Measure ty ctor -> [Def ty ctor]
msEqns :: [Def ty ctor]
  , forall ty ctor. Measure ty ctor -> MeasureKind
msKind :: !MeasureKind
  , forall ty ctor. Measure ty ctor -> UnSortedExprs
msUnSorted :: !UnSortedExprs -- potential unsorted expressions used at measure denifinitions
  } deriving (Measure ty ctor -> Measure ty ctor -> Bool
(Measure ty ctor -> Measure ty ctor -> Bool)
-> (Measure ty ctor -> Measure ty ctor -> Bool)
-> Eq (Measure ty ctor)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall ty ctor.
(Eq ty, Eq ctor) =>
Measure ty ctor -> Measure ty ctor -> Bool
$c== :: forall ty ctor.
(Eq ty, Eq ctor) =>
Measure ty ctor -> Measure ty ctor -> Bool
== :: Measure ty ctor -> Measure ty ctor -> Bool
$c/= :: forall ty ctor.
(Eq ty, Eq ctor) =>
Measure ty ctor -> Measure ty ctor -> Bool
/= :: Measure ty ctor -> Measure ty ctor -> Bool
Eq, Typeable (Measure ty ctor)
Typeable (Measure ty ctor) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Measure ty ctor))
-> (Measure ty ctor -> Constr)
-> (Measure ty ctor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Measure ty ctor)))
-> ((forall b. Data b => b -> b)
    -> Measure ty ctor -> Measure ty ctor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> Measure ty ctor -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Measure ty ctor -> m (Measure ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Measure ty ctor -> m (Measure ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Measure ty ctor -> m (Measure ty ctor))
-> Data (Measure ty ctor)
Measure ty ctor -> Constr
Measure ty ctor -> DataType
(forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty ctor
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
forall u. (forall d. Data d => d -> u) -> Measure ty ctor -> [u]
forall ty ctor. (Data ctor, Data ty) => Typeable (Measure ty ctor)
forall ty ctor. (Data ctor, Data ty) => Measure ty ctor -> Constr
forall ty ctor. (Data ctor, Data ty) => Measure ty ctor -> DataType
forall ty ctor.
(Data ctor, Data ty) =>
(forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty ctor
forall ty ctor u.
(Data ctor, Data ty) =>
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
forall ty ctor u.
(Data ctor, Data ty) =>
(forall d. Data d => d -> u) -> Measure ty ctor -> [u]
forall ty ctor r r'.
(Data ctor, Data ty) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall ty ctor r r'.
(Data ctor, Data ty) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall ty ctor (m :: * -> *).
(Data ctor, Data ty, Monad m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall ty ctor (m :: * -> *).
(Data ctor, Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall ty ctor (c :: * -> *).
(Data ctor, Data ty) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure ty ctor)
forall ty ctor (c :: * -> *).
(Data ctor, Data ty) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor)
forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ctor, Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
forall ty ctor (t :: * -> * -> *) (c :: * -> *).
(Data ctor, Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure ty ctor)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
$cgfoldl :: forall ty ctor (c :: * -> *).
(Data ctor, Data ty) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor)
$cgunfold :: forall ty ctor (c :: * -> *).
(Data ctor, Data ty) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure ty ctor)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure ty ctor)
$ctoConstr :: forall ty ctor. (Data ctor, Data ty) => Measure ty ctor -> Constr
toConstr :: Measure ty ctor -> Constr
$cdataTypeOf :: forall ty ctor. (Data ctor, Data ty) => Measure ty ctor -> DataType
dataTypeOf :: Measure ty ctor -> DataType
$cdataCast1 :: forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ctor, Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
$cdataCast2 :: forall ty ctor (t :: * -> * -> *) (c :: * -> *).
(Data ctor, Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
$cgmapT :: forall ty ctor.
(Data ctor, Data ty) =>
(forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty ctor
gmapT :: (forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty ctor
$cgmapQl :: forall ty ctor r r'.
(Data ctor, Data ty) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
$cgmapQr :: forall ty ctor r r'.
(Data ctor, Data ty) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
$cgmapQ :: forall ty ctor u.
(Data ctor, Data ty) =>
(forall d. Data d => d -> u) -> Measure ty ctor -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Measure ty ctor -> [u]
$cgmapQi :: forall ty ctor u.
(Data ctor, Data ty) =>
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
$cgmapM :: forall ty ctor (m :: * -> *).
(Data ctor, Data ty, Monad m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
$cgmapMp :: forall ty ctor (m :: * -> *).
(Data ctor, Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
$cgmapMo :: forall ty ctor (m :: * -> *).
(Data ctor, Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
Data, Typeable, (forall x. Measure ty ctor -> Rep (Measure ty ctor) x)
-> (forall x. Rep (Measure ty ctor) x -> Measure ty ctor)
-> Generic (Measure ty ctor)
forall x. Rep (Measure ty ctor) x -> Measure ty ctor
forall x. Measure ty ctor -> Rep (Measure ty ctor) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty ctor x. Rep (Measure ty ctor) x -> Measure ty ctor
forall ty ctor x. Measure ty ctor -> Rep (Measure ty ctor) x
$cfrom :: forall ty ctor x. Measure ty ctor -> Rep (Measure ty ctor) x
from :: forall x. Measure ty ctor -> Rep (Measure ty ctor) x
$cto :: forall ty ctor x. Rep (Measure ty ctor) x -> Measure ty ctor
to :: forall x. Rep (Measure ty ctor) x -> Measure ty ctor
Generic, (forall a b. (a -> b) -> Measure ty a -> Measure ty b)
-> (forall a b. a -> Measure ty b -> Measure ty a)
-> Functor (Measure ty)
forall a b. a -> Measure ty b -> Measure ty a
forall a b. (a -> b) -> Measure ty a -> Measure ty b
forall ty a b. a -> Measure ty b -> Measure ty a
forall ty a b. (a -> b) -> Measure ty a -> Measure ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall ty a b. (a -> b) -> Measure ty a -> Measure ty b
fmap :: forall a b. (a -> b) -> Measure ty a -> Measure ty b
$c<$ :: forall ty a b. a -> Measure ty b -> Measure ty a
<$ :: forall a b. a -> Measure ty b -> Measure ty a
Functor)
    deriving Eq (Measure ty ctor)
Eq (Measure ty ctor) =>
(Int -> Measure ty ctor -> Int)
-> (Measure ty ctor -> Int) -> Hashable (Measure ty ctor)
Int -> Measure ty ctor -> Int
Measure ty ctor -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall ty ctor.
(Hashable ty, Hashable ctor) =>
Eq (Measure ty ctor)
forall ty ctor.
(Hashable ty, Hashable ctor) =>
Int -> Measure ty ctor -> Int
forall ty ctor.
(Hashable ty, Hashable ctor) =>
Measure ty ctor -> Int
$chashWithSalt :: forall ty ctor.
(Hashable ty, Hashable ctor) =>
Int -> Measure ty ctor -> Int
hashWithSalt :: Int -> Measure ty ctor -> Int
$chash :: forall ty ctor.
(Hashable ty, Hashable ctor) =>
Measure ty ctor -> Int
hash :: Measure ty ctor -> Int
Hashable via Generically (Measure ty ctor)

type UnSortedExprs = [UnSortedExpr] -- mempty = []
type UnSortedExpr  = ([F.Symbol], F.Expr)

data MeasureKind
  = MsReflect     -- ^ due to `reflect foo`
  | MsMeasure     -- ^ due to `measure foo` with old-style (non-haskell) equations
  | MsLifted      -- ^ due to `measure foo` with new-style haskell equations
  | MsClass       -- ^ due to `class measure` definition
  | MsAbsMeasure  -- ^ due to `measure foo` without equations c.f. tests/pos/T1223.hs
  | MsSelector    -- ^ due to selector-fields e.g. `data Foo = Foo { fld :: Int }`
  | MsChecker     -- ^ due to checkers  e.g. `is-F` for `data Foo = F ... | G ...`
  deriving (MeasureKind -> MeasureKind -> Bool
(MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool) -> Eq MeasureKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MeasureKind -> MeasureKind -> Bool
== :: MeasureKind -> MeasureKind -> Bool
$c/= :: MeasureKind -> MeasureKind -> Bool
/= :: MeasureKind -> MeasureKind -> Bool
Eq, Eq MeasureKind
Eq MeasureKind =>
(MeasureKind -> MeasureKind -> Ordering)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> MeasureKind)
-> (MeasureKind -> MeasureKind -> MeasureKind)
-> Ord MeasureKind
MeasureKind -> MeasureKind -> Bool
MeasureKind -> MeasureKind -> Ordering
MeasureKind -> MeasureKind -> MeasureKind
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MeasureKind -> MeasureKind -> Ordering
compare :: MeasureKind -> MeasureKind -> Ordering
$c< :: MeasureKind -> MeasureKind -> Bool
< :: MeasureKind -> MeasureKind -> Bool
$c<= :: MeasureKind -> MeasureKind -> Bool
<= :: MeasureKind -> MeasureKind -> Bool
$c> :: MeasureKind -> MeasureKind -> Bool
> :: MeasureKind -> MeasureKind -> Bool
$c>= :: MeasureKind -> MeasureKind -> Bool
>= :: MeasureKind -> MeasureKind -> Bool
$cmax :: MeasureKind -> MeasureKind -> MeasureKind
max :: MeasureKind -> MeasureKind -> MeasureKind
$cmin :: MeasureKind -> MeasureKind -> MeasureKind
min :: MeasureKind -> MeasureKind -> MeasureKind
Ord, Int -> MeasureKind -> ShowS
[MeasureKind] -> ShowS
MeasureKind -> String
(Int -> MeasureKind -> ShowS)
-> (MeasureKind -> String)
-> ([MeasureKind] -> ShowS)
-> Show MeasureKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MeasureKind -> ShowS
showsPrec :: Int -> MeasureKind -> ShowS
$cshow :: MeasureKind -> String
show :: MeasureKind -> String
$cshowList :: [MeasureKind] -> ShowS
showList :: [MeasureKind] -> ShowS
Show, Typeable MeasureKind
Typeable MeasureKind =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> MeasureKind -> c MeasureKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MeasureKind)
-> (MeasureKind -> Constr)
-> (MeasureKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MeasureKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c MeasureKind))
-> ((forall b. Data b => b -> b) -> MeasureKind -> MeasureKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MeasureKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MeasureKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> MeasureKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind)
-> Data MeasureKind
MeasureKind -> Constr
MeasureKind -> DataType
(forall b. Data b => b -> b) -> MeasureKind -> MeasureKind
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeasureKind
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeasureKind -> c MeasureKind
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeasureKind)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MeasureKind)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeasureKind -> c MeasureKind
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeasureKind -> c MeasureKind
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeasureKind
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeasureKind
$ctoConstr :: MeasureKind -> Constr
toConstr :: MeasureKind -> Constr
$cdataTypeOf :: MeasureKind -> DataType
dataTypeOf :: MeasureKind -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeasureKind)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeasureKind)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MeasureKind)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MeasureKind)
$cgmapT :: (forall b. Data b => b -> b) -> MeasureKind -> MeasureKind
gmapT :: (forall b. Data b => b -> b) -> MeasureKind -> MeasureKind
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
Data, Typeable, (forall x. MeasureKind -> Rep MeasureKind x)
-> (forall x. Rep MeasureKind x -> MeasureKind)
-> Generic MeasureKind
forall x. Rep MeasureKind x -> MeasureKind
forall x. MeasureKind -> Rep MeasureKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MeasureKind -> Rep MeasureKind x
from :: forall x. MeasureKind -> Rep MeasureKind x
$cto :: forall x. Rep MeasureKind x -> MeasureKind
to :: forall x. Rep MeasureKind x -> MeasureKind
Generic)
  deriving Eq MeasureKind
Eq MeasureKind =>
(Int -> MeasureKind -> Int)
-> (MeasureKind -> Int) -> Hashable MeasureKind
Int -> MeasureKind -> Int
MeasureKind -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> MeasureKind -> Int
hashWithSalt :: Int -> MeasureKind -> Int
$chash :: MeasureKind -> Int
hash :: MeasureKind -> Int
Hashable via Generically MeasureKind

instance F.Loc (Measure a b) where
  srcSpan :: Measure a b -> SrcSpan
srcSpan = LocSymbol -> SrcSpan
forall a. Loc a => a -> SrcSpan
F.srcSpan (LocSymbol -> SrcSpan)
-> (Measure a b -> LocSymbol) -> Measure a b -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Measure a b -> LocSymbol
forall ty ctor. Measure ty ctor -> LocSymbol
msName

instance Bifunctor Def where
  -- first f  (Def m ps c s bs b) = Def m (second f <$> ps) c (f <$> s) ((second (fmap f)) <$> bs) b
  -- second f (Def m ps c s bs b) = Def m ps (f c) s bs b
  first :: forall a b c. (a -> b) -> Def a c -> Def b c
first a -> b
f  (Def LocSymbol
m c
c Maybe a
s [(Symbol, Maybe a)]
bs Body
b) = LocSymbol -> c -> Maybe b -> [(Symbol, Maybe b)] -> Body -> Def b c
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m c
c (a -> b
f (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe a
s) ((Maybe a -> Maybe b) -> (Symbol, Maybe a) -> (Symbol, Maybe b)
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second ((a -> b) -> Maybe a -> Maybe b
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) ((Symbol, Maybe a) -> (Symbol, Maybe b))
-> [(Symbol, Maybe a)] -> [(Symbol, Maybe b)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Maybe a)]
bs) Body
b
  second :: forall b c a. (b -> c) -> Def a b -> Def a c
second b -> c
f (Def LocSymbol
m b
c Maybe a
s [(Symbol, Maybe a)]
bs Body
b) = LocSymbol -> c -> Maybe a -> [(Symbol, Maybe a)] -> Body -> Def a c
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m (b -> c
f b
c) Maybe a
s [(Symbol, Maybe a)]
bs Body
b


instance Bifunctor Measure where
  first :: forall a b c. (a -> b) -> Measure a c -> Measure b c
first  a -> b
f (M LocSymbol
n a
s [Def a c]
es MeasureKind
k UnSortedExprs
u) = LocSymbol
-> b -> [Def b c] -> MeasureKind -> UnSortedExprs -> Measure b c
forall ty ctor.
LocSymbol
-> ty
-> [Def ty ctor]
-> MeasureKind
-> UnSortedExprs
-> Measure ty ctor
M LocSymbol
n (a -> b
f a
s) ((a -> b) -> Def a c -> Def b c
forall a b c. (a -> b) -> Def a c -> Def b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f (Def a c -> Def b c) -> [Def a c] -> [Def b c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Def a c]
es) MeasureKind
k UnSortedExprs
u
  second :: forall b c a. (b -> c) -> Measure a b -> Measure a c
second b -> c
f (M LocSymbol
n a
s [Def a b]
es MeasureKind
k UnSortedExprs
u) = LocSymbol
-> a -> [Def a c] -> MeasureKind -> UnSortedExprs -> Measure a c
forall ty ctor.
LocSymbol
-> ty
-> [Def ty ctor]
-> MeasureKind
-> UnSortedExprs
-> Measure ty ctor
M LocSymbol
n a
s ((b -> c) -> Def a b -> Def a c
forall b c a. (b -> c) -> Def a b -> Def a c
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second b -> c
f (Def a b -> Def a c) -> [Def a b] -> [Def a c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Def a b]
es)    MeasureKind
k UnSortedExprs
u

instance                             B.Binary MeasureKind
instance                             B.Binary Body
instance (B.Binary t, B.Binary c) => B.Binary (Def     t c)
instance (B.Binary t, B.Binary c) => B.Binary (Measure t c)

-- NOTE: don't use the TH versions since they seem to cause issues
-- building on windows :(
-- deriveBifunctor ''Def
-- deriveBifunctor ''Measure

data CMeasure ty = CM
  { forall ty. CMeasure ty -> LocSymbol
cName :: F.LocSymbol
  , forall ty. CMeasure ty -> ty
cSort :: ty
  } deriving (Typeable (CMeasure ty)
Typeable (CMeasure ty) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (CMeasure ty))
-> (CMeasure ty -> Constr)
-> (CMeasure ty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (CMeasure ty)))
-> ((forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r)
-> (forall u. (forall d. Data d => d -> u) -> CMeasure ty -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty))
-> Data (CMeasure ty)
CMeasure ty -> Constr
CMeasure ty -> DataType
(forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
forall ty. Data ty => Typeable (CMeasure ty)
forall ty. Data ty => CMeasure ty -> Constr
forall ty. Data ty => CMeasure ty -> DataType
forall ty.
Data ty =>
(forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
forall ty u.
Data ty =>
Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u
forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> CMeasure ty -> [u]
forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
forall ty r r'.
Data ty =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
forall ty (c :: * -> *).
Data ty =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CMeasure ty)
forall ty (c :: * -> *).
Data ty =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty)
forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
forall ty (t :: * -> * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CMeasure ty))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u
forall u. (forall d. Data d => d -> u) -> CMeasure ty -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CMeasure ty)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CMeasure ty))
$cgfoldl :: forall ty (c :: * -> *).
Data ty =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty)
$cgunfold :: forall ty (c :: * -> *).
Data ty =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CMeasure ty)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CMeasure ty)
$ctoConstr :: forall ty. Data ty => CMeasure ty -> Constr
toConstr :: CMeasure ty -> Constr
$cdataTypeOf :: forall ty. Data ty => CMeasure ty -> DataType
dataTypeOf :: CMeasure ty -> DataType
$cdataCast1 :: forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
$cdataCast2 :: forall ty (t :: * -> * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CMeasure ty))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CMeasure ty))
$cgmapT :: forall ty.
Data ty =>
(forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
gmapT :: (forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
$cgmapQl :: forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
$cgmapQr :: forall ty r r'.
Data ty =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> CMeasure ty -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CMeasure ty -> [u]
$cgmapQi :: forall ty u.
Data ty =>
Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u
$cgmapM :: forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
$cgmapMp :: forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
$cgmapMo :: forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
Data, Typeable, (forall x. CMeasure ty -> Rep (CMeasure ty) x)
-> (forall x. Rep (CMeasure ty) x -> CMeasure ty)
-> Generic (CMeasure ty)
forall x. Rep (CMeasure ty) x -> CMeasure ty
forall x. CMeasure ty -> Rep (CMeasure ty) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty x. Rep (CMeasure ty) x -> CMeasure ty
forall ty x. CMeasure ty -> Rep (CMeasure ty) x
$cfrom :: forall ty x. CMeasure ty -> Rep (CMeasure ty) x
from :: forall x. CMeasure ty -> Rep (CMeasure ty) x
$cto :: forall ty x. Rep (CMeasure ty) x -> CMeasure ty
to :: forall x. Rep (CMeasure ty) x -> CMeasure ty
Generic, (forall a b. (a -> b) -> CMeasure a -> CMeasure b)
-> (forall a b. a -> CMeasure b -> CMeasure a) -> Functor CMeasure
forall a b. a -> CMeasure b -> CMeasure a
forall a b. (a -> b) -> CMeasure a -> CMeasure b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> CMeasure a -> CMeasure b
fmap :: forall a b. (a -> b) -> CMeasure a -> CMeasure b
$c<$ :: forall a b. a -> CMeasure b -> CMeasure a
<$ :: forall a b. a -> CMeasure b -> CMeasure a
Functor)

instance F.PPrint Body where
  pprintTidy :: Tidy -> Body -> Doc
pprintTidy Tidy
k (E Expr
e)   = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e
  pprintTidy Tidy
k (P Expr
p)   = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
p
  pprintTidy Tidy
k (R Symbol
v Expr
p) = Doc -> Doc
braces (Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Symbol
v Doc -> Doc -> Doc
<+> Doc
"|" Doc -> Doc -> Doc
<+> Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
p)

instance F.PPrint a => F.PPrint (Def t a) where
  pprintTidy :: Tidy -> Def t a -> Doc
pprintTidy Tidy
k (Def LocSymbol
m a
c Maybe t
_ [(Symbol, Maybe t)]
bs Body
body)
           = Tidy -> LocSymbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k LocSymbol
m Doc -> Doc -> Doc
<+> Doc
cbsd Doc -> Doc -> Doc
<+> Doc
"=" Doc -> Doc -> Doc
<+> Tidy -> Body -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Body
body
    where
      cbsd :: Doc
cbsd = Doc -> Doc
parens (Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
c Doc -> Doc -> Doc
<-> [Doc] -> Doc
hsep (Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (Symbol -> Doc) -> [Symbol] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ((Symbol, Maybe t) -> Symbol
forall a b. (a, b) -> a
fst ((Symbol, Maybe t) -> Symbol) -> [(Symbol, Maybe t)] -> [Symbol]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Maybe t)]
bs)))

instance (F.PPrint t, F.PPrint a) => F.PPrint (Measure t a) where
  pprintTidy :: Tidy -> Measure t a -> Doc
pprintTidy Tidy
k (M LocSymbol
n t
s [Def t a]
eqs MeasureKind
_ UnSortedExprs
_) =  Tidy -> LocSymbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k LocSymbol
n Doc -> Doc -> Doc
<+> {- parens (pprintTidy k (loc n)) <+> -} Doc
"::" Doc -> Doc -> Doc
<+> Tidy -> t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k t
s
                                  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat (Tidy -> Def t a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (Def t a -> Doc) -> [Def t a] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` [Def t a]
eqs)


instance F.PPrint (Measure t a) => Show (Measure t a) where
  show :: Measure t a -> String
show = Measure t a -> String
forall a. PPrint a => a -> String
F.showpp

instance F.PPrint t => F.PPrint (CMeasure t) where
  pprintTidy :: Tidy -> CMeasure t -> Doc
pprintTidy Tidy
k (CM LocSymbol
n t
s) =  Tidy -> LocSymbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k LocSymbol
n Doc -> Doc -> Doc
<+> Doc
"::" Doc -> Doc -> Doc
<+> Tidy -> t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k t
s

instance F.PPrint (CMeasure t) => Show (CMeasure t) where
  show :: CMeasure t -> String
show = CMeasure t -> String
forall a. PPrint a => a -> String
F.showpp


instance F.Subable (Measure ty ctor) where
  syms :: Measure ty ctor -> [Symbol]
syms  Measure ty ctor
m     = (Def ty ctor -> [Symbol]) -> [Def ty ctor] -> [Symbol]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Def ty ctor -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms (Measure ty ctor -> [Def ty ctor]
forall ty ctor. Measure ty ctor -> [Def ty ctor]
msEqns Measure ty ctor
m)
  substa :: (Symbol -> Symbol) -> Measure ty ctor -> Measure ty ctor
substa Symbol -> Symbol
f Measure ty ctor
m  = Measure ty ctor
m { msEqns = F.substa f  <$> msEqns m }
  substf :: (Symbol -> Expr) -> Measure ty ctor -> Measure ty ctor
substf Symbol -> Expr
f Measure ty ctor
m  = Measure ty ctor
m { msEqns = F.substf f  <$> msEqns m }
  subst :: Subst -> Measure ty ctor -> Measure ty ctor
subst  Subst
su Measure ty ctor
m = Measure ty ctor
m { msEqns = F.subst  su <$> msEqns m }
  -- substa f  (M n s es _) = M n s (F.substa f  <$> es) k
  -- substf f  (M n s es _) = M n s $ F.substf f  <$> es
  -- subst  su (M n s es _) = M n s $ F.subst  su <$> es

instance F.Subable (Def ty ctor) where
  syms :: Def ty ctor -> [Symbol]
syms (Def LocSymbol
_ ctor
_ Maybe ty
_ [(Symbol, Maybe ty)]
sb Body
bd)  = ((Symbol, Maybe ty) -> Symbol
forall a b. (a, b) -> a
fst ((Symbol, Maybe ty) -> Symbol) -> [(Symbol, Maybe ty)] -> [Symbol]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Maybe ty)]
sb) [Symbol] -> [Symbol] -> [Symbol]
forall a. [a] -> [a] -> [a]
++ Body -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms Body
bd
  substa :: (Symbol -> Symbol) -> Def ty ctor -> Def ty ctor
substa Symbol -> Symbol
f  (Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b Body
bd) = LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b (Body -> Def ty ctor) -> Body -> Def ty ctor
forall a b. (a -> b) -> a -> b
$ (Symbol -> Symbol) -> Body -> Body
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f  Body
bd
  substf :: (Symbol -> Expr) -> Def ty ctor -> Def ty ctor
substf Symbol -> Expr
f  (Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b Body
bd) = LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b (Body -> Def ty ctor) -> Body -> Def ty ctor
forall a b. (a -> b) -> a -> b
$ (Symbol -> Expr) -> Body -> Body
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f  Body
bd
  subst :: Subst -> Def ty ctor -> Def ty ctor
subst  Subst
su (Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b Body
bd) = LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b (Body -> Def ty ctor) -> Body -> Def ty ctor
forall a b. (a -> b) -> a -> b
$ Subst -> Body -> Body
forall a. Subable a => Subst -> a -> a
F.subst  Subst
su Body
bd

instance F.Subable Body where
  syms :: Body -> [Symbol]
syms (E Expr
e)       = Expr -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms Expr
e
  syms (P Expr
e)       = Expr -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms Expr
e
  syms (R Symbol
s Expr
e)     = Symbol
s Symbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
: Expr -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms Expr
e

  substa :: (Symbol -> Symbol) -> Body -> Body
substa Symbol -> Symbol
f (E Expr
e)   = Expr -> Body
E   ((Symbol -> Symbol) -> Expr -> Expr
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f Expr
e)
  substa Symbol -> Symbol
f (P Expr
e)   = Expr -> Body
P   ((Symbol -> Symbol) -> Expr -> Expr
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f Expr
e)
  substa Symbol -> Symbol
f (R Symbol
s Expr
e) = Symbol -> Expr -> Body
R Symbol
s ((Symbol -> Symbol) -> Expr -> Expr
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f Expr
e)

  substf :: (Symbol -> Expr) -> Body -> Body
substf Symbol -> Expr
f (E Expr
e)   = Expr -> Body
E   ((Symbol -> Expr) -> Expr -> Expr
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f Expr
e)
  substf Symbol -> Expr
f (P Expr
e)   = Expr -> Body
P   ((Symbol -> Expr) -> Expr -> Expr
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f Expr
e)
  substf Symbol -> Expr
f (R Symbol
s Expr
e) = Symbol -> Expr -> Body
R Symbol
s ((Symbol -> Expr) -> Expr -> Expr
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f Expr
e)

  subst :: Subst -> Body -> Body
subst Subst
su (E Expr
e)   = Expr -> Body
E   (Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst Subst
su Expr
e)
  subst Subst
su (P Expr
e)   = Expr -> Body
P   (Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst Subst
su Expr
e)
  subst Subst
su (R Symbol
s Expr
e) = Symbol -> Expr -> Body
R Symbol
s (Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst Subst
su Expr
e)

instance F.Subable t => F.Subable (WithModel t) where
  syms :: WithModel t -> [Symbol]
syms (NoModel t
t)     = t -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms t
t
  syms (WithModel Doc
_ t
t) = t -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms t
t
  substa :: (Symbol -> Symbol) -> WithModel t -> WithModel t
substa Symbol -> Symbol
f             = (t -> t) -> WithModel t -> WithModel t
forall a b. (a -> b) -> WithModel a -> WithModel b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Symbol -> Symbol) -> t -> t
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f)
  substf :: (Symbol -> Expr) -> WithModel t -> WithModel t
substf Symbol -> Expr
f             = (t -> t) -> WithModel t -> WithModel t
forall a b. (a -> b) -> WithModel a -> WithModel b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Symbol -> Expr) -> t -> t
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f)
  subst :: Subst -> WithModel t -> WithModel t
subst Subst
su             = (t -> t) -> WithModel t -> WithModel t
forall a b. (a -> b) -> WithModel a -> WithModel b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Subst -> t -> t
forall a. Subable a => Subst -> a -> a
F.subst Subst
su)

data RClass ty = RClass
  { forall ty. RClass ty -> BTyCon
rcName    :: BTyCon
  , forall ty. RClass ty -> [ty]
rcSupers  :: [ty]
  , forall ty. RClass ty -> [BTyVar]
rcTyVars  :: [BTyVar]
  , forall ty. RClass ty -> [(LocSymbol, ty)]
rcMethods :: [(F.LocSymbol, ty)]
  } deriving (RClass ty -> RClass ty -> Bool
(RClass ty -> RClass ty -> Bool)
-> (RClass ty -> RClass ty -> Bool) -> Eq (RClass ty)
forall ty. Eq ty => RClass ty -> RClass ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall ty. Eq ty => RClass ty -> RClass ty -> Bool
== :: RClass ty -> RClass ty -> Bool
$c/= :: forall ty. Eq ty => RClass ty -> RClass ty -> Bool
/= :: RClass ty -> RClass ty -> Bool
Eq, Int -> RClass ty -> ShowS
[RClass ty] -> ShowS
RClass ty -> String
(Int -> RClass ty -> ShowS)
-> (RClass ty -> String)
-> ([RClass ty] -> ShowS)
-> Show (RClass ty)
forall ty. Show ty => Int -> RClass ty -> ShowS
forall ty. Show ty => [RClass ty] -> ShowS
forall ty. Show ty => RClass ty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall ty. Show ty => Int -> RClass ty -> ShowS
showsPrec :: Int -> RClass ty -> ShowS
$cshow :: forall ty. Show ty => RClass ty -> String
show :: RClass ty -> String
$cshowList :: forall ty. Show ty => [RClass ty] -> ShowS
showList :: [RClass ty] -> ShowS
Show, (forall a b. (a -> b) -> RClass a -> RClass b)
-> (forall a b. a -> RClass b -> RClass a) -> Functor RClass
forall a b. a -> RClass b -> RClass a
forall a b. (a -> b) -> RClass a -> RClass b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> RClass a -> RClass b
fmap :: forall a b. (a -> b) -> RClass a -> RClass b
$c<$ :: forall a b. a -> RClass b -> RClass a
<$ :: forall a b. a -> RClass b -> RClass a
Functor, Typeable (RClass ty)
Typeable (RClass ty) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RClass ty -> c (RClass ty))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RClass ty))
-> (RClass ty -> Constr)
-> (RClass ty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RClass ty)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RClass ty)))
-> ((forall b. Data b => b -> b) -> RClass ty -> RClass ty)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RClass ty -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RClass ty -> r)
-> (forall u. (forall d. Data d => d -> u) -> RClass ty -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RClass ty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty))
-> Data (RClass ty)
RClass ty -> Constr
RClass ty -> DataType
(forall b. Data b => b -> b) -> RClass ty -> RClass ty
forall ty. Data ty => Typeable (RClass ty)
forall ty. Data ty => RClass ty -> Constr
forall ty. Data ty => RClass ty -> DataType
forall ty.
Data ty =>
(forall b. Data b => b -> b) -> RClass ty -> RClass ty
forall ty u.
Data ty =>
Int -> (forall d. Data d => d -> u) -> RClass ty -> u
forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RClass ty -> [u]
forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
forall ty r r'.
Data ty =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
forall ty (c :: * -> *).
Data ty =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RClass ty)
forall ty (c :: * -> *).
Data ty =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> c (RClass ty)
forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
forall ty (t :: * -> * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RClass ty))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RClass ty -> u
forall u. (forall d. Data d => d -> u) -> RClass ty -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RClass ty)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> c (RClass ty)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RClass ty))
$cgfoldl :: forall ty (c :: * -> *).
Data ty =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> c (RClass ty)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> c (RClass ty)
$cgunfold :: forall ty (c :: * -> *).
Data ty =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RClass ty)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RClass ty)
$ctoConstr :: forall ty. Data ty => RClass ty -> Constr
toConstr :: RClass ty -> Constr
$cdataTypeOf :: forall ty. Data ty => RClass ty -> DataType
dataTypeOf :: RClass ty -> DataType
$cdataCast1 :: forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
$cdataCast2 :: forall ty (t :: * -> * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RClass ty))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RClass ty))
$cgmapT :: forall ty.
Data ty =>
(forall b. Data b => b -> b) -> RClass ty -> RClass ty
gmapT :: (forall b. Data b => b -> b) -> RClass ty -> RClass ty
$cgmapQl :: forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
$cgmapQr :: forall ty r r'.
Data ty =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RClass ty -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RClass ty -> [u]
$cgmapQi :: forall ty u.
Data ty =>
Int -> (forall d. Data d => d -> u) -> RClass ty -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RClass ty -> u
$cgmapM :: forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
$cgmapMp :: forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
$cgmapMo :: forall ty (m :: * -> *).
(Data ty, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
Data, Typeable, (forall x. RClass ty -> Rep (RClass ty) x)
-> (forall x. Rep (RClass ty) x -> RClass ty)
-> Generic (RClass ty)
forall x. Rep (RClass ty) x -> RClass ty
forall x. RClass ty -> Rep (RClass ty) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty x. Rep (RClass ty) x -> RClass ty
forall ty x. RClass ty -> Rep (RClass ty) x
$cfrom :: forall ty x. RClass ty -> Rep (RClass ty) x
from :: forall x. RClass ty -> Rep (RClass ty) x
$cto :: forall ty x. Rep (RClass ty) x -> RClass ty
to :: forall x. Rep (RClass ty) x -> RClass ty
Generic)
    deriving Eq (RClass ty)
Eq (RClass ty) =>
(Int -> RClass ty -> Int)
-> (RClass ty -> Int) -> Hashable (RClass ty)
Int -> RClass ty -> Int
RClass ty -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
forall ty. Hashable ty => Eq (RClass ty)
forall ty. Hashable ty => Int -> RClass ty -> Int
forall ty. Hashable ty => RClass ty -> Int
$chashWithSalt :: forall ty. Hashable ty => Int -> RClass ty -> Int
hashWithSalt :: Int -> RClass ty -> Int
$chash :: forall ty. Hashable ty => RClass ty -> Int
hash :: RClass ty -> Int
Hashable via Generically (RClass ty)


instance F.PPrint t => F.PPrint (RClass t) where
  pprintTidy :: Tidy -> RClass t -> Doc
pprintTidy Tidy
k (RClass BTyCon
n [t]
ts [BTyVar]
as [(LocSymbol, t)]
mts)
                = Tidy -> Doc -> BTyCon -> [BTyVar] -> [(LocSymbol, RISig t)] -> Doc
forall x t a n.
(PPrint x, PPrint t, PPrint a, PPrint n) =>
Tidy -> Doc -> n -> [a] -> [(x, RISig t)] -> Doc
ppMethods Tidy
k (Doc
"class" Doc -> Doc -> Doc
<+> [t] -> Doc
forall {a}. PPrint a => [a] -> Doc
supers [t]
ts) BTyCon
n [BTyVar]
as [(LocSymbol
m, t -> RISig t
forall t. t -> RISig t
RISig t
t) | (LocSymbol
m, t
t) <- [(LocSymbol, t)]
mts]
    where
      supers :: [a] -> Doc
supers [] = Doc
""
      supers [a]
xs = [Doc] -> Doc
tuplify (Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k   (a -> Doc) -> [a] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
xs) Doc -> Doc -> Doc
<+> Doc
"=>"
      tuplify :: [Doc] -> Doc
tuplify   = Doc -> Doc
parens (Doc -> Doc) -> ([Doc] -> Doc) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Doc] -> Doc
hcat ([Doc] -> Doc) -> ([Doc] -> [Doc]) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
", "


instance F.PPrint t => F.PPrint (RILaws t) where
  pprintTidy :: Tidy -> RILaws t -> Doc
pprintTidy Tidy
k (RIL BTyCon
n [t]
ss [t]
ts [(LocSymbol, LocSymbol)]
mts Located ()
_) = Tidy -> Doc -> BTyCon -> [t] -> [(LocSymbol, LocSymbol)] -> Doc
forall x t a n.
(PPrint x, PPrint t, PPrint a, PPrint n) =>
Tidy -> Doc -> n -> [a] -> [(x, t)] -> Doc
ppEqs Tidy
k (Doc
"instance laws" Doc -> Doc -> Doc
<+> [t] -> Doc
forall {a}. PPrint a => [a] -> Doc
supers [t]
ss) BTyCon
n [t]
ts [(LocSymbol, LocSymbol)]
mts
   where
    supers :: [a] -> Doc
supers [] = Doc
""
    supers [a]
xs = [Doc] -> Doc
tuplify (Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k   (a -> Doc) -> [a] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
xs) Doc -> Doc -> Doc
<+> Doc
"=>"
    tuplify :: [Doc] -> Doc
tuplify   = Doc -> Doc
parens (Doc -> Doc) -> ([Doc] -> Doc) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Doc] -> Doc
hcat ([Doc] -> Doc) -> ([Doc] -> [Doc]) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
", "


ppEqs :: (F.PPrint x, F.PPrint t, F.PPrint a, F.PPrint n)
          => F.Tidy -> Doc -> n -> [a] -> [(x, t)] -> Doc
ppEqs :: forall x t a n.
(PPrint x, PPrint t, PPrint a, PPrint n) =>
Tidy -> Doc -> n -> [a] -> [(x, t)] -> Doc
ppEqs Tidy
k Doc
hdr n
name [a]
args [(x, t)]
mts
  = [Doc] -> Doc
vcat ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ Doc
hdr Doc -> Doc -> Doc
<+> Doc
dName Doc -> Doc -> Doc
<+> Doc
"where"
         Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [ Int -> Doc -> Doc
nest Int
4 (x -> t -> Doc
forall {a} {a}. (PPrint a, PPrint a) => a -> a -> Doc
bind x
m t
t) | (x
m, t
t) <- [(x, t)]
mts ]
    where
      dName :: Doc
dName    = Doc -> Doc
parens  (Tidy -> n -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k n
name Doc -> Doc -> Doc
<+> Doc
dArgs)
      dArgs :: Doc
dArgs    = [Doc] -> Doc
gaps    (Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k      (a -> Doc) -> [a] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
args)
      gaps :: [Doc] -> Doc
gaps     = [Doc] -> Doc
hcat ([Doc] -> Doc) -> ([Doc] -> [Doc]) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
" "
      bind :: a -> a -> Doc
bind a
m a
t = Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
m Doc -> Doc -> Doc
<+> Doc
"=" Doc -> Doc -> Doc
<+> Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
t

ppMethods :: (F.PPrint x, F.PPrint t, F.PPrint a, F.PPrint n)
          => F.Tidy -> Doc -> n -> [a] -> [(x, RISig t)] -> Doc
ppMethods :: forall x t a n.
(PPrint x, PPrint t, PPrint a, PPrint n) =>
Tidy -> Doc -> n -> [a] -> [(x, RISig t)] -> Doc
ppMethods Tidy
k Doc
hdr n
name [a]
args [(x, RISig t)]
mts
  = [Doc] -> Doc
vcat ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ Doc
hdr Doc -> Doc -> Doc
<+> Doc
dName Doc -> Doc -> Doc
<+> Doc
"where"
         Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [ Int -> Doc -> Doc
nest Int
4 (x -> RISig t -> Doc
forall {k} {t}. (PPrint k, PPrint t) => k -> RISig t -> Doc
bind x
m RISig t
t) | (x
m, RISig t
t) <- [(x, RISig t)]
mts ]
    where
      dName :: Doc
dName    = Doc -> Doc
parens  (Tidy -> n -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k n
name Doc -> Doc -> Doc
<+> Doc
dArgs)
      dArgs :: Doc
dArgs    = [Doc] -> Doc
gaps    (Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k      (a -> Doc) -> [a] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
args)
      gaps :: [Doc] -> Doc
gaps     = [Doc] -> Doc
hcat ([Doc] -> Doc) -> ([Doc] -> [Doc]) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
" "
      bind :: k -> RISig t -> Doc
bind k
m RISig t
t = Tidy -> k -> RISig t -> Doc
forall k t. (PPrint k, PPrint t) => Tidy -> k -> RISig t -> Doc
ppRISig Tidy
k k
m RISig t
t -- F.pprintTidy k m <+> "::" <+> F.pprintTidy k t

instance B.Binary ty => B.Binary (RClass ty)


------------------------------------------------------------------------
-- | Var Hole Info -----------------------------------------------------
------------------------------------------------------------------------

data HoleInfo i t = HoleInfo {forall i t. HoleInfo i t -> t
htype :: t, forall i t. HoleInfo i t -> SrcSpan
hloc :: SrcSpan, forall i t. HoleInfo i t -> AREnv t
henv :: AREnv t, forall i t. HoleInfo i t -> i
info :: i }

instance Functor (HoleInfo i) where
  fmap :: forall a b. (a -> b) -> HoleInfo i a -> HoleInfo i b
fmap a -> b
f HoleInfo i a
hinfo = HoleInfo i a
hinfo{htype = f (htype hinfo), henv = fmap f (henv hinfo)}

instance (F.PPrint t) => F.PPrint (HoleInfo  i t) where
  pprintTidy :: Tidy -> HoleInfo i t -> Doc
pprintTidy Tidy
k HoleInfo i t
hinfo = String -> Doc
text String
"type:" Doc -> Doc -> Doc
<+> Tidy -> t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (HoleInfo i t -> t
forall i t. HoleInfo i t -> t
htype HoleInfo i t
hinfo)
                       Doc -> Doc -> Doc
<+> String -> Doc
text String
"\n loc:" Doc -> Doc -> Doc
<+> Tidy -> SrcSpan -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (HoleInfo i t -> SrcSpan
forall i t. HoleInfo i t -> SrcSpan
hloc HoleInfo i t
hinfo)
  -- to print the hole environment uncomment the following
  --                     <+> text "\n env:" <+> F.pprintTidy k (henv hinfo)

------------------------------------------------------------------------
-- | Annotations -------------------------------------------------------
------------------------------------------------------------------------

newtype AnnInfo a = AI (M.HashMap SrcSpan [(Maybe Text, a)])
                    deriving (Typeable (AnnInfo a)
Typeable (AnnInfo a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (AnnInfo a))
-> (AnnInfo a -> Constr)
-> (AnnInfo a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (AnnInfo a)))
-> ((forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnInfo a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a))
-> Data (AnnInfo a)
AnnInfo a -> Constr
AnnInfo a -> DataType
(forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
forall a. Data a => Typeable (AnnInfo a)
forall a. Data a => AnnInfo a -> Constr
forall a. Data a => AnnInfo a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> AnnInfo a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (AnnInfo a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (AnnInfo a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u
forall u. (forall d. Data d => d -> u) -> AnnInfo a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (AnnInfo a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (AnnInfo a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (AnnInfo a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (AnnInfo a)
$ctoConstr :: forall a. Data a => AnnInfo a -> Constr
toConstr :: AnnInfo a -> Constr
$cdataTypeOf :: forall a. Data a => AnnInfo a -> DataType
dataTypeOf :: AnnInfo a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (AnnInfo a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (AnnInfo a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
gmapT :: (forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> AnnInfo a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnInfo a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
Data, Typeable, (forall x. AnnInfo a -> Rep (AnnInfo a) x)
-> (forall x. Rep (AnnInfo a) x -> AnnInfo a)
-> Generic (AnnInfo a)
forall x. Rep (AnnInfo a) x -> AnnInfo a
forall x. AnnInfo a -> Rep (AnnInfo a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (AnnInfo a) x -> AnnInfo a
forall a x. AnnInfo a -> Rep (AnnInfo a) x
$cfrom :: forall a x. AnnInfo a -> Rep (AnnInfo a) x
from :: forall x. AnnInfo a -> Rep (AnnInfo a) x
$cto :: forall a x. Rep (AnnInfo a) x -> AnnInfo a
to :: forall x. Rep (AnnInfo a) x -> AnnInfo a
Generic, (forall a b. (a -> b) -> AnnInfo a -> AnnInfo b)
-> (forall a b. a -> AnnInfo b -> AnnInfo a) -> Functor AnnInfo
forall a b. a -> AnnInfo b -> AnnInfo a
forall a b. (a -> b) -> AnnInfo a -> AnnInfo b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> AnnInfo a -> AnnInfo b
fmap :: forall a b. (a -> b) -> AnnInfo a -> AnnInfo b
$c<$ :: forall a b. a -> AnnInfo b -> AnnInfo a
<$ :: forall a b. a -> AnnInfo b -> AnnInfo a
Functor)

data Annot t
  = AnnUse t
  | AnnDef t
  | AnnRDf t
  | AnnLoc SrcSpan
  deriving (Typeable (Annot t)
Typeable (Annot t) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Annot t -> c (Annot t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Annot t))
-> (Annot t -> Constr)
-> (Annot t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Annot t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t)))
-> ((forall b. Data b => b -> b) -> Annot t -> Annot t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Annot t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Annot t -> r)
-> (forall u. (forall d. Data d => d -> u) -> Annot t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Annot t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Annot t -> m (Annot t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Annot t -> m (Annot t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Annot t -> m (Annot t))
-> Data (Annot t)
Annot t -> Constr
Annot t -> DataType
(forall b. Data b => b -> b) -> Annot t -> Annot t
forall t. Data t => Typeable (Annot t)
forall t. Data t => Annot t -> Constr
forall t. Data t => Annot t -> DataType
forall t.
Data t =>
(forall b. Data b => b -> b) -> Annot t -> Annot t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> Annot t -> u
forall t u.
Data t =>
(forall d. Data d => d -> u) -> Annot t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Annot t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Annot t -> c (Annot t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Annot t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Annot t -> u
forall u. (forall d. Data d => d -> u) -> Annot t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Annot t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Annot t -> c (Annot t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Annot t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t))
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Annot t -> c (Annot t)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Annot t -> c (Annot t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Annot t)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Annot t)
$ctoConstr :: forall t. Data t => Annot t -> Constr
toConstr :: Annot t -> Constr
$cdataTypeOf :: forall t. Data t => Annot t -> DataType
dataTypeOf :: Annot t -> DataType
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Annot t))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Annot t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t))
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> Annot t -> Annot t
gmapT :: (forall b. Data b => b -> b) -> Annot t -> Annot t
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> Annot t -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Annot t -> [u]
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> Annot t -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Annot t -> u
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
Data, Typeable, (forall x. Annot t -> Rep (Annot t) x)
-> (forall x. Rep (Annot t) x -> Annot t) -> Generic (Annot t)
forall x. Rep (Annot t) x -> Annot t
forall x. Annot t -> Rep (Annot t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (Annot t) x -> Annot t
forall t x. Annot t -> Rep (Annot t) x
$cfrom :: forall t x. Annot t -> Rep (Annot t) x
from :: forall x. Annot t -> Rep (Annot t) x
$cto :: forall t x. Rep (Annot t) x -> Annot t
to :: forall x. Rep (Annot t) x -> Annot t
Generic, (forall a b. (a -> b) -> Annot a -> Annot b)
-> (forall a b. a -> Annot b -> Annot a) -> Functor Annot
forall a b. a -> Annot b -> Annot a
forall a b. (a -> b) -> Annot a -> Annot b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Annot a -> Annot b
fmap :: forall a b. (a -> b) -> Annot a -> Annot b
$c<$ :: forall a b. a -> Annot b -> Annot a
<$ :: forall a b. a -> Annot b -> Annot a
Functor)

instance Monoid (AnnInfo a) where
  mempty :: AnnInfo a
mempty  = HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
forall a. HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
AI HashMap SrcSpan [(Maybe Text, a)]
forall k v. HashMap k v
M.empty
  mappend :: AnnInfo a -> AnnInfo a -> AnnInfo a
mappend = AnnInfo a -> AnnInfo a -> AnnInfo a
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup (AnnInfo a) where
  AI HashMap SrcSpan [(Maybe Text, a)]
m1 <> :: AnnInfo a -> AnnInfo a -> AnnInfo a
<> AI HashMap SrcSpan [(Maybe Text, a)]
m2 = HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
forall a. HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
AI (HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a)
-> HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
forall a b. (a -> b) -> a -> b
$ ([(Maybe Text, a)] -> [(Maybe Text, a)] -> [(Maybe Text, a)])
-> HashMap SrcSpan [(Maybe Text, a)]
-> HashMap SrcSpan [(Maybe Text, a)]
-> HashMap SrcSpan [(Maybe Text, a)]
forall k v.
Eq k =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
M.unionWith [(Maybe Text, a)] -> [(Maybe Text, a)] -> [(Maybe Text, a)]
forall a. [a] -> [a] -> [a]
(++) HashMap SrcSpan [(Maybe Text, a)]
m1 HashMap SrcSpan [(Maybe Text, a)]
m2

instance NFData a => NFData (AnnInfo a)

instance NFData a => NFData (Annot a)

--------------------------------------------------------------------------------
-- | Output --------------------------------------------------------------------
--------------------------------------------------------------------------------

data Output a = O
  { forall a. Output a -> Maybe [String]
o_vars   :: Maybe [String]
  , forall a. Output a -> AnnInfo a
o_types  :: !(AnnInfo a)
  , forall a. Output a -> AnnInfo a
o_templs :: !(AnnInfo a)
  , forall a. Output a -> [SrcSpan]
o_bots   :: ![SrcSpan]
  , forall a. Output a -> ErrorResult
o_result :: ErrorResult
  } deriving (Typeable, (forall x. Output a -> Rep (Output a) x)
-> (forall x. Rep (Output a) x -> Output a) -> Generic (Output a)
forall x. Rep (Output a) x -> Output a
forall x. Output a -> Rep (Output a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Output a) x -> Output a
forall a x. Output a -> Rep (Output a) x
$cfrom :: forall a x. Output a -> Rep (Output a) x
from :: forall x. Output a -> Rep (Output a) x
$cto :: forall a x. Rep (Output a) x -> Output a
to :: forall x. Rep (Output a) x -> Output a
Generic, (forall a b. (a -> b) -> Output a -> Output b)
-> (forall a b. a -> Output b -> Output a) -> Functor Output
forall a b. a -> Output b -> Output a
forall a b. (a -> b) -> Output a -> Output b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Output a -> Output b
fmap :: forall a b. (a -> b) -> Output a -> Output b
$c<$ :: forall a b. a -> Output b -> Output a
<$ :: forall a b. a -> Output b -> Output a
Functor)

instance (F.PPrint a) => F.PPrint (Output a) where
  pprintTidy :: Tidy -> Output a -> Doc
pprintTidy Tidy
_ Output a
out = FixResult Doc -> Doc
forall a. Fixpoint a => FixResult a -> Doc
F.resultDoc (UserError -> Doc
forall a. PPrint a => a -> Doc
F.pprint (UserError -> Doc) -> ErrorResult -> FixResult Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Output a -> ErrorResult
forall a. Output a -> ErrorResult
o_result Output a
out)

emptyOutput :: Output a
emptyOutput :: forall a. Output a
emptyOutput = Maybe [String]
-> AnnInfo a -> AnnInfo a -> [SrcSpan] -> ErrorResult -> Output a
forall a.
Maybe [String]
-> AnnInfo a -> AnnInfo a -> [SrcSpan] -> ErrorResult -> Output a
O Maybe [String]
forall a. Maybe a
Nothing AnnInfo a
forall a. Monoid a => a
mempty AnnInfo a
forall a. Monoid a => a
mempty [] ErrorResult
forall a. Monoid a => a
mempty

instance Monoid (Output a) where
  mempty :: Output a
mempty  = Output a
forall a. Output a
emptyOutput
  mappend :: Output a -> Output a -> Output a
mappend = Output a -> Output a -> Output a
forall a. Semigroup a => a -> a -> a
(<>)

instance Semigroup (Output a) where
  Output a
o1 <> :: Output a -> Output a -> Output a
<> Output a
o2 = O { o_vars :: Maybe [String]
o_vars   =            [String] -> [String]
forall a. Ord a => [a] -> [a]
sortNub ([String] -> [String]) -> Maybe [String] -> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe [String] -> Maybe [String] -> Maybe [String]
forall a. Monoid a => a -> a -> a
mappend (Output a -> Maybe [String]
forall a. Output a -> Maybe [String]
o_vars   Output a
o1) (Output a -> Maybe [String]
forall a. Output a -> Maybe [String]
o_vars   Output a
o2)
               , o_types :: AnnInfo a
o_types  =                        AnnInfo a -> AnnInfo a -> AnnInfo a
forall a. Monoid a => a -> a -> a
mappend (Output a -> AnnInfo a
forall a. Output a -> AnnInfo a
o_types  Output a
o1) (Output a -> AnnInfo a
forall a. Output a -> AnnInfo a
o_types  Output a
o2)
               , o_templs :: AnnInfo a
o_templs =                        AnnInfo a -> AnnInfo a -> AnnInfo a
forall a. Monoid a => a -> a -> a
mappend (Output a -> AnnInfo a
forall a. Output a -> AnnInfo a
o_templs Output a
o1) (Output a -> AnnInfo a
forall a. Output a -> AnnInfo a
o_templs Output a
o2)
               , o_bots :: [SrcSpan]
o_bots   = (SrcSpan -> SrcSpan -> Ordering) -> [SrcSpan] -> [SrcSpan]
forall a. Eq a => (a -> a -> Ordering) -> [a] -> [a]
sortNubBy SrcSpan -> SrcSpan -> Ordering
ordSrcSpan ([SrcSpan] -> [SrcSpan]) -> [SrcSpan] -> [SrcSpan]
forall a b. (a -> b) -> a -> b
$ [SrcSpan] -> [SrcSpan] -> [SrcSpan]
forall a. Monoid a => a -> a -> a
mappend (Output a -> [SrcSpan]
forall a. Output a -> [SrcSpan]
o_bots Output a
o1)   (Output a -> [SrcSpan]
forall a. Output a -> [SrcSpan]
o_bots   Output a
o2)
               , o_result :: ErrorResult
o_result =                        ErrorResult -> ErrorResult -> ErrorResult
forall a. Monoid a => a -> a -> a
mappend (Output a -> ErrorResult
forall a. Output a -> ErrorResult
o_result Output a
o1) (Output a -> ErrorResult
forall a. Output a -> ErrorResult
o_result Output a
o2)
               }

-- Ord a 'SrcSpan' if it's meaningful to do so (i.e. we have a 'RealSrcSpan'). Otherwise we default to EQ.
ordSrcSpan :: SrcSpan -> SrcSpan -> Ordering
ordSrcSpan :: SrcSpan -> SrcSpan -> Ordering
ordSrcSpan (RealSrcSpan RealSrcSpan
r1 Maybe BufSpan
_) (RealSrcSpan RealSrcSpan
r2 Maybe BufSpan
_) = RealSrcSpan
r1 RealSrcSpan -> RealSrcSpan -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` RealSrcSpan
r2
ordSrcSpan (RealSrcSpan RealSrcSpan
_ Maybe BufSpan
_ ) SrcSpan
_                  = Ordering
GT
ordSrcSpan SrcSpan
_                  (RealSrcSpan RealSrcSpan
_ Maybe BufSpan
_ ) = Ordering
LT
ordSrcSpan SrcSpan
_                  SrcSpan
_                  = Ordering
EQ


--------------------------------------------------------------------------------
-- | KVar Profile --------------------------------------------------------------
--------------------------------------------------------------------------------

data KVKind
  = RecBindE    Var -- ^ Recursive binder      @letrec x = ...@
  | NonRecBindE Var -- ^ Non recursive binder  @let x = ...@
  | TypeInstE
  | PredInstE
  | LamE
  | CaseE       Int -- ^ Int is the number of cases
  | LetE
  | ProjectE        -- ^ Projecting out field of
  deriving ((forall x. KVKind -> Rep KVKind x)
-> (forall x. Rep KVKind x -> KVKind) -> Generic KVKind
forall x. Rep KVKind x -> KVKind
forall x. KVKind -> Rep KVKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. KVKind -> Rep KVKind x
from :: forall x. KVKind -> Rep KVKind x
$cto :: forall x. Rep KVKind x -> KVKind
to :: forall x. Rep KVKind x -> KVKind
Generic, KVKind -> KVKind -> Bool
(KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool) -> Eq KVKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: KVKind -> KVKind -> Bool
== :: KVKind -> KVKind -> Bool
$c/= :: KVKind -> KVKind -> Bool
/= :: KVKind -> KVKind -> Bool
Eq, Eq KVKind
Eq KVKind =>
(KVKind -> KVKind -> Ordering)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> KVKind)
-> (KVKind -> KVKind -> KVKind)
-> Ord KVKind
KVKind -> KVKind -> Bool
KVKind -> KVKind -> Ordering
KVKind -> KVKind -> KVKind
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: KVKind -> KVKind -> Ordering
compare :: KVKind -> KVKind -> Ordering
$c< :: KVKind -> KVKind -> Bool
< :: KVKind -> KVKind -> Bool
$c<= :: KVKind -> KVKind -> Bool
<= :: KVKind -> KVKind -> Bool
$c> :: KVKind -> KVKind -> Bool
> :: KVKind -> KVKind -> Bool
$c>= :: KVKind -> KVKind -> Bool
>= :: KVKind -> KVKind -> Bool
$cmax :: KVKind -> KVKind -> KVKind
max :: KVKind -> KVKind -> KVKind
$cmin :: KVKind -> KVKind -> KVKind
min :: KVKind -> KVKind -> KVKind
Ord, Int -> KVKind -> ShowS
[KVKind] -> ShowS
KVKind -> String
(Int -> KVKind -> ShowS)
-> (KVKind -> String) -> ([KVKind] -> ShowS) -> Show KVKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> KVKind -> ShowS
showsPrec :: Int -> KVKind -> ShowS
$cshow :: KVKind -> String
show :: KVKind -> String
$cshowList :: [KVKind] -> ShowS
showList :: [KVKind] -> ShowS
Show, Typeable KVKind
Typeable KVKind =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> KVKind -> c KVKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c KVKind)
-> (KVKind -> Constr)
-> (KVKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c KVKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind))
-> ((forall b. Data b => b -> b) -> KVKind -> KVKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> KVKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> KVKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> KVKind -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> KVKind -> m KVKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KVKind -> m KVKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KVKind -> m KVKind)
-> Data KVKind
KVKind -> Constr
KVKind -> DataType
(forall b. Data b => b -> b) -> KVKind -> KVKind
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u
forall u. (forall d. Data d => d -> u) -> KVKind -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KVKind
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KVKind -> c KVKind
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KVKind)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KVKind -> c KVKind
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KVKind -> c KVKind
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KVKind
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KVKind
$ctoConstr :: KVKind -> Constr
toConstr :: KVKind -> Constr
$cdataTypeOf :: KVKind -> DataType
dataTypeOf :: KVKind -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KVKind)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KVKind)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind)
$cgmapT :: (forall b. Data b => b -> b) -> KVKind -> KVKind
gmapT :: (forall b. Data b => b -> b) -> KVKind -> KVKind
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KVKind -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> KVKind -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
Data, Typeable)

instance Hashable KVKind

newtype KVProf = KVP (M.HashMap KVKind Int) deriving ((forall x. KVProf -> Rep KVProf x)
-> (forall x. Rep KVProf x -> KVProf) -> Generic KVProf
forall x. Rep KVProf x -> KVProf
forall x. KVProf -> Rep KVProf x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. KVProf -> Rep KVProf x
from :: forall x. KVProf -> Rep KVProf x
$cto :: forall x. Rep KVProf x -> KVProf
to :: forall x. Rep KVProf x -> KVProf
Generic)

emptyKVProf :: KVProf
emptyKVProf :: KVProf
emptyKVProf = HashMap KVKind Int -> KVProf
KVP HashMap KVKind Int
forall k v. HashMap k v
M.empty

updKVProf :: KVKind -> F.Kuts -> KVProf -> KVProf
updKVProf :: KVKind -> Kuts -> KVProf -> KVProf
updKVProf KVKind
k Kuts
kvs (KVP HashMap KVKind Int
m) = HashMap KVKind Int -> KVProf
KVP (HashMap KVKind Int -> KVProf) -> HashMap KVKind Int -> KVProf
forall a b. (a -> b) -> a -> b
$ KVKind -> Int -> HashMap KVKind Int -> HashMap KVKind Int
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
M.insert KVKind
k (Int
kn Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) HashMap KVKind Int
m
  where
    kn :: Int
kn                  = Int -> KVKind -> HashMap KVKind Int -> Int
forall k v. (Eq k, Hashable k) => v -> k -> HashMap k v -> v
M.lookupDefault Int
0 KVKind
k HashMap KVKind Int
m
    n :: Int
n                   = HashSet KVar -> Int
forall a. HashSet a -> Int
S.size (Kuts -> HashSet KVar
F.ksVars Kuts
kvs)

instance NFData KVKind

instance F.PPrint KVKind where
  pprintTidy :: Tidy -> KVKind -> Doc
pprintTidy Tidy
_ = String -> Doc
text (String -> Doc) -> (KVKind -> String) -> KVKind -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. KVKind -> String
forall a. Show a => a -> String
show

instance F.PPrint KVProf where
  pprintTidy :: Tidy -> KVProf -> Doc
pprintTidy Tidy
k (KVP HashMap KVKind Int
m) = Tidy -> [(KVKind, Int)] -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (HashMap KVKind Int -> [(KVKind, Int)]
forall k v. HashMap k v -> [(k, v)]
M.toList HashMap KVKind Int
m)

instance NFData KVProf

hole :: Expr
hole :: Expr
hole = KVar -> Subst -> Expr
F.PKVar KVar
"HOLE" Subst
forall a. Monoid a => a
mempty

isHole :: Expr -> Bool
isHole :: Expr -> Bool
isHole (F.PKVar KVar
"HOLE" Subst
_) = Bool
True
isHole Expr
_                  = Bool
False

hasHole :: F.Reftable r => r -> Bool
hasHole :: forall r. Reftable r => r -> Bool
hasHole = (Expr -> Bool) -> [Expr] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Expr -> Bool
isHole ([Expr] -> Bool) -> (r -> [Expr]) -> r -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr]
F.conjuncts (Expr -> [Expr]) -> (r -> Expr) -> r -> [Expr]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reft -> Expr
F.reftPred (Reft -> Expr) -> (r -> Reft) -> r -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Reft
forall r. Reftable r => r -> Reft
F.toReft

instance F.Symbolic DataCon where
  symbol :: DataCon -> Symbol
symbol = Var -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol (Var -> Symbol) -> (DataCon -> Var) -> DataCon -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCon -> Var
dataConWorkId

instance F.PPrint DataCon where
  pprintTidy :: Tidy -> DataCon -> Doc
pprintTidy Tidy
_ = String -> Doc
text (String -> Doc) -> (DataCon -> String) -> DataCon -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCon -> String
forall a. Outputable a => a -> String
showPpr

instance Ord TyCon where
  compare :: TyCon -> TyCon -> Ordering
compare = Symbol -> Symbol -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Symbol -> Symbol -> Ordering)
-> (TyCon -> Symbol) -> TyCon -> TyCon -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` TyCon -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol

instance Ord DataCon where
  compare :: DataCon -> DataCon -> Ordering
compare = Symbol -> Symbol -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Symbol -> Symbol -> Ordering)
-> (DataCon -> Symbol) -> DataCon -> DataCon -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` DataCon -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol

instance F.PPrint TyThing where
  pprintTidy :: Tidy -> TyThing -> Doc
pprintTidy Tidy
_ = String -> Doc
text (String -> Doc) -> (TyThing -> String) -> TyThing -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyThing -> String
forall a. Outputable a => a -> String
showPpr

instance Show DataCon where
  show :: DataCon -> String
show = DataCon -> String
forall a. PPrint a => a -> String
F.showpp

-- instance F.Symbolic TyThing where
--  symbol = tyThingSymbol

liquidBegin :: String
liquidBegin :: String
liquidBegin = [Char
'{', Char
'-', Char
'@']

liquidEnd :: String
liquidEnd :: String
liquidEnd = [Char
'@', Char
'-', Char
'}']

data MSpec ty ctor = MSpec
  { forall ty ctor. MSpec ty ctor -> HashMap Symbol [Def ty ctor]
ctorMap  :: M.HashMap Symbol [Def ty ctor]
  , forall ty ctor.
MSpec ty ctor -> HashMap LocSymbol (Measure ty ctor)
measMap  :: M.HashMap F.LocSymbol (Measure ty ctor)
  , forall ty ctor. MSpec ty ctor -> HashMap LocSymbol (Measure ty ())
cmeasMap :: M.HashMap F.LocSymbol (Measure ty ())
  , forall ty ctor. MSpec ty ctor -> [Measure ty ctor]
imeas    :: ![Measure ty ctor]
  } deriving (Typeable (MSpec ty ctor)
Typeable (MSpec ty ctor) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor))
-> (MSpec ty ctor -> Constr)
-> (MSpec ty ctor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (MSpec ty ctor)))
-> ((forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r)
-> (forall u. (forall d. Data d => d -> u) -> MSpec ty ctor -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> MSpec ty ctor -> m (MSpec ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> MSpec ty ctor -> m (MSpec ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> MSpec ty ctor -> m (MSpec ty ctor))
-> Data (MSpec ty ctor)
MSpec ty ctor -> Constr
MSpec ty ctor -> DataType
(forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u
forall u. (forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
forall ty ctor. (Data ty, Data ctor) => Typeable (MSpec ty ctor)
forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> Constr
forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> DataType
forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor
forall ty ctor u.
(Data ty, Data ctor) =>
Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u
forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
forall ty ctor r r'.
(Data ty, Data ctor) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
forall ty ctor (m :: * -> *).
(Data ty, Data ctor, Monad m) =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor)
forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor)
forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
forall ty ctor (t :: * -> * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
$cgfoldl :: forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor)
$cgunfold :: forall ty ctor (c :: * -> *).
(Data ty, Data ctor) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor)
$ctoConstr :: forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> Constr
toConstr :: MSpec ty ctor -> Constr
$cdataTypeOf :: forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> DataType
dataTypeOf :: MSpec ty ctor -> DataType
$cdataCast1 :: forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
$cdataCast2 :: forall ty ctor (t :: * -> * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
$cgmapT :: forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor
gmapT :: (forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor
$cgmapQl :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
$cgmapQr :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
$cgmapQ :: forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
$cgmapQi :: forall ty ctor u.
(Data ty, Data ctor) =>
Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u
$cgmapM :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, Monad m) =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
$cgmapMp :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
$cgmapMo :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
Data, Typeable, (forall x. MSpec ty ctor -> Rep (MSpec ty ctor) x)
-> (forall x. Rep (MSpec ty ctor) x -> MSpec ty ctor)
-> Generic (MSpec ty ctor)
forall x. Rep (MSpec ty ctor) x -> MSpec ty ctor
forall x. MSpec ty ctor -> Rep (MSpec ty ctor) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty ctor x. Rep (MSpec ty ctor) x -> MSpec ty ctor
forall ty ctor x. MSpec ty ctor -> Rep (MSpec ty ctor) x
$cfrom :: forall ty ctor x. MSpec ty ctor -> Rep (MSpec ty ctor) x
from :: forall x. MSpec ty ctor -> Rep (MSpec ty ctor) x
$cto :: forall ty ctor x. Rep (MSpec ty ctor) x -> MSpec ty ctor
to :: forall x. Rep (MSpec ty ctor) x -> MSpec ty ctor
Generic, (forall a b. (a -> b) -> MSpec ty a -> MSpec ty b)
-> (forall a b. a -> MSpec ty b -> MSpec ty a)
-> Functor (MSpec ty)
forall a b. a -> MSpec ty b -> MSpec ty a
forall a b. (a -> b) -> MSpec ty a -> MSpec ty b
forall ty a b. a -> MSpec ty b -> MSpec ty a
forall ty a b. (a -> b) -> MSpec ty a -> MSpec ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall ty a b. (a -> b) -> MSpec ty a -> MSpec ty b
fmap :: forall a b. (a -> b) -> MSpec ty a -> MSpec ty b
$c<$ :: forall ty a b. a -> MSpec ty b -> MSpec ty a
<$ :: forall a b. a -> MSpec ty b -> MSpec ty a
Functor)

instance Bifunctor MSpec   where
  first :: forall a b c. (a -> b) -> MSpec a c -> MSpec b c
first a -> b
f (MSpec HashMap Symbol [Def a c]
c HashMap LocSymbol (Measure a c)
m HashMap LocSymbol (Measure a ())
cm [Measure a c]
im) = HashMap Symbol [Def b c]
-> HashMap LocSymbol (Measure b c)
-> HashMap LocSymbol (Measure b ())
-> [Measure b c]
-> MSpec b c
forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec (([Def a c] -> [Def b c])
-> HashMap Symbol [Def a c] -> HashMap Symbol [Def b c]
forall a b. (a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Def a c -> Def b c) -> [Def a c] -> [Def b c]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Def a c -> Def b c
forall a b c. (a -> b) -> Def a c -> Def b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f)) HashMap Symbol [Def a c]
c)
                                    ((Measure a c -> Measure b c)
-> HashMap LocSymbol (Measure a c)
-> HashMap LocSymbol (Measure b c)
forall a b. (a -> b) -> HashMap LocSymbol a -> HashMap LocSymbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Measure a c -> Measure b c
forall a b c. (a -> b) -> Measure a c -> Measure b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) HashMap LocSymbol (Measure a c)
m)
                                    ((Measure a () -> Measure b ())
-> HashMap LocSymbol (Measure a ())
-> HashMap LocSymbol (Measure b ())
forall a b. (a -> b) -> HashMap LocSymbol a -> HashMap LocSymbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Measure a () -> Measure b ()
forall a b c. (a -> b) -> Measure a c -> Measure b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) HashMap LocSymbol (Measure a ())
cm)
                                    ((Measure a c -> Measure b c) -> [Measure a c] -> [Measure b c]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Measure a c -> Measure b c
forall a b c. (a -> b) -> Measure a c -> Measure b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) [Measure a c]
im)
  second :: forall b c a. (b -> c) -> MSpec a b -> MSpec a c
second                    = (b -> c) -> MSpec a b -> MSpec a c
forall a b. (a -> b) -> MSpec a a -> MSpec a b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

instance (F.PPrint t, F.PPrint a) => F.PPrint (MSpec t a) where
  pprintTidy :: Tidy -> MSpec t a -> Doc
pprintTidy Tidy
k =  [Doc] -> Doc
vcat ([Doc] -> Doc) -> (MSpec t a -> [Doc]) -> MSpec t a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((LocSymbol, Measure t a) -> Doc)
-> [(LocSymbol, Measure t a)] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Tidy -> Measure t a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (Measure t a -> Doc)
-> ((LocSymbol, Measure t a) -> Measure t a)
-> (LocSymbol, Measure t a)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LocSymbol, Measure t a) -> Measure t a
forall a b. (a, b) -> b
snd) ([(LocSymbol, Measure t a)] -> [Doc])
-> (MSpec t a -> [(LocSymbol, Measure t a)]) -> MSpec t a -> [Doc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap LocSymbol (Measure t a) -> [(LocSymbol, Measure t a)]
forall k v. HashMap k v -> [(k, v)]
M.toList (HashMap LocSymbol (Measure t a) -> [(LocSymbol, Measure t a)])
-> (MSpec t a -> HashMap LocSymbol (Measure t a))
-> MSpec t a
-> [(LocSymbol, Measure t a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MSpec t a -> HashMap LocSymbol (Measure t a)
forall ty ctor.
MSpec ty ctor -> HashMap LocSymbol (Measure ty ctor)
measMap

instance (Show ty, Show ctor, F.PPrint ctor, F.PPrint ty) => Show (MSpec ty ctor) where
  show :: MSpec ty ctor -> String
show (MSpec HashMap Symbol [Def ty ctor]
ct HashMap LocSymbol (Measure ty ctor)
m HashMap LocSymbol (Measure ty ())
cm [Measure ty ctor]
im)
    = String
"\nMSpec:\n" String -> ShowS
forall a. [a] -> [a] -> [a]
++
      String
"\nctorMap:\t "  String -> ShowS
forall a. [a] -> [a] -> [a]
++ HashMap Symbol [Def ty ctor] -> String
forall a. Show a => a -> String
show HashMap Symbol [Def ty ctor]
ct String -> ShowS
forall a. [a] -> [a] -> [a]
++
      String
"\nmeasMap:\t "  String -> ShowS
forall a. [a] -> [a] -> [a]
++ HashMap LocSymbol (Measure ty ctor) -> String
forall a. Show a => a -> String
show HashMap LocSymbol (Measure ty ctor)
m  String -> ShowS
forall a. [a] -> [a] -> [a]
++
      String
"\ncmeasMap:\t " String -> ShowS
forall a. [a] -> [a] -> [a]
++ HashMap LocSymbol (Measure ty ()) -> String
forall a. Show a => a -> String
show HashMap LocSymbol (Measure ty ())
cm String -> ShowS
forall a. [a] -> [a] -> [a]
++
      String
"\nimeas:\t "    String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Measure ty ctor] -> String
forall a. Show a => a -> String
show [Measure ty ctor]
im String -> ShowS
forall a. [a] -> [a] -> [a]
++
      String
"\n"

instance Eq ctor => Semigroup (MSpec ty ctor) where
  MSpec HashMap Symbol [Def ty ctor]
c1 HashMap LocSymbol (Measure ty ctor)
m1 HashMap LocSymbol (Measure ty ())
cm1 [Measure ty ctor]
im1 <> :: MSpec ty ctor -> MSpec ty ctor -> MSpec ty ctor
<> MSpec HashMap Symbol [Def ty ctor]
c2 HashMap LocSymbol (Measure ty ctor)
m2 HashMap LocSymbol (Measure ty ())
cm2 [Measure ty ctor]
im2
    | (LocSymbol
k1, LocSymbol
k2) : [(LocSymbol, LocSymbol)]
_ <- [(LocSymbol, LocSymbol)]
dups
      -- = panic Nothing $ err (head dups)
    = UserError -> MSpec ty ctor
forall a. UserError -> a
uError (UserError -> MSpec ty ctor) -> UserError -> MSpec ty ctor
forall a b. (a -> b) -> a -> b
$ LocSymbol -> LocSymbol -> UserError
forall {a} {t}. PPrint a => Located a -> Located a -> TError t
err LocSymbol
k1 LocSymbol
k2
    | Bool
otherwise
    = HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec (([Def ty ctor] -> [Def ty ctor] -> [Def ty ctor])
-> HashMap Symbol [Def ty ctor]
-> HashMap Symbol [Def ty ctor]
-> HashMap Symbol [Def ty ctor]
forall k v.
Eq k =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
M.unionWith [Def ty ctor] -> [Def ty ctor] -> [Def ty ctor]
forall a. [a] -> [a] -> [a]
(++) HashMap Symbol [Def ty ctor]
c1 HashMap Symbol [Def ty ctor]
c2) (HashMap LocSymbol (Measure ty ctor)
m1 HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ctor)
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
`M.union` HashMap LocSymbol (Measure ty ctor)
m2) (HashMap LocSymbol (Measure ty ())
cm1 HashMap LocSymbol (Measure ty ())
-> HashMap LocSymbol (Measure ty ())
-> HashMap LocSymbol (Measure ty ())
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
`M.union` HashMap LocSymbol (Measure ty ())
cm2) ([Measure ty ctor]
im1 [Measure ty ctor] -> [Measure ty ctor] -> [Measure ty ctor]
forall a. [a] -> [a] -> [a]
++ [Measure ty ctor]
im2)
    where
      dups :: [(LocSymbol, LocSymbol)]
dups = [(LocSymbol
k1, LocSymbol
k2) | LocSymbol
k1 <- HashMap LocSymbol (Measure ty ctor) -> [LocSymbol]
forall k v. HashMap k v -> [k]
M.keys HashMap LocSymbol (Measure ty ctor)
m1 , LocSymbol
k2 <- HashMap LocSymbol (Measure ty ctor) -> [LocSymbol]
forall k v. HashMap k v -> [k]
M.keys HashMap LocSymbol (Measure ty ctor)
m2, LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
k1 Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
k2]
      err :: Located a -> Located a -> TError t
err Located a
k1 Located a
k2 = SrcSpan -> Doc -> [SrcSpan] -> TError t
forall t. SrcSpan -> Doc -> [SrcSpan] -> TError t
ErrDupMeas (Located a -> SrcSpan
forall a. Loc a => a -> SrcSpan
fSrcSpan Located a
k1) (a -> Doc
forall a. PPrint a => a -> Doc
F.pprint (Located a -> a
forall a. Located a -> a
F.val Located a
k1)) (Located a -> SrcSpan
forall a. Loc a => a -> SrcSpan
fSrcSpan (Located a -> SrcSpan) -> [Located a] -> [SrcSpan]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Located a
k1, Located a
k2])


instance Eq ctor => Monoid (MSpec ty ctor) where
  mempty :: MSpec ty ctor
mempty = HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec HashMap Symbol [Def ty ctor]
forall k v. HashMap k v
M.empty HashMap LocSymbol (Measure ty ctor)
forall k v. HashMap k v
M.empty HashMap LocSymbol (Measure ty ())
forall k v. HashMap k v
M.empty []
  mappend :: MSpec ty ctor -> MSpec ty ctor -> MSpec ty ctor
mappend = MSpec ty ctor -> MSpec ty ctor -> MSpec ty ctor
forall a. Semigroup a => a -> a -> a
(<>)



--------------------------------------------------------------------------------
-- Nasty PP stuff
--------------------------------------------------------------------------------

instance F.PPrint BTyVar where
  pprintTidy :: Tidy -> BTyVar -> Doc
pprintTidy Tidy
_ (BTV Symbol
α) = String -> Doc
text (Symbol -> String
F.symbolString Symbol
α)

instance F.PPrint RTyVar where
  pprintTidy :: Tidy -> RTyVar -> Doc
pprintTidy Tidy
k (RTV Var
α)
   | PPEnv -> Bool
ppTyVar PPEnv
ppEnv  = Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (Var -> Symbol
forall a. Symbolic a => a -> Symbol
F.symbol Var
α) -- shows full tyvar
   | Bool
otherwise      = Var -> Doc
ppr_tyvar_short Var
α           -- drops the unique-suffix
   where
     ppr_tyvar_short :: TyVar -> Doc
     ppr_tyvar_short :: Var -> Doc
ppr_tyvar_short = String -> Doc
text (String -> Doc) -> (Var -> String) -> Var -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Var -> String
forall a. Outputable a => a -> String
showPpr

instance (F.PPrint r, F.Reftable r, F.PPrint t, F.PPrint (RType c tv r)) => F.PPrint (Ref t (RType c tv r)) where
  pprintTidy :: Tidy -> Ref t (RType c tv r) -> Doc
pprintTidy Tidy
k (RProp [(Symbol, t)]
ss RType c tv r
s) = Tidy -> [Symbol] -> Doc
ppRefArgs Tidy
k ((Symbol, t) -> Symbol
forall a b. (a, b) -> a
fst ((Symbol, t) -> Symbol) -> [(Symbol, t)] -> [Symbol]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, t)]
ss) Doc -> Doc -> Doc
<+> Tidy -> RType c tv r -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k RType c tv r
s

ppRefArgs :: F.Tidy -> [Symbol] -> Doc
ppRefArgs :: Tidy -> [Symbol] -> Doc
ppRefArgs Tidy
_ [] = Doc
empty
ppRefArgs Tidy
k [Symbol]
ss = String -> Doc
text String
"\\" Doc -> Doc -> Doc
<-> [Doc] -> Doc
hsep (Tidy -> Symbol -> Doc
forall a. (Eq a, IsString a, PPrint a) => Tidy -> a -> Doc
ppRefSym Tidy
k (Symbol -> Doc) -> [Symbol] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Symbol]
ss [Symbol] -> [Symbol] -> [Symbol]
forall a. [a] -> [a] -> [a]
++ [Maybe SubcId -> Symbol
F.vv Maybe SubcId
forall a. Maybe a
Nothing]) Doc -> Doc -> Doc
<+> Doc
"->"

ppRefSym :: (Eq a, IsString a, F.PPrint a) => F.Tidy -> a -> Doc
ppRefSym :: forall a. (Eq a, IsString a, PPrint a) => Tidy -> a -> Doc
ppRefSym Tidy
_ a
"" = String -> Doc
text String
"_"
ppRefSym Tidy
k a
s  = Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
s