{-# 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.Types.Generics
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. 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
$cto :: forall x. Rep RFInfo x -> RFInfo
$cfrom :: forall x. RFInfo -> Rep RFInfo x
Generic, Typeable RFInfo
RFInfo -> DataType
RFInfo -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RFInfo -> m RFInfo
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RFInfo -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RFInfo -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> RFInfo -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RFInfo -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RFInfo -> r
gmapT :: (forall b. Data b => b -> b) -> RFInfo -> RFInfo
$cgmapT :: (forall b. Data b => b -> b) -> RFInfo -> RFInfo
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RFInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RFInfo)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RFInfo)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RFInfo)
dataTypeOf :: RFInfo -> DataType
$cdataTypeOf :: RFInfo -> DataType
toConstr :: RFInfo -> Constr
$ctoConstr :: RFInfo -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RFInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RFInfo
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RFInfo -> c RFInfo
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RFInfo -> c RFInfo
Data, Typeable, Int -> RFInfo -> ShowS
[RFInfo] -> ShowS
RFInfo -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RFInfo] -> ShowS
$cshowList :: [RFInfo] -> ShowS
show :: RFInfo -> [Char]
$cshow :: RFInfo -> [Char]
showsPrec :: Int -> RFInfo -> ShowS
$cshowsPrec :: Int -> RFInfo -> ShowS
Show, RFInfo -> RFInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RFInfo -> RFInfo -> Bool
$c/= :: RFInfo -> RFInfo -> Bool
== :: RFInfo -> RFInfo -> Bool
$c== :: RFInfo -> RFInfo -> Bool
Eq)

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

classRFInfo :: Bool -> RFInfo
classRFInfo :: Bool -> RFInfo
classRFInfo Bool
b = Maybe Bool -> RFInfo
RFInfo forall a b. (a -> b) -> a -> b
$ 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 = forall c tv r. RTypeRep c tv r -> RType c tv r
fromRTypeRep 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_res :: forall c tv r. RTypeRep c tv r -> RType c tv r
ty_args :: forall c tv r. RTypeRep c tv r -> [RType c tv r]
ty_refts :: forall c tv r. RTypeRep c tv r -> [r]
ty_info :: forall c tv r. RTypeRep c tv r -> [RFInfo]
ty_binds :: forall c tv r. RTypeRep c tv r -> [Symbol]
ty_preds :: forall c tv r. RTypeRep c tv r -> [PVar (RType c tv ())]
ty_vars :: forall c tv r. RTypeRep c tv r -> [(RTVar tv (RType c tv ()), r)]
ty_res :: RType c tv r
ty_args :: [RType c tv r]
ty_refts :: [r]
ty_info :: [RFInfo]
ty_binds :: [Symbol]
ty_preds :: [PVar (RType c tv ())]
ty_vars :: [(RTVar tv (RType c tv ()), r)]
..} -> RTypeRep c tv r
trep{ty_info :: [RFInfo]
ty_info = forall a b. (a -> b) -> [a] -> [b]
map (\RFInfo
i -> RFInfo
i{permitTC :: Maybe Bool
permitTC = forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
b}) [RFInfo]
ty_info}) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                    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 forall a b. (a -> b) -> a -> b
$ 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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [PPEnv] -> ShowS
$cshowList :: [PPEnv] -> ShowS
show :: PPEnv -> [Char]
$cshow :: PPEnv -> [Char]
showsPrec :: Int -> PPEnv -> ShowS
$cshowsPrec :: Int -> PPEnv -> ShowS
Show)

ppEnv :: PPEnv
ppEnv :: PPEnv
ppEnv = PPEnv
ppEnvDef
          { ppPs :: Bool
ppPs    = Bool
True }
          { ppDebug :: Bool
ppDebug = Bool
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 :: Bool
ppShort = Bool
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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [LogicMap] -> ShowS
$cshowList :: [LogicMap] -> ShowS
show :: LogicMap -> [Char]
$cshow :: LogicMap -> [Char]
showsPrec :: Int -> LogicMap -> ShowS
$cshowsPrec :: Int -> LogicMap -> ShowS
Show)

instance Monoid LogicMap where
  mempty :: LogicMap
mempty  = HashMap Symbol LMap -> HashMap Var (Maybe Symbol) -> LogicMap
LM forall k v. HashMap k v
M.empty forall k v. HashMap k v
M.empty
  mappend :: LogicMap -> LogicMap -> LogicMap
mappend = 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 (forall k v.
(Eq k, Hashable k) =>
HashMap k v -> HashMap k v -> HashMap k v
M.union HashMap Symbol LMap
x1 HashMap Symbol LMap
y1) (forall k v.
(Eq k, Hashable 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 -> [Char]
show (LMap LocSymbol
x [Symbol]
xs Expr
e) = forall a. Show a => a -> [Char]
show LocSymbol
x forall a. [a] -> [a] -> [a]
++ [Char]
" " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show [Symbol]
xs forall a. [a] -> [a] -> [a]
++ [Char]
"\t |-> \t" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Expr
e

toLogicMap :: [(F.LocSymbol, [Symbol], Expr)] -> LogicMap
toLogicMap :: [(LocSymbol, [Symbol], Expr)] -> LogicMap
toLogicMap [(LocSymbol, [Symbol], Expr)]
ls = forall a. Monoid a => a
mempty {lmSymDefs :: HashMap Symbol LMap
lmSymDefs = forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
M.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (LocSymbol, [Symbol], Expr) -> (Symbol, LMap)
toLMap [(LocSymbol, [Symbol], Expr)]
ls}
  where
    toLMap :: (LocSymbol, [Symbol], Expr) -> (Symbol, LMap)
toLMap (LocSymbol
x, [Symbol]
ys, Expr
e) = (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) <- forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup (forall a. Located a -> a
F.val LocSymbol
f) (LogicMap -> HashMap Symbol LMap
lmSymDefs LogicMap
lmap)
  , forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
xs forall a. Eq a => a -> a -> Bool
== forall (t :: * -> *) a. Foldable t => t a -> Int
length [Expr]
es
  = forall a. Subable a => Subst -> a -> a
F.subst ([(Symbol, Expr)] -> Subst
F.mkSubst forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip [Symbol]
xs [Expr]
es) Expr
e
  | Just (LMap LocSymbol
_ [Symbol]
xs Expr
e) <- forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup (forall a. Located a -> a
F.val LocSymbol
f) (LogicMap -> HashMap Symbol LMap
lmSymDefs LogicMap
lmap)
  , Expr -> Bool
isApp Expr
e
  = forall a. Subable a => Subst -> a -> a
F.subst ([(Symbol, Expr)] -> Subst
F.mkSubst forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip [Symbol]
xs [Expr]
es) forall a b. (a -> b) -> a -> b
$ Expr -> Int -> Expr
dropApp Expr
e (forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
xs forall a. Num a => a -> a -> a
- 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 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
iforall a. Num a => a -> a -> a
-Int
1)
dropApp Expr
_ Int
_          = forall a. (?callStack::CallStack) => [Char] -> a
errorstar [Char]
"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 -> [RPVar]
tcpFreePredTy   :: ![PVar RSort]
  , TyConP -> VarianceInfo
tcpVarianceTs   :: !VarianceInfo
  , TyConP -> VarianceInfo
tcpVariancePs   :: !VarianceInfo
  , TyConP -> Maybe SizeFun
tcpSizeFun      :: !(Maybe SizeFun)
  } deriving (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
$cto :: forall x. Rep TyConP x -> TyConP
$cfrom :: forall x. TyConP -> Rep TyConP x
Generic, Typeable TyConP
TyConP -> DataType
TyConP -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConP -> m TyConP
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TyConP -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TyConP -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyConP -> r
gmapT :: (forall b. Data b => b -> b) -> TyConP -> TyConP
$cgmapT :: (forall b. Data b => b -> b) -> TyConP -> TyConP
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConP)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConP)
dataTypeOf :: TyConP -> DataType
$cdataTypeOf :: TyConP -> DataType
toConstr :: TyConP -> Constr
$ctoConstr :: TyConP -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConP
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConP
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConP -> c TyConP
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConP -> c 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 -> [RPVar]
dcpFreePred   :: ![PVar RSort]           -- ^ Abstract Refinement parameters
  , DataConP -> [RType RTyCon RTyVar RReft]
dcpTyConstrs  :: ![SpecType]             -- ^ ? Class constraints (via `dataConStupidTheta`)
  , DataConP -> [(Symbol, RType RTyCon RTyVar RReft)]
dcpTyArgs     :: ![(Symbol, SpecType)]   -- ^ Value parameters
  , DataConP -> RType RTyCon RTyVar RReft
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. 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
$cto :: forall x. Rep DataConP x -> DataConP
$cfrom :: forall x. DataConP -> Rep DataConP x
Generic, Typeable DataConP
DataConP -> DataType
DataConP -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConP -> m DataConP
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataConP -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataConP -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConP -> r
gmapT :: (forall b. Data b => b -> b) -> DataConP -> DataConP
$cgmapT :: (forall b. Data b => b -> b) -> DataConP -> DataConP
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConP)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConP)
dataTypeOf :: DataConP -> DataType
$cdataTypeOf :: DataConP -> DataType
toConstr :: DataConP -> Constr
$ctoConstr :: DataConP -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConP
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConP
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConP -> c DataConP
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConP -> c 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 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
$cto :: forall t x. Rep (PVar t) x -> PVar t
$cfrom :: forall t x. PVar t -> Rep (PVar t) x
Generic, PVar t -> DataType
PVar t -> Constr
forall {t}. Data t => Typeable (PVar t)
forall t. Data t => PVar t -> DataType
forall t. Data t => PVar t -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> PVar t -> [u]
$cgmapQ :: forall t u. Data t => (forall d. Data d => d -> u) -> PVar t -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
gmapT :: (forall b. Data b => b -> b) -> PVar t -> PVar t
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> PVar t -> PVar t
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
dataTypeOf :: PVar t -> DataType
$cdataTypeOf :: forall t. Data t => PVar t -> DataType
toConstr :: PVar t -> Constr
$ctoConstr :: forall t. Data t => PVar t -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> 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)
Data, Typeable, Int -> PVar t -> ShowS
forall t. Show t => Int -> PVar t -> ShowS
forall t. Show t => [PVar t] -> ShowS
forall t. Show t => PVar t -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [PVar t] -> ShowS
$cshowList :: forall t. Show t => [PVar t] -> ShowS
show :: PVar t -> [Char]
$cshow :: forall t. Show t => PVar t -> [Char]
showsPrec :: Int -> PVar t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> PVar t -> ShowS
Show, 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
<$ :: forall a b. a -> PVar b -> PVar a
$c<$ :: forall a b. a -> PVar b -> PVar a
fmap :: forall a b. (a -> b) -> PVar a -> PVar b
$cfmap :: forall a b. (a -> b) -> PVar a -> PVar b
Functor)

instance Eq (PVar t) where
  PVar t
pv == :: PVar t -> PVar t -> Bool
== PVar t
pv' = forall t. PVar t -> Symbol
pname PVar t
pv forall a. Eq a => a -> a -> Bool
== 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)]
_) = 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)]
_) = 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 forall t. PVar t -> PVKind t
ptype PVar t
p of
             PVProp t
t -> t
t
             PVKind t
PVHProp  -> forall a. Maybe SrcSpan -> [Char] -> a
panic forall a. Maybe a
Nothing [Char]
"pvType on HProp-PVar"

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

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

instance Semigroup Predicate where
  Predicate
p <> :: Predicate -> Predicate -> Predicate
<> Predicate
p' = 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' = forall r. r -> Predicate -> UReft r
MkUReft (a
x forall a. Semigroup a => a -> a -> a
<> a
x') (Predicate
y forall a. Semigroup a => a -> a -> a
<> Predicate
y')

instance (Monoid a) => Monoid (UReft a) where
  mempty :: UReft a
mempty  = forall r. r -> Predicate -> UReft r
MkUReft forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty
  mappend :: UReft a -> UReft a -> UReft a
mappend = 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 (forall a. Eq a => [a] -> [a]
nub forall a b. (a -> b) -> a -> b
$ 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) <- forall t. PVar t -> [(t, Symbol, Expr)]
pargs UsedPVar
pv, Symbol
x forall a. Eq a => a -> a -> Bool
/= Symbol
y ]
  subst :: Subst -> UsedPVar -> UsedPVar
subst Subst
s UsedPVar
pv      = UsedPVar
pv { pargs :: [((), Symbol, Expr)]
pargs = forall t t3 t1 t2. (t -> t3) -> (t1, t2, t) -> (t1, t2, t3)
mapThd3 (forall a. Subable a => Subst -> a -> a
F.subst Subst
s)  forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall t. PVar t -> [(t, Symbol, Expr)]
pargs UsedPVar
pv }
  substf :: (Symbol -> Expr) -> UsedPVar -> UsedPVar
substf Symbol -> Expr
f UsedPVar
pv     = UsedPVar
pv { pargs :: [((), Symbol, Expr)]
pargs = forall t t3 t1 t2. (t -> t3) -> (t1, t2, t) -> (t1, t2, t3)
mapThd3 (forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall t. PVar t -> [(t, Symbol, Expr)]
pargs UsedPVar
pv }
  substa :: (Symbol -> Symbol) -> UsedPVar -> UsedPVar
substa Symbol -> Symbol
f UsedPVar
pv     = UsedPVar
pv { pargs :: [((), Symbol, Expr)]
pargs = forall t t3 t1 t2. (t -> t3) -> (t1, t2, t) -> (t1, t2, t3)
mapThd3 (forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall t. PVar t -> [(t, Symbol, Expr)]
pargs UsedPVar
pv }


instance F.Subable Predicate where
  syms :: Predicate -> [Symbol]
syms     (Pr [UsedPVar]
pvs) = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a. Subable a => a -> [Symbol]
F.syms   [UsedPVar]
pvs
  subst :: Subst -> Predicate -> Predicate
subst  Subst
s (Pr [UsedPVar]
pvs) = [UsedPVar] -> Predicate
Pr (forall a. Subable a => Subst -> a -> a
F.subst Subst
s  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 (forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f 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 (forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelExpr -> RelExpr -> Bool
$c/= :: RelExpr -> RelExpr -> Bool
== :: RelExpr -> RelExpr -> Bool
$c== :: RelExpr -> RelExpr -> Bool
Eq, Int -> RelExpr -> ShowS
[RelExpr] -> ShowS
RelExpr -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RelExpr] -> ShowS
$cshowList :: [RelExpr] -> ShowS
show :: RelExpr -> [Char]
$cshow :: RelExpr -> [Char]
showsPrec :: Int -> RelExpr -> ShowS
$cshowsPrec :: Int -> RelExpr -> ShowS
Show, Typeable RelExpr
RelExpr -> DataType
RelExpr -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RelExpr -> m RelExpr
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RelExpr -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RelExpr -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> RelExpr -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RelExpr -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RelExpr -> r
gmapT :: (forall b. Data b => b -> b) -> RelExpr -> RelExpr
$cgmapT :: (forall b. Data b => b -> b) -> RelExpr -> RelExpr
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelExpr)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RelExpr)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelExpr)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RelExpr)
dataTypeOf :: RelExpr -> DataType
$cdataTypeOf :: RelExpr -> DataType
toConstr :: RelExpr -> Constr
$ctoConstr :: RelExpr -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelExpr
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RelExpr
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelExpr -> c RelExpr
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RelExpr -> c RelExpr
Data, 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
$cto :: forall x. Rep RelExpr x -> RelExpr
$cfrom :: forall x. RelExpr -> Rep RelExpr x
Generic)

instance B.Binary RelExpr

instance F.PPrint RelExpr where
  pprintTidy :: Tidy -> RelExpr -> Doc
pprintTidy Tidy
k (ERBasic Expr
e)       = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e
  pprintTidy Tidy
k (ERChecked Expr
e RelExpr
r)   = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e Doc -> Doc -> Doc
<+> Doc
"!=>" Doc -> Doc -> Doc
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k RelExpr
r
  pprintTidy Tidy
k (ERUnChecked Expr
e RelExpr
r) = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e Doc -> Doc -> Doc
<+> Doc
":=>" Doc -> Doc -> 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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [BTyVar] -> ShowS
$cshowList :: [BTyVar] -> ShowS
show :: BTyVar -> [Char]
$cshow :: BTyVar -> [Char]
showsPrec :: Int -> BTyVar -> ShowS
$cshowsPrec :: Int -> BTyVar -> ShowS
Show, 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
$cto :: forall x. Rep BTyVar x -> BTyVar
$cfrom :: forall x. BTyVar -> Rep BTyVar x
Generic, Typeable BTyVar
BTyVar -> DataType
BTyVar -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyVar -> m BTyVar
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> BTyVar -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BTyVar -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyVar -> r
gmapT :: (forall b. Data b => b -> b) -> BTyVar -> BTyVar
$cgmapT :: (forall b. Data b => b -> b) -> BTyVar -> BTyVar
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyVar)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyVar)
dataTypeOf :: BTyVar -> DataType
$cdataTypeOf :: BTyVar -> DataType
toConstr :: BTyVar -> Constr
$ctoConstr :: BTyVar -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyVar
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyVar
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyVar -> c BTyVar
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyVar -> c BTyVar
Data, Typeable)

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

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

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

instance IsString BTyVar where
  fromString :: [Char] -> BTyVar
fromString = Symbol -> BTyVar
BTV forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsString a => [Char] -> 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) = 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. 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
$cto :: forall x. Rep BTyCon x -> BTyCon
$cfrom :: forall x. BTyCon -> Rep BTyCon x
Generic, Typeable BTyCon
BTyCon -> DataType
BTyCon -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BTyCon -> m BTyCon
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> BTyCon -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BTyCon -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BTyCon -> r
gmapT :: (forall b. Data b => b -> b) -> BTyCon -> BTyCon
$cgmapT :: (forall b. Data b => b -> b) -> BTyCon -> BTyCon
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyCon)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BTyCon)
dataTypeOf :: BTyCon -> DataType
$cdataTypeOf :: BTyCon -> DataType
toConstr :: BTyCon -> Constr
$ctoConstr :: BTyCon -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyCon
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BTyCon
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyCon -> c BTyCon
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyCon -> c BTyCon
Data, Typeable)
  deriving Eq BTyCon
Int -> BTyCon -> Int
BTyCon -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: BTyCon -> Int
$chash :: BTyCon -> Int
hashWithSalt :: Int -> BTyCon -> Int
$chashWithSalt :: Int -> BTyCon -> Int
Hashable via Generically BTyCon

instance B.Binary BTyCon

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

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

instance F.Symbolic BTyCon where
  symbol :: BTyCon -> Symbol
symbol = forall a. Located a -> a
F.val 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 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 -> [RPVar]
rTyConPVs     = RTyCon -> [RPVar]
rtc_pvars

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

isPropPV :: PVar t -> Bool
isPropPV :: forall t. PVar t -> Bool
isPropPV      = forall a. PVKind a -> Bool
isProp forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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
_) = 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
_) = 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
_) = 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 [] [] 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. 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
$cto :: forall x. Rep TyConInfo x -> TyConInfo
$cfrom :: forall x. TyConInfo -> Rep TyConInfo x
Generic, Typeable TyConInfo
TyConInfo -> DataType
TyConInfo -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TyConInfo -> r
gmapT :: (forall b. Data b => b -> b) -> TyConInfo -> TyConInfo
$cgmapT :: (forall b. Data b => b -> b) -> TyConInfo -> TyConInfo
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConInfo)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TyConInfo)
dataTypeOf :: TyConInfo -> DataType
$cdataTypeOf :: TyConInfo -> DataType
toConstr :: TyConInfo -> Constr
$ctoConstr :: TyConInfo -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TyConInfo
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConInfo -> c TyConInfo
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConInfo -> c TyConInfo
Data, Typeable)

instance NFData TyConInfo

instance Show TyConInfo where
  show :: TyConInfo -> [Char]
show (TyConInfo VarianceInfo
x VarianceInfo
y Maybe SizeFun
_) = forall a. Show a => a -> [Char]
show VarianceInfo
x forall a. [a] -> [a] -> [a]
++ [Char]
"\n" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
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 -> [Char]
show (RTVar tv
t RTVInfo (RType c tv ())
_) = forall a. Show a => a -> [Char]
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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall c tv r.
(Eq tv, Eq r, Eq c) =>
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 r, Eq c) =>
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 r, Eq c) =>
RType c tv r -> RType c tv r -> Bool
Eq, 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
$cto :: forall c tv r x. Rep (RType c tv r) x -> RType c tv r
$cfrom :: forall c tv r x. RType c tv r -> Rep (RType c tv r) x
Generic, RType c tv r -> DataType
RType c tv r -> Constr
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 {c} {tv} {r}.
(Data c, Data tv, Data r) =>
Typeable (RType c tv r)
forall c tv r.
(Data c, Data tv, Data r) =>
RType c tv r -> DataType
forall c tv r. (Data c, Data tv, Data r) => RType c tv r -> Constr
forall c tv r.
(Data c, Data tv, Data r) =>
(forall b. Data b => b -> b) -> RType c tv r -> RType c tv r
forall c tv r u.
(Data c, Data tv, Data r) =>
Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
forall c tv r u.
(Data c, Data tv, Data r) =>
(forall d. Data d => d -> u) -> RType c tv r -> [u]
forall c tv r r r'.
(Data c, Data tv, Data r) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall c tv r r r'.
(Data c, Data tv, Data r) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall c tv r (m :: * -> *).
(Data c, Data tv, 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 c, Data tv, 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 c, Data tv, 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 c, Data tv, 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 c, Data tv, Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
forall c tv r (t :: * -> * -> *) (c :: * -> *).
(Data c, Data tv, Data r, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (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)
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)
gmapMo :: 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 c, Data tv, 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)
$cgmapMp :: forall c tv r (m :: * -> *).
(Data c, Data tv, Data r, MonadPlus 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)
$cgmapM :: forall c tv r (m :: * -> *).
(Data c, Data tv, Data r, Monad m) =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
$cgmapQi :: forall c tv r u.
(Data c, Data tv, Data r) =>
Int -> (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]
$cgmapQ :: forall c tv r u.
(Data c, Data tv, Data r) =>
(forall d. Data d => d -> u) -> RType c tv r -> [u]
gmapQr :: 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 c, Data tv, 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
$cgmapQl :: forall c tv r r r'.
(Data c, Data tv, Data r) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
gmapT :: (forall b. Data b => b -> b) -> RType c tv r -> RType c tv r
$cgmapT :: forall c tv r.
(Data c, Data tv, Data r) =>
(forall b. Data b => b -> b) -> RType c tv r -> 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))
$cdataCast2 :: forall c tv r (t :: * -> * -> *) (c :: * -> *).
(Data c, Data tv, Data r, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
$cdataCast1 :: forall c tv r (t :: * -> *) (c :: * -> *).
(Data c, Data tv, Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
dataTypeOf :: RType c tv r -> DataType
$cdataTypeOf :: forall c tv r.
(Data c, Data tv, Data r) =>
RType c tv r -> DataType
toConstr :: RType c tv r -> Constr
$ctoConstr :: forall c tv r. (Data c, Data tv, Data r) => RType c tv r -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
$cgunfold :: forall c tv r (c :: * -> *).
(Data c, Data tv, Data r) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
$cgfoldl :: forall c tv r (c :: * -> *).
(Data c, Data tv, 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)
Data, Typeable, 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
<$ :: forall a b. a -> RType c tv b -> RType c tv a
$c<$ :: forall c tv a b. a -> RType c tv b -> RType c tv a
fmap :: forall a b. (a -> b) -> RType c tv a -> RType c tv b
$cfmap :: forall c tv a b. (a -> b) -> RType c tv a -> RType c tv b
Functor)
  deriving 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
hash :: RType c tv r -> Int
$chash :: forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
RType c tv r -> Int
hashWithSalt :: Int -> RType c tv r -> Int
$chashWithSalt :: forall c tv r.
(Hashable tv, Hashable r, Hashable c) =>
Int -> 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 = forall tv s. tv -> RTVInfo s -> RTVar tv s
RTVar tv
a (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 = forall tv s. RTVar tv s -> tv
ty_var_value RTVar tv s
t1 forall a. Eq a => a -> a -> Bool
== 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 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
$cto :: forall tv s x. Rep (RTVar tv s) x -> RTVar tv s
$cfrom :: forall tv s x. RTVar tv s -> Rep (RTVar tv s) x
Generic, RTVar tv s -> DataType
RTVar tv s -> Constr
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 {tv} {s}. (Data tv, Data s) => Typeable (RTVar tv s)
forall tv s. (Data tv, Data s) => RTVar tv s -> DataType
forall tv s. (Data tv, Data s) => RTVar tv s -> Constr
forall tv s.
(Data tv, Data s) =>
(forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s
forall tv s u.
(Data tv, Data s) =>
Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
forall tv s u.
(Data tv, Data s) =>
(forall d. Data d => d -> u) -> RTVar tv s -> [u]
forall tv s r r'.
(Data tv, Data s) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall tv s r r'.
(Data tv, Data s) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall tv s (m :: * -> *).
(Data tv, Data s, Monad m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall tv s (m :: * -> *).
(Data tv, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall tv s (c :: * -> *).
(Data tv, Data s) =>
(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 tv, Data s) =>
(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 tv, Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
forall tv s (t :: * -> * -> *) (c :: * -> *).
(Data tv, Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (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)
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 e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
$cgmapMo :: forall tv s (m :: * -> *).
(Data tv, Data s, 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)
$cgmapMp :: forall tv s (m :: * -> *).
(Data tv, Data s, MonadPlus 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)
$cgmapM :: forall tv s (m :: * -> *).
(Data tv, Data s, Monad m) =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
$cgmapQi :: forall tv s u.
(Data tv, Data s) =>
Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTVar tv s -> [u]
$cgmapQ :: forall tv s u.
(Data tv, Data s) =>
(forall d. Data d => d -> u) -> RTVar tv s -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
$cgmapQr :: forall tv s r r'.
(Data tv, Data s) =>
(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
$cgmapQl :: forall tv s r r'.
(Data tv, Data s) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
gmapT :: (forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s
$cgmapT :: forall tv s.
(Data tv, Data s) =>
(forall b. Data b => b -> b) -> RTVar tv s -> 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))
$cdataCast2 :: forall tv s (t :: * -> * -> *) (c :: * -> *).
(Data tv, Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
$cdataCast1 :: forall tv s (t :: * -> *) (c :: * -> *).
(Data tv, Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
dataTypeOf :: RTVar tv s -> DataType
$cdataTypeOf :: forall tv s. (Data tv, Data s) => RTVar tv s -> DataType
toConstr :: RTVar tv s -> Constr
$ctoConstr :: forall tv s. (Data tv, Data s) => RTVar tv s -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
$cgunfold :: forall tv s (c :: * -> *).
(Data tv, Data s) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
$cgfoldl :: forall tv s (c :: * -> *).
(Data tv, Data s) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s)
Data, Typeable)
    deriving 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
hash :: RTVar tv s -> Int
$chash :: forall tv s. (Hashable tv, Hashable s) => RTVar tv s -> Int
hashWithSalt :: Int -> RTVar tv s -> Int
$chashWithSalt :: forall tv s. (Hashable tv, Hashable s) => Int -> 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 :: tv2
ty_var_value = tv1 -> tv2
f forall a b. (a -> b) -> a -> b
$ forall tv s. RTVar tv s -> tv
ty_var_value RTVar tv1 s
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 :: RTVInfo s2
ty_var_info = forall s. Bool -> RTVInfo s
RTVNoInfo Bool
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 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
$cto :: forall s x. Rep (RTVInfo s) x -> RTVInfo s
$cfrom :: forall s x. RTVInfo s -> Rep (RTVInfo s) x
Generic, RTVInfo s -> DataType
RTVInfo s -> Constr
forall {s}. Data s => Typeable (RTVInfo s)
forall s. Data s => RTVInfo s -> DataType
forall s. Data s => RTVInfo s -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
$cgmapM :: forall s (m :: * -> *).
(Data s, Monad m) =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTVInfo s -> [u]
$cgmapQ :: forall s u.
Data s =>
(forall d. Data d => d -> u) -> RTVInfo s -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
$cgmapQl :: forall s r r'.
Data s =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
gmapT :: (forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
$cgmapT :: forall s.
Data s =>
(forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
$cdataCast1 :: forall s (t :: * -> *) (c :: * -> *).
(Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
dataTypeOf :: RTVInfo s -> DataType
$cdataTypeOf :: forall s. Data s => RTVInfo s -> DataType
toConstr :: RTVInfo s -> Constr
$ctoConstr :: forall s. Data s => RTVInfo s -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> 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)
Data, Typeable, 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
<$ :: forall a b. a -> RTVInfo b -> RTVInfo a
$c<$ :: forall a b. a -> RTVInfo b -> RTVInfo a
fmap :: forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
$cfmap :: forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
Functor, RTVInfo s -> RTVInfo s -> Bool
forall s. Eq s => RTVInfo s -> RTVInfo s -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RTVInfo s -> RTVInfo s -> Bool
$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
Eq)
              deriving 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
hash :: RTVInfo s -> Int
$chash :: forall s. Hashable s => RTVInfo s -> Int
hashWithSalt :: Int -> RTVInfo s -> Int
$chashWithSalt :: forall s. Hashable s => Int -> 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 = forall tv s. tv -> RTVInfo s -> RTVar tv s
RTVar tv
a (RTVInfo a
i{rtv_is_pol :: Bool
rtv_is_pol = Bool
b})

rTVarToBind :: RTVar RTyVar s  -> Maybe (Symbol, s)
rTVarToBind :: forall s. RTVar RTyVar s -> Maybe (Symbol, s)
rTVarToBind = forall {b}. RTVInfo b -> Maybe (Symbol, b)
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 :: Bool
rtv_is_val :: Bool
rtv_kind :: b
rtv_name :: Symbol
rtv_is_val :: forall s. RTVInfo s -> Bool
rtv_kind :: forall s. RTVInfo s -> s
rtv_name :: forall s. RTVInfo s -> Symbol
rtv_is_pol :: forall s. RTVInfo s -> Bool
..} | Bool
rtv_is_val = forall a. a -> Maybe a
Just (Symbol
rtv_name, b
rtv_kind)
    go RTVInfo b
_                        = forall a. Maybe a
Nothing

tyVarIsVal :: RTVar tv s -> Bool
tyVarIsVal :: forall tv s. RTVar tv s -> Bool
tyVarIsVal = forall s. RTVInfo s -> Bool
rtvinfoIsVal forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 :: Bool
rtv_is_val :: Bool
rtv_kind :: s
rtv_name :: Symbol
rtv_is_val :: forall s. RTVInfo s -> Bool
rtv_kind :: forall s. RTVInfo s -> s
rtv_name :: forall s. RTVInfo s -> Symbol
rtv_is_pol :: forall s. RTVInfo s -> 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, τ)]
  , forall τ t. Ref τ t -> t
rf_body :: t -- ^ Abstract refinement associated with `RTyCon`
  } deriving (Ref τ t -> Ref τ t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
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
$c== :: forall τ t. (Eq τ, Eq t) => Ref τ t -> Ref τ t -> Bool
Eq, 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
$cto :: forall τ t x. Rep (Ref τ t) x -> Ref τ t
$cfrom :: forall τ t x. Ref τ t -> Rep (Ref τ t) x
Generic, Ref τ t -> DataType
Ref τ t -> Constr
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 {τ} {t}. (Data τ, Data t) => Typeable (Ref τ t)
forall τ t. (Data τ, Data t) => Ref τ t -> DataType
forall τ t. (Data τ, Data t) => Ref τ t -> Constr
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 (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 e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
$cgmapM :: forall τ t (m :: * -> *).
(Data τ, Data t, Monad m) =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> Ref τ t -> [u]
$cgmapQ :: forall τ t u.
(Data τ, Data t) =>
(forall d. Data d => d -> u) -> Ref τ t -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
$cgmapQl :: forall τ t r r'.
(Data τ, Data t) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
gmapT :: (forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
$cgmapT :: forall τ t.
(Data τ, Data t) =>
(forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
$cdataCast1 :: forall τ t (t :: * -> *) (c :: * -> *).
(Data τ, Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
dataTypeOf :: Ref τ t -> DataType
$cdataTypeOf :: forall τ t. (Data τ, Data t) => Ref τ t -> DataType
toConstr :: Ref τ t -> Constr
$ctoConstr :: forall τ t. (Data τ, Data t) => Ref τ t -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> 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)
Data, Typeable, 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
<$ :: forall a b. a -> Ref τ b -> Ref τ a
$c<$ :: forall τ a b. a -> Ref τ b -> Ref τ a
fmap :: forall a b. (a -> b) -> Ref τ a -> Ref τ b
$cfmap :: forall τ a b. (a -> b) -> Ref τ a -> Ref τ b
Functor)
    deriving 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
hash :: Ref τ t -> Int
$chash :: forall τ t. (Hashable τ, Hashable t) => Ref τ t -> Int
hashWithSalt :: Int -> Ref τ t -> Int
$chashWithSalt :: forall τ t. (Hashable τ, Hashable t) => Int -> 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 = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
τ (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 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
$cto :: forall t x. Rep (World t) x -> World t
$cfrom :: forall t x. World t -> Rep (World t) x
Generic, World t -> DataType
World t -> Constr
forall {t}. Data t => Typeable (World t)
forall t. Data t => World t -> DataType
forall t. Data t => World t -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> World t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> World t -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
gmapT :: (forall b. Data b => b -> b) -> World t -> World t
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> World t -> World t
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
dataTypeOf :: World t -> DataType
$cdataTypeOf :: forall t. Data t => World t -> DataType
toConstr :: World t -> Constr
$ctoConstr :: forall t. Data t => World t -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> 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)
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 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
$cto :: forall t x. Rep (HSeg t) x -> HSeg t
$cfrom :: forall t x. HSeg t -> Rep (HSeg t) x
Generic, HSeg t -> DataType
HSeg t -> Constr
forall {t}. Data t => Typeable (HSeg t)
forall t. Data t => HSeg t -> DataType
forall t. Data t => HSeg t -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> HSeg t -> [u]
$cgmapQ :: forall t u. Data t => (forall d. Data d => d -> u) -> HSeg t -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
gmapT :: (forall b. Data b => b -> b) -> HSeg t -> HSeg t
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> HSeg t -> HSeg t
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
dataTypeOf :: HSeg t -> DataType
$cdataTypeOf :: forall t. Data t => HSeg t -> DataType
toConstr :: HSeg t -> Constr
$ctoConstr :: forall t. Data t => HSeg t -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> 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)
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
forall r. Eq r => UReft r -> UReft r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UReft r -> UReft r -> Bool
$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
Eq, 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
$cto :: forall r x. Rep (UReft r) x -> UReft r
$cfrom :: forall r x. UReft r -> Rep (UReft r) x
Generic, UReft r -> DataType
UReft r -> Constr
forall {r}. Data r => Typeable (UReft r)
forall r. Data r => UReft r -> DataType
forall r. Data r => UReft r -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
$cgmapM :: forall r (m :: * -> *).
(Data r, Monad m) =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> UReft r -> [u]
$cgmapQ :: forall r u.
Data r =>
(forall d. Data d => d -> u) -> UReft r -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
$cgmapQl :: forall r r r'.
Data r =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
gmapT :: (forall b. Data b => b -> b) -> UReft r -> UReft r
$cgmapT :: forall r.
Data r =>
(forall b. Data b => b -> b) -> UReft r -> UReft r
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
$cdataCast1 :: forall r (t :: * -> *) (c :: * -> *).
(Data r, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
dataTypeOf :: UReft r -> DataType
$cdataTypeOf :: forall r. Data r => UReft r -> DataType
toConstr :: UReft r -> Constr
$ctoConstr :: forall r. Data r => UReft r -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> 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)
Data, Typeable, 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
<$ :: forall a b. a -> UReft b -> UReft a
$c<$ :: forall a b. a -> UReft b -> UReft a
fmap :: forall a b. (a -> b) -> UReft a -> UReft b
$cfmap :: forall a b. (a -> b) -> UReft a -> UReft b
Functor, 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
product :: forall a. Num a => UReft a -> a
$cproduct :: forall a. Num a => UReft a -> a
sum :: forall a. Num a => UReft a -> a
$csum :: forall a. Num a => UReft a -> a
minimum :: forall a. Ord a => UReft a -> a
$cminimum :: forall a. Ord a => UReft a -> a
maximum :: forall a. Ord a => UReft a -> a
$cmaximum :: forall a. Ord a => UReft a -> a
elem :: forall a. Eq a => a -> UReft a -> Bool
$celem :: forall a. Eq a => a -> UReft a -> Bool
length :: forall a. UReft a -> Int
$clength :: forall a. UReft a -> Int
null :: forall a. UReft a -> Bool
$cnull :: forall a. UReft a -> Bool
toList :: forall a. UReft a -> [a]
$ctoList :: forall a. UReft a -> [a]
foldl1 :: forall a. (a -> a -> a) -> UReft a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> UReft a -> a
foldr1 :: forall a. (a -> a -> a) -> UReft a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> UReft a -> a
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
$cfoldl :: forall b a. (b -> a -> 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
$cfoldr :: forall a b. (a -> b -> b) -> b -> UReft a -> b
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
$cfoldMap :: forall m a. Monoid m => (a -> m) -> UReft a -> m
fold :: forall m. Monoid m => UReft m -> m
$cfold :: forall m. Monoid m => UReft m -> m
Foldable, Functor UReft
Foldable 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)
sequence :: forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a)
$csequence :: forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UReft a -> m (UReft b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UReft a -> m (UReft b)
sequenceA :: forall (f :: * -> *) a. Applicative f => UReft (f a) -> f (UReft a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => UReft (f a) -> f (UReft a)
traverse :: 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)
Traversable)
  deriving 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
hash :: UReft r -> Int
$chash :: forall r. Hashable r => UReft r -> Int
hashWithSalt :: Int -> UReft r -> Int
$chashWithSalt :: forall r. Hashable r => Int -> 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   = forall a b. a -> b -> a
const Bool
False
  isEmbeddedDict c
c = forall c. TyConable c => c -> Bool
isNumCls c
c Bool -> Bool -> Bool
|| forall c. TyConable c => c -> Bool
isEqual c
c Bool -> Bool -> Bool
|| forall c. TyConable c => c -> Bool
isOrdCls c
c Bool -> Bool -> Bool
|| forall c. TyConable c => c -> Bool
isEqCls c
c
  isOrdCls  = forall a b. a -> b -> a
const Bool
False
  isEqCls   = forall a b. a -> b -> a
const Bool
False
  isEqual   = forall a b. a -> b -> a
const Bool
False
  isNumCls  = forall a b. a -> b -> a
const Bool
False
  isFracCls = 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
isFunTyCon forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  isList :: RTyCon -> Bool
isList     = (TyCon
listTyCon forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  isTuple :: RTyCon -> Bool
isTuple    = TyCon -> Bool
Ghc.isTupleTyCon   forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  isClass :: RTyCon -> Bool
isClass    = forall c. TyConable c => c -> Bool
isClass forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc -- isClassRTyCon
  isEqual :: RTyCon -> Bool
isEqual    = forall c. TyConable c => c -> Bool
isEqual forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc
  ppTycon :: RTyCon -> Doc
ppTycon    = forall a. Fixpoint a => a -> Doc
F.toFix

  isNumCls :: RTyCon -> Bool
isNumCls RTyCon
c  = 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 forall a b. (a -> b) -> a -> b
$ RTyCon -> TyCon
rtc_tc RTyCon
c)
  isFracCls :: RTyCon -> Bool
isFracCls RTyCon
c = 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 forall a b. (a -> b) -> a -> b
$ RTyCon -> TyCon
rtc_tc RTyCon
c)
  isOrdCls :: RTyCon -> Bool
isOrdCls  RTyCon
c = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Class -> Bool
isOrdClass (TyCon -> Maybe Class
tyConClass_maybe forall a b. (a -> b) -> a -> b
$ RTyCon -> TyCon
rtc_tc RTyCon
c)
  isEqCls :: RTyCon -> Bool
isEqCls   RTyCon
c = forall c. TyConable c => c -> Bool
isEqCls (RTyCon -> TyCon
rtc_tc RTyCon
c)


instance TyConable TyCon where
  isFun :: TyCon -> Bool
isFun      = TyCon -> Bool
isFunTyCon
  isList :: TyCon -> Bool
isList     = (TyCon
listTyCon 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
|| forall c. TyConable c => c -> Bool
isEqual TyCon
c -- c == eqPrimTyCon
  isEqual :: TyCon -> Bool
isEqual TyCon
c  = TyCon
c forall a. Eq a => a -> a -> Bool
== TyCon
eqPrimTyCon Bool -> Bool -> Bool
|| TyCon
c forall a. Eq a => a -> a -> Bool
== TyCon
eqReprPrimTyCon
  ppTycon :: TyCon -> Doc
ppTycon    = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Outputable a => a -> [Char]
showPpr

  isNumCls :: TyCon -> Bool
isNumCls TyCon
c  = 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 = 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  = 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
|| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((Class -> Bool) -> Class -> Bool
isClassOrSubClass Class -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst)
                 (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 forall a. Eq a => a -> a -> Bool
== Symbol
s
  isList :: Symbol -> Bool
isList  Symbol
s = Symbol
F.listConName forall a. Eq a => a -> a -> Bool
== Symbol
s
  isTuple :: Symbol -> Bool
isTuple Symbol
s = Symbol
F.tupConName forall a. Eq a => a -> a -> Bool
== Symbol
s
  ppTycon :: Symbol -> Doc
ppTycon   = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> [Char]
F.symbolString

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

instance TyConable BTyCon where
  isFun :: BTyCon -> Bool
isFun   = forall c. TyConable c => c -> Bool
isFun forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc
  isList :: BTyCon -> Bool
isList  = forall c. TyConable c => c -> Bool
isList forall b c a. (b -> c) -> (a -> b) -> a -> c
. BTyCon -> LocSymbol
btc_tc
  isTuple :: BTyCon -> Bool
isTuple = forall c. TyConable c => c -> Bool
isTuple 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 = forall c. TyConable c => c -> Doc
ppTycon 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 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 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 = 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 [RPVar]
_ TyConInfo
_) = [Char] -> Doc
text forall a b. (a -> b) -> a -> b
$ forall a. Outputable a => a -> [Char]
showPpr TyCon
c

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

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

instance Show Cinfo where
  show :: Cinfo -> [Char]
show = forall a. Show a => a -> [Char]
show forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Symbol
tc  Doc -> Doc -> Doc
<-> Doc -> Doc
angleBrackets (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k [RPVar]
pvs)
    | Bool
otherwise     = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Outputable a => a -> [Char]
showPpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. RTyCon -> TyCon
rtc_tc forall a b. (a -> b) -> a -> b
$ RTyCon
c
    where
      tc :: Symbol
tc            = forall a. Symbolic a => a -> Symbol
F.symbol (RTyCon -> TyCon
rtc_tc RTyCon
c)
      pvs :: [RPVar]
pvs           = RTyCon -> [RPVar]
rtc_pvars RTyCon
c

instance F.PPrint BTyCon where
  pprintTidy :: Tidy -> BTyCon -> Doc
pprintTidy Tidy
_ = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> [Char]
F.symbolString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Located a -> a
F.val 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
_) = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k v
x

instance Show RTyCon where
  show :: RTyCon -> [Char]
show = forall a. PPrint a => a -> [Char]
F.showpp

instance Show BTyCon where
  show :: BTyCon -> [Char]
show = forall a. PPrint a => a -> [Char]
F.showpp

instance F.Loc BTyCon where
  srcSpan :: BTyCon -> SrcSpan
srcSpan = forall a. Loc a => a -> SrcSpan
F.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
forall t. Eq t => RInstance t -> RInstance t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RInstance t -> RInstance t -> Bool
$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
Eq, 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
$cto :: forall t x. Rep (RInstance t) x -> RInstance t
$cfrom :: forall t x. RInstance t -> Rep (RInstance t) x
Generic, 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
<$ :: forall a b. a -> RInstance b -> RInstance a
$c<$ :: forall a b. a -> RInstance b -> RInstance a
fmap :: forall a b. (a -> b) -> RInstance a -> RInstance b
$cfmap :: forall a b. (a -> b) -> RInstance a -> RInstance b
Functor, RInstance t -> DataType
RInstance t -> Constr
forall {t}. Data t => Typeable (RInstance t)
forall t. Data t => RInstance t -> DataType
forall t. Data t => RInstance t -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> RInstance t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> RInstance t -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
gmapT :: (forall b. Data b => b -> b) -> RInstance t -> RInstance t
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> RInstance t -> RInstance t
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
dataTypeOf :: RInstance t -> DataType
$cdataTypeOf :: forall t. Data t => RInstance t -> DataType
toConstr :: RInstance t -> Constr
$ctoConstr :: forall t. Data t => RInstance t -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> 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)
Data, Typeable, Int -> RInstance t -> ShowS
forall t. Show t => Int -> RInstance t -> ShowS
forall t. Show t => [RInstance t] -> ShowS
forall t. Show t => RInstance t -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RInstance t] -> ShowS
$cshowList :: forall t. Show t => [RInstance t] -> ShowS
show :: RInstance t -> [Char]
$cshow :: forall t. Show t => RInstance t -> [Char]
showsPrec :: Int -> RInstance t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> RInstance t -> ShowS
Show)
    deriving 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
hash :: RInstance t -> Int
$chash :: forall t. Hashable t => RInstance t -> Int
hashWithSalt :: Int -> RInstance t -> Int
$chashWithSalt :: forall t. Hashable t => Int -> 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
forall ty. Eq ty => RILaws ty -> RILaws ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RILaws ty -> RILaws ty -> Bool
$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
Eq, Int -> RILaws ty -> ShowS
forall ty. Show ty => Int -> RILaws ty -> ShowS
forall ty. Show ty => [RILaws ty] -> ShowS
forall ty. Show ty => RILaws ty -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RILaws ty] -> ShowS
$cshowList :: forall ty. Show ty => [RILaws ty] -> ShowS
show :: RILaws ty -> [Char]
$cshow :: forall ty. Show ty => RILaws ty -> [Char]
showsPrec :: Int -> RILaws ty -> ShowS
$cshowsPrec :: forall ty. Show ty => Int -> RILaws ty -> ShowS
Show, 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
<$ :: forall a b. a -> RILaws b -> RILaws a
$c<$ :: forall a b. a -> RILaws b -> RILaws a
fmap :: forall a b. (a -> b) -> RILaws a -> RILaws b
$cfmap :: forall a b. (a -> b) -> RILaws a -> RILaws b
Functor, RILaws ty -> DataType
RILaws ty -> Constr
forall {ty}. Data ty => Typeable (RILaws ty)
forall ty. Data ty => RILaws ty -> DataType
forall ty. Data ty => RILaws ty -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
$cgmapM :: forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> RILaws ty -> [u]
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RILaws ty -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
$cgmapQl :: forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
gmapT :: (forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
$cgmapT :: forall ty.
Data ty =>
(forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
$cdataCast1 :: forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
dataTypeOf :: RILaws ty -> DataType
$cdataTypeOf :: forall ty. Data ty => RILaws ty -> DataType
toConstr :: RILaws ty -> Constr
$ctoConstr :: forall ty. Data ty => RILaws ty -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> 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)
Data, Typeable, 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
$cto :: forall ty x. Rep (RILaws ty) x -> RILaws ty
$cfrom :: forall ty x. RILaws ty -> Rep (RILaws ty) x
Generic)
    deriving 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
hash :: RILaws ty -> Int
$chash :: forall ty. Hashable ty => RILaws ty -> Int
hashWithSalt :: Int -> RILaws ty -> Int
$chashWithSalt :: forall ty. Hashable ty => Int -> RILaws ty -> Int
Hashable via Generically (RILaws ty)

data RISig t = RIAssumed t | RISig t
  deriving (RISig t -> RISig t -> Bool
forall t. Eq t => RISig t -> RISig t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RISig t -> RISig t -> Bool
$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
Eq, 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
$cto :: forall t x. Rep (RISig t) x -> RISig t
$cfrom :: forall t x. RISig t -> Rep (RISig t) x
Generic, 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
<$ :: forall a b. a -> RISig b -> RISig a
$c<$ :: forall a b. a -> RISig b -> RISig a
fmap :: forall a b. (a -> b) -> RISig a -> RISig b
$cfmap :: forall a b. (a -> b) -> RISig a -> RISig b
Functor, RISig t -> DataType
RISig t -> Constr
forall {t}. Data t => Typeable (RISig t)
forall t. Data t => RISig t -> DataType
forall t. Data t => RISig t -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> RISig t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> RISig t -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
gmapT :: (forall b. Data b => b -> b) -> RISig t -> RISig t
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> RISig t -> RISig t
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
dataTypeOf :: RISig t -> DataType
$cdataTypeOf :: forall t. Data t => RISig t -> DataType
toConstr :: RISig t -> Constr
$ctoConstr :: forall t. Data t => RISig t -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> 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)
Data, Typeable, Int -> RISig t -> ShowS
forall t. Show t => Int -> RISig t -> ShowS
forall t. Show t => [RISig t] -> ShowS
forall t. Show t => RISig t -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RISig t] -> ShowS
$cshowList :: forall t. Show t => [RISig t] -> ShowS
show :: RISig t -> [Char]
$cshow :: forall t. Show t => RISig t -> [Char]
showsPrec :: Int -> RISig t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> RISig t -> ShowS
Show)
  deriving 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
hash :: RISig t -> Int
$chash :: forall t. Hashable t => RISig t -> Int
hashWithSalt :: Int -> RISig t -> Int
$chashWithSalt :: forall t. Hashable t => Int -> 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 = 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
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k k
x Doc -> Doc -> Doc
<+> Doc
"::" Doc -> Doc -> Doc
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k t
t
ppRISig Tidy
k k
x (RISig t
t)     =              forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k k
x Doc -> Doc -> Doc
<+> Doc
"::" Doc -> Doc -> 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) = 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
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
stimes :: forall b. Integral b => b -> DEnv x ty -> DEnv x ty
$cstimes :: forall x ty b.
(Hashable x, Integral b) =>
b -> DEnv x ty -> DEnv x ty
sconcat :: NonEmpty (DEnv x ty) -> DEnv x ty
$csconcat :: forall x ty. Hashable x => NonEmpty (DEnv x ty) -> DEnv x ty
<> :: DEnv x ty -> DEnv x ty -> DEnv x ty
$c<> :: forall x ty. Hashable x => DEnv x ty -> 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
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
mconcat :: [DEnv x ty] -> DEnv x ty
$cmconcat :: forall x ty. Hashable x => [DEnv x ty] -> DEnv x ty
mappend :: DEnv x ty -> DEnv x ty -> DEnv x ty
$cmappend :: forall x ty. Hashable x => DEnv x ty -> DEnv x ty -> DEnv x ty
mempty :: DEnv x ty
$cmempty :: forall x ty. Hashable x => DEnv x ty
Monoid, Int -> DEnv x ty -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([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 -> [Char]
showList :: [DEnv x ty] -> ShowS
$cshowList :: forall x ty. (Show x, Show ty) => [DEnv x ty] -> ShowS
show :: DEnv x ty -> [Char]
$cshow :: forall x ty. (Show x, Show ty) => DEnv x ty -> [Char]
showsPrec :: Int -> DEnv x ty -> ShowS
$cshowsPrec :: forall x ty. (Show x, Show ty) => Int -> DEnv x ty -> ShowS
Show, 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
<$ :: forall a b. a -> DEnv x b -> DEnv x a
$c<$ :: forall x a b. a -> DEnv x b -> DEnv x a
fmap :: forall a b. (a -> b) -> DEnv x a -> DEnv x b
$cfmap :: forall x a b. (a -> b) -> DEnv x a -> DEnv x b
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
forall t. Show t => Int -> MethodType t -> ShowS
forall t. Show t => [MethodType t] -> ShowS
forall t. Show t => MethodType t -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [MethodType t] -> ShowS
$cshowList :: forall t. Show t => [MethodType t] -> ShowS
show :: MethodType t -> [Char]
$cshow :: forall t. Show t => MethodType t -> [Char]
showsPrec :: Int -> MethodType t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> MethodType t -> ShowS
Show)

getMethodType :: MethodType t -> Maybe t
getMethodType :: forall t. MethodType t -> Maybe t
getMethodType (MT (Just 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 -> [Char]
show (Axiom (Var
n, Maybe DataCon
c) Maybe Var
v [Var]
bs [Type]
_ts CoreExpr
lhs CoreExpr
rhs) = [Char]
"Axiom : " forall a. [a] -> [a] -> [a]
++
                                         [Char]
"\nFun Name: " forall a. [a] -> [a] -> [a]
++ forall a. Outputable a => a -> [Char]
showPpr Var
n forall a. [a] -> [a] -> [a]
++
                                         [Char]
"\nReal Name: " forall a. [a] -> [a] -> [a]
++ forall a. Outputable a => a -> [Char]
showPpr Maybe Var
v forall a. [a] -> [a] -> [a]
++
                                         [Char]
"\nData Con: " forall a. [a] -> [a] -> [a]
++ forall a. Outputable a => a -> [Char]
showPpr Maybe DataCon
c forall a. [a] -> [a] -> [a]
++
                                         [Char]
"\nArguments:" forall a. [a] -> [a] -> [a]
++ forall a. Outputable a => a -> [Char]
showPpr [Var]
bs  forall a. [a] -> [a] -> [a]
++
                                         -- "\nTypes    :" ++ (showPpr ts)  ++
                                         [Char]
"\nLHS      :" forall a. [a] -> [a] -> [a]
++ forall a. Outputable a => a -> [Char]
showPpr CoreExpr
lhs forall a. [a] -> [a] -> [a]
++
                                         [Char]
"\nRHS      :" forall a. [a] -> [a] -> [a]
++ forall a. Outputable a => a -> [Char]
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
DataDecl -> DataType
DataDecl -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDecl -> m DataDecl
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataDecl -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDecl -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDecl -> r
gmapT :: (forall b. Data b => b -> b) -> DataDecl -> DataDecl
$cgmapT :: (forall b. Data b => b -> b) -> DataDecl -> DataDecl
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDecl)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDecl)
dataTypeOf :: DataDecl -> DataType
$cdataTypeOf :: DataDecl -> DataType
toConstr :: DataDecl -> Constr
$ctoConstr :: DataDecl -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDecl -> c DataDecl
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDecl -> c DataDecl
Data, Typeable, 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
$cto :: forall x. Rep DataDecl x -> DataDecl
$cfrom :: forall x. DataDecl -> Rep DataDecl x
Generic)
    deriving Eq DataDecl
Int -> DataDecl -> Int
DataDecl -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: DataDecl -> Int
$chash :: DataDecl -> Int
hashWithSalt :: Int -> DataDecl -> Int
$chashWithSalt :: Int -> 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataName -> DataName -> Bool
$c/= :: DataName -> DataName -> Bool
== :: DataName -> DataName -> Bool
$c== :: DataName -> DataName -> Bool
Eq, Eq 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
min :: DataName -> DataName -> DataName
$cmin :: DataName -> DataName -> DataName
max :: DataName -> DataName -> DataName
$cmax :: DataName -> DataName -> DataName
>= :: DataName -> DataName -> Bool
$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
compare :: DataName -> DataName -> Ordering
$ccompare :: DataName -> DataName -> Ordering
Ord, Typeable DataName
DataName -> DataType
DataName -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataName -> m DataName
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataName -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataName -> r
gmapT :: (forall b. Data b => b -> b) -> DataName -> DataName
$cgmapT :: (forall b. Data b => b -> b) -> DataName -> DataName
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataName)
dataTypeOf :: DataName -> DataType
$cdataTypeOf :: DataName -> DataType
toConstr :: DataName -> Constr
$ctoConstr :: DataName -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataName -> c DataName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataName -> c DataName
Data, Typeable, 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
$cto :: forall x. Rep DataName x -> DataName
$cfrom :: forall x. DataName -> Rep DataName x
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
DataCtor -> DataType
DataCtor -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataCtor -> m DataCtor
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataCtor -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataCtor -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataCtor -> r
gmapT :: (forall b. Data b => b -> b) -> DataCtor -> DataCtor
$cgmapT :: (forall b. Data b => b -> b) -> DataCtor -> DataCtor
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataCtor)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataCtor)
dataTypeOf :: DataCtor -> DataType
$cdataTypeOf :: DataCtor -> DataType
toConstr :: DataCtor -> Constr
$ctoConstr :: DataCtor -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataCtor
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataCtor
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataCtor -> c DataCtor
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataCtor -> c DataCtor
Data, Typeable, 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
$cto :: forall x. Rep DataCtor x -> DataCtor
$cfrom :: forall x. DataCtor -> Rep DataCtor x
Generic, DataCtor -> DataCtor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataCtor -> DataCtor -> Bool
$c/= :: DataCtor -> DataCtor -> Bool
== :: DataCtor -> DataCtor -> Bool
$c== :: DataCtor -> DataCtor -> Bool
Eq)
    deriving Eq DataCtor
Int -> DataCtor -> Int
DataCtor -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: DataCtor -> Int
$chash :: DataCtor -> Int
hashWithSalt :: Int -> DataCtor -> Int
$chashWithSalt :: Int -> DataCtor -> Int
Hashable via Generically DataCtor

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

instance Show SizeFun where
  show :: SizeFun -> [Char]
show SizeFun
IdSizeFun      = [Char]
"IdSizeFun"
  show (SymSizeFun LocSymbol
x) = [Char]
"SymSizeFun " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show (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 (forall a. Symbolic a => a -> Symbol
F.symbol 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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [HasDataDecl] -> ShowS
$cshowList :: [HasDataDecl] -> ShowS
show :: HasDataDecl -> [Char]
$cshow :: HasDataDecl -> [Char]
showsPrec :: Int -> HasDataDecl -> ShowS
$cshowsPrec :: Int -> HasDataDecl -> ShowS
Show)

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

hasDecl :: DataDecl -> HasDataDecl
hasDecl :: DataDecl -> HasDataDecl
hasDecl DataDecl
d
  | 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 = forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
i forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 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 = 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 = forall a. Loc a => a -> SrcSpan
F.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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourcePos -> SrcSpan
sourcePosSrcSpan 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) = forall a. Loc a => a -> SrcSpan
F.srcSpan LocSymbol
z
  srcSpan (DnCon  LocSymbol
z) = forall a. Loc a => a -> SrcSpan
F.srcSpan LocSymbol
z


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


instance Show DataName where
  show :: DataName -> [Char]
show (DnName LocSymbol
n) =               forall a. Show a => a -> [Char]
show (forall a. Located a -> a
F.val LocSymbol
n)
  show (DnCon  LocSymbol
c) = [Char]
"datacon:" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show (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 (forall a. PPrint a => a -> Doc
F.pprint (forall a. Located a -> a
F.val LocSymbol
x))

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

instance F.Symbolic DataDecl where
  symbol :: DataDecl -> Symbol
symbol = forall a. Symbolic a => a -> Symbol
F.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) = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (forall a. Located a -> a
F.val LocSymbol
n)
  pprintTidy Tidy
k (DnCon  LocSymbol
n) = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
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
$c== :: forall x a. (Eq x, Eq a) => RTAlias x a -> RTAlias x a -> Bool
Eq, RTAlias x a -> DataType
RTAlias x a -> Constr
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 {x} {a}. (Data x, Data a) => Typeable (RTAlias x a)
forall x a. (Data x, Data a) => RTAlias x a -> DataType
forall x a. (Data x, Data a) => RTAlias x a -> Constr
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 (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 e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
$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)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> RTAlias x a -> [u]
$cgmapQ :: forall x a u.
(Data x, Data a) =>
(forall d. Data d => d -> u) -> RTAlias x a -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
$cgmapQl :: forall x a r r'.
(Data x, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
gmapT :: (forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a
$cgmapT :: forall x a.
(Data x, Data a) =>
(forall b. Data b => b -> b) -> RTAlias x a -> 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))
$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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
$cdataCast1 :: forall x a (t :: * -> *) (c :: * -> *).
(Data x, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
dataTypeOf :: RTAlias x a -> DataType
$cdataTypeOf :: forall x a. (Data x, Data a) => RTAlias x a -> DataType
toConstr :: RTAlias x a -> Constr
$ctoConstr :: forall x a. (Data x, Data a) => RTAlias x a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
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)
$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)
Data, Typeable, 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
$cto :: forall x a x. Rep (RTAlias x a) x -> RTAlias x a
$cfrom :: forall x a x. RTAlias x a -> Rep (RTAlias x a) x
Generic, 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
<$ :: forall a b. a -> RTAlias x b -> RTAlias x a
$c<$ :: forall x a b. a -> RTAlias x b -> RTAlias x a
fmap :: forall a b. (a -> b) -> RTAlias x a -> RTAlias x b
$cfmap :: forall x a b. (a -> b) -> RTAlias x a -> RTAlias x b
Functor)
    deriving 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
hash :: RTAlias x a -> Int
$chash :: forall x a. (Hashable x, Hashable a) => RTAlias x a -> Int
hashWithSalt :: Int -> RTAlias x a -> Int
$chashWithSalt :: forall x a. (Hashable x, Hashable a) => Int -> 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 :: [b]
rtTArgs = a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x a. RTAlias x a -> [x]
rtTArgs RTAlias a ty
rt }

lmapEAlias :: LMap -> F.Located (RTAlias Symbol Expr)
lmapEAlias :: LMap -> Located (RTAlias Symbol Expr)
lmapEAlias (LMap LocSymbol
v [Symbol]
ys Expr
e) = forall l b. Loc l => l -> b -> Located b
F.atLoc LocSymbol
v (forall x a. Symbol -> [x] -> [Symbol] -> a -> RTAlias x a
RTA (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_res :: RType c tv r
ty_args :: [RType c tv r]
ty_refts :: [r]
ty_info :: [RFInfo]
ty_binds :: [Symbol]
ty_preds :: [PVar (RType c tv ())]
ty_vars :: [(RTVar tv (RType c tv ()), r)]
ty_res :: forall c tv r. RTypeRep c tv r -> RType c tv r
ty_args :: forall c tv r. RTypeRep c tv r -> [RType c tv r]
ty_refts :: forall c tv r. RTypeRep c tv r -> [r]
ty_info :: forall c tv r. RTypeRep c tv r -> [RFInfo]
ty_binds :: forall c tv r. RTypeRep c tv r -> [Symbol]
ty_preds :: forall c tv r. RTypeRep c tv r -> [PVar (RType c tv ())]
ty_vars :: forall c tv r. RTypeRep c tv r -> [(RTVar tv (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 = forall t1 t2 t3 t4.
[Char] -> [t1] -> [t2] -> [t3] -> [t4] -> [(t1, t2, t3, t4)]
safeZip4WithError ([Char]
"fromRTypeRep: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show (forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
ty_binds, forall (t :: * -> *) a. Foldable t => t a -> Int
length [RFInfo]
ty_info, forall (t :: * -> *) a. Foldable t => t a -> Int
length [RType c tv r]
ty_args, 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         = 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') = 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'') = 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 = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 = 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 -> 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
_)   = 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)     = 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'') = 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
xforall a. a -> [a] -> [a]
:[Symbol]
xs, RFInfo
iforall a. a -> [a] -> [a]
:[RFInfo]
is, RType t t1 a
tforall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
rforall 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') = 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'') = 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
xforall a. a -> [a] -> [a]
:[Symbol]
xs, RFInfo
iforall a. a -> [a] -> [a]
:[RFInfo]
is, RType t t1 a
tforall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
rforall 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 {} = forall a. (?callStack::CallStack) => [Char] -> a
Prelude.error {- panic Nothing -} forall a b. (a -> b) -> a -> b
$ [Char]
"safeBkArrow on RAllT" forall a. [a] -> [a] -> [a]
++ forall a. PPrint a => a -> [Char]
F.showpp RType t t1 a
t
safeBkArrow (RAllP PVU t t1
_ RType t t1 a
_)     = forall a. (?callStack::CallStack) => [Char] -> a
Prelude.error {- panic Nothing -} [Char]
"safeBkArrow on RAllP"
safeBkArrow RType t t1 a
t               = 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 = 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 -> 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) (forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr 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 :: RType RTyCon RTyVar RReft
-> ([(SpecRTVar, RReft)], [RPVar],
    [(RTyCon, [RType RTyCon RTyVar RReft])], RType RTyCon RTyVar RReft)
bkUnivClass RType RTyCon RTyVar RReft
t        = ([(SpecRTVar, RReft)]
as, [RPVar]
ps, [(RTyCon, [RType RTyCon RTyVar RReft])]
cs, RType RTyCon RTyVar RReft
t2)
  where
    ([(SpecRTVar, RReft)]
as, [RPVar]
ps, RType RTyCon RTyVar RReft
t1) = forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv  RType RTyCon RTyVar RReft
t
    ([(RTyCon, [RType RTyCon RTyVar RReft])]
cs, RType RTyCon RTyVar RReft
t2)     = forall c tv r.
(PPrint c, TyConable c) =>
RType c tv r -> ([(c, [RType c tv r])], RType c tv r)
bkClass RType RTyCon RTyVar RReft
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') = 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)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') = 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 ())
π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' :: RType RTyCon RTyVar RReft
-> ([(SpecRTVar, RReft)], [RPVar],
    [(Symbol, RType RTyCon RTyVar RReft, RReft)],
    RType RTyCon RTyVar RReft)
bkUnivClass' RType RTyCon RTyVar RReft
t = ([(SpecRTVar, RReft)]
as, [RPVar]
ps, forall a b c. [a] -> [b] -> [c] -> [(a, b, c)]
zip3 [Symbol]
bs [RType RTyCon RTyVar RReft]
ts [RReft]
rs, RType RTyCon RTyVar RReft
t2)
  where
    ([(SpecRTVar, RReft)]
as, [RPVar]
ps, RType RTyCon RTyVar RReft
t1) = forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv  RType RTyCon RTyVar RReft
t
    ([Symbol]
bs, [RType RTyCon RTyVar RReft]
ts, [RReft]
rs, RType RTyCon RTyVar RReft
t2)     = forall t t1 a.
TyConable t =>
RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkClass' RType RTyCon RTyVar RReft
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)
  | forall c. TyConable c => c -> Bool
isClass t
c
  = let ([Symbol]
xs, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t'') = 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
xforall a. a -> [a] -> [a]
:[Symbol]
xs, RType t t1 a
tforall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
rforall 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'') = 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, 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
_)
  | forall a. PPrint a => [Char] -> a -> a
F.notracepp ([Char]
"IS-CLASS: " forall a. [a] -> [a] -> [a]
++ forall a. PPrint a => a -> [Char]
F.showpp c
c) forall a b. (a -> b) -> a -> b
$ forall c. TyConable c => c -> Bool
isClass c
c
  = let ([(c, [RType c tv r])]
cs, RType c tv r
t'') = 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)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') = 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, 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' = 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' 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' = 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' 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' = 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' 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   = forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp (TyCon -> [RPVar] -> TyConInfo -> RTyCon
RTyCon TyCon
c [] TyConInfo
defaultTyConInfo) [RType RTyCon tv r]
ts [] 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 = 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 [] forall a. Monoid a => a
mempty

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

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

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


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

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

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

instance F.Expression (UReft ()) where
  expr :: UReft () -> Expr
expr = forall a. Expression a => a -> Expr
F.expr forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 = forall r. Reftable r => r -> Bool
F.isTauto (forall r. UReft r -> r
ur_reft UReft r
u) Bool -> Bool -> Bool
&& forall r. Reftable r => r -> Bool
F.isTauto (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
  | forall r. Reftable r => UReft r -> Bool
isTautoUreft UReft r
u = Doc
d
  | Bool
otherwise      = forall r. Reftable r => r -> Doc -> Doc
pprReft r
r (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 (forall a. PPrint a => a -> Doc
F.pprint Symbol
v Doc -> Doc -> Doc
<+> Doc
colon Doc -> Doc -> Doc
<+> Doc
d Doc -> Doc -> Doc
<+> [Char] -> Doc
text [Char]
"|" Doc -> Doc -> Doc
<+> forall a. PPrint a => a -> Doc
F.pprint Reft
r')
  where
    r' :: Reft
r'@(F.Reft (Symbol
v, Expr
_)) = 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)     = forall a. Subable a => a -> [Symbol]
F.syms r
r forall a. [a] -> [a] -> [a]
++ forall a. Subable a => a -> [Symbol]
F.syms Predicate
p
  subst :: Subst -> UReft r -> UReft r
subst Subst
s (MkUReft r
r Predicate
z)  = forall r. r -> Predicate -> UReft r
MkUReft (forall a. Subable a => Subst -> a -> a
F.subst Subst
s r
r)  (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) = forall r. r -> Predicate -> UReft r
MkUReft (forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f r
r) (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) = forall r. r -> Predicate -> UReft r
MkUReft (forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f r
r) (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)     = (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv ())]
ss) forall a. [a] -> [a] -> [a]
++ 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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (forall c tv r. r -> RType c tv r
RHole (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) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (forall a. Subable a => Subst -> a -> a
F.subst Subst
su 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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (forall c tv r. r -> RType c tv r
RHole (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) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f 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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (forall c tv r. r -> RType c tv r
RHole (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) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
ss (forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f 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        = 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 -> forall a. Subable a => a -> [Symbol]
F.syms r
r 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    = forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ -> forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f) []      forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r1 r2 c tv. (r1 -> r2) -> RType c tv r1 -> RType c tv r2
mapReft  (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    = forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ -> forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f) []      forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft (forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf 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    = forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ -> forall a. Subable a => Subst -> a -> a
F.subst Subst
su) []      forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft (forall a. Subable a => Subst -> a -> a
F.subst  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 = forall c tv r.
([Symbol] -> Expr -> Expr)
-> [Symbol] -> RType c tv r -> RType c tv r
emapExprArg (\[Symbol]
_ Expr
e -> forall a. Subable a => a -> (Symbol, Expr) -> a
F.subst1 Expr
e (Symbol, Expr)
su) [] forall a b. (a -> b) -> a -> b
$ forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft (\[Symbol]
xs r
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)      = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [UsedPVar]
ps

  bot :: Predicate -> Predicate
bot (Pr [UsedPVar]
_)           = forall a. Maybe SrcSpan -> [Char] -> a
panic forall a. Maybe a
Nothing [Char]
"No BOT instance for Predicate"
  ppTy :: Predicate -> Doc -> Doc
ppTy Predicate
r Doc
d | 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 (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 (forall t. PVar t -> Symbol
parg UsedPVar
p, [Expr] -> Expr
F.pAnd forall a b. (a -> b) -> a -> b
$ forall a. PVar a -> Expr
pToRef forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UsedPVar]
ps)
  toReft Predicate
_                    = forall a. Monoid a => a
mempty
  params :: Predicate -> [Symbol]
params                      = forall a. Maybe SrcSpan -> [Char] -> a
todo forall a. Maybe a
Nothing [Char]
"TODO: instance of params for Predicate"

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

pToRef :: PVar a -> F.Expr
pToRef :: forall a. PVar a -> Expr
pToRef PVar a
p = Symbol -> [Expr] -> Expr
pApp (forall t. PVar t -> Symbol
pname PVar a
p) forall a b. (a -> b) -> a -> b
$ Symbol -> Expr
F.EVar (forall t. PVar t -> Symbol
parg PVar a
p) forall a. a -> [a] -> [a]
: (forall a b c. (a, b, c) -> c
thd3 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> 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
pforall a. a -> [a] -> [a]
:[Expr]
es)
  where
    fn :: LocSymbol
fn    = forall a. a -> Located a
F.dummyLoc (forall a. Show a => a -> Symbol
pappSym Int
n)
    n :: Int
n     = 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  = forall a. Symbolic a => a -> Symbol
F.symbol forall a b. (a -> b) -> a -> b
$ [Char]
"papp" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
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 RReft -> RType c tv RReft
mapExprReft Symbol -> Expr -> Expr
f = forall r1 r2 c tv. (r1 -> r2) -> RType c tv r1 -> RType c tv r2
mapReft RReft -> RReft
g
  where
    g :: RReft -> RReft
g (MkUReft (F.Reft (Symbol
x, Expr
e)) Predicate
p) = 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 = 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 -> 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 = forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft (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)        = 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)     = forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (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)       = forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π (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) = forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun  Symbol
x RFInfo
i (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) (forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f (Symbol
xforall a. a -> [a] -> [a]
:[Symbol]
γ) RType c tv r1
t') ([Symbol] -> r1 -> r2
f (Symbol
xforall 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)  = forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c (forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r1]
ts) (forall t s c tv.
([Symbol] -> t -> s) -> [Symbol] -> RTProp c tv t -> RTProp c tv s
emapRef [Symbol] -> r1 -> r2
f [Symbol]
γ 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')    = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z (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) (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')      = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx   Symbol
z (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) (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)      = 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)   = forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (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) (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)    = forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy  (forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (forall r1 r2 c tv.
([Symbol] -> r1 -> r2)
-> [Symbol] -> RType c tv r1 -> RType c tv r2
emapReft [Symbol] -> r1 -> r2
f [Symbol]
γ) 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 (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)         = 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))  = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
s forall a b. (a -> b) -> a -> b
$ 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)         = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, RType c tv ())]
s forall a b. (a -> b) -> a -> b
$ 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 = 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)     = 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)       = 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) = 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
xforall 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)  = 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]
γ 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]
γ 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')    = 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')      = 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)      = forall c tv r. Located Expr -> RType c tv r
RExprArg ([Symbol] -> Expr -> Expr
f [Symbol]
γ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. PPrint a => [Char] -> a -> a
F.notracepp [Char]
"RExprArg" Located Expr
e) -- <---- actual substitution
    go [Symbol]
γ (RAppTy RType c tv r
t RType c tv r
t' r
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)    = forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy  (forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd ([Symbol] -> RType c tv r -> RType c tv r
go [Symbol]
γ) 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)         = 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
_)  = 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')     = 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')       = 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
_)    = 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
_)   = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RTProp c tv r -> acc
prep (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)     = 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 forall a. a -> [a] -> [a]
: (forall a b. (a, b) -> b
snd 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
_)    = 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)      = 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
_)  = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all 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
_) = forall c tv r. RType c tv r -> Bool
isBase RType t t1 t2
t1 Bool -> Bool -> 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)   = 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)    = 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)      = 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
_)     = 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)       = 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
_) = forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> 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
_)   = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any 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')    = forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> 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')      = forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> 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
_)   = forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> 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)  = forall c tv r. RType c tv r -> Bool
hasHoleTy RType t t1 t2
t Bool -> Bool -> Bool
|| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any forall c tv r. RType c tv r -> Bool
hasHoleTy (forall a b. (a, b) -> b
snd 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)    = 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
_)    = 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)      = 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)        = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   (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)     = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α)  (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)       = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   (forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π)  (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) = forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i) (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)         (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)  = forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c)  (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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) (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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')    = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z)  (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)         (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')      = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
z)    (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)         (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)      = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ 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)   = forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (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) (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)         = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   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)  = 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 forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *) b c a.
Applicative m =>
(b -> m c) -> (a, b) -> m (a, c)
mapSndM (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) (forall (m :: * -> *) a. Monad m => a -> m a
return Oblig
o) (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)        = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap    (forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, 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)        = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ 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)     = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α)   (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)          (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)       = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap   (forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π)   (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) = forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i)  (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)          (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') (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)  = forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp  c
c)   (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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)  (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM RTProp c tv r -> m (RTProp c tv r)
f [RTProp c tv r]
rs)     (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')    = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
z)   (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)          (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')      = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
z)     (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)          (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)      = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ 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)   = forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (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) (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') (forall (m :: * -> *) a. Monad m => a -> m a
return r
r)
mapPropM RTProp c tv r -> m (RTProp c tv r)
_ (RHole r
r)         = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ 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)  = 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 forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *) b c a.
Applicative m =>
(b -> m c) -> (a, b) -> m (a, c)
mapSndM (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) (forall (m :: * -> *) a. Monad m => a -> m a
return r
r) (forall (m :: * -> *) a. Monad m => a -> m a
return Oblig
o) (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 = 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 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
  = 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]
_ -> [])
              (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
γ)
              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
γ (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)
       | 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
γ (forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go (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
γ (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 forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just Bool
True then forall c. TyConable c => c -> Bool
isEmbeddedDict else forall c. TyConable c => c -> Bool
isClass)
         c
c  = SEnv a -> Maybe (RType c tv r) -> r -> b -> b
f SEnv a
γ (forall a. a -> Maybe a
Just RType c tv r
me) r
r (SEnv a -> b -> RType c tv r -> b
go (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
γ (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
γ (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
γ'                             = 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
γ (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 forall a. Symbol -> a -> SEnv a -> SEnv a
insertSEnv (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 (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 (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
γ (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
γ (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 (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
γ (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
γ (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 (forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv SEnv a
γ (forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (RType c tv r -> a
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r c tv. Reftable r => RType c tv () -> RType c tv r
ofRSort) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv ())]
ss)) 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 (forall a. SEnv a -> [(Symbol, a)] -> SEnv a
insertsSEnv SEnv a
γ (forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (RType c tv r -> a
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r c tv. Reftable r => RType c tv () -> RType c tv r
ofRSort) 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                 = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall a b c. (a -> b -> c) -> b -> a -> c
flip 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                 = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall a b c. (a -> b -> c) -> b -> a -> c
flip 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 = 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 -> 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) (forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. [a] -> a
last [(Symbol, RType c tv r)]
xts) (forall a. [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)     = forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (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)       = forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π (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) = 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) (forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t) (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)   = forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t) (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)  = forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c (forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) (forall τ c tv r.
(RFInfo -> RFInfo) -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapRFInfoRef RFInfo -> RFInfo
f 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)     = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
b  (forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t1) (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)   = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
b (forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f RType c tv r
t1) (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)    = forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy (forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (forall c tv r. (RFInfo -> RFInfo) -> RType c tv r -> RType c tv r
mapRFInfo RFInfo -> RFInfo
f) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e) r
r Oblig
o (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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s forall a b. (a -> b) -> a -> b
$ forall c tv r. r -> RType c tv r
RHole r
r
mapRFInfoRef RFInfo -> RFInfo
f (RProp [(Symbol, τ)]
s RType c tv r
t)    = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp  [(Symbol, τ)]
s forall a b. (a -> b) -> a -> b
$ 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)     = forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (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)       = forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π (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) = forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i (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) (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)   = forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (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) (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 forall a b. (a -> b) -> a -> b
$ forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c (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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) (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 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)     = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx Symbol
b  (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) (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)   = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
b  (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) (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)    = forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy (forall b c a. (b -> c) -> (a, b) -> (a, c)
mapSnd (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) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e) r
r Oblig
o (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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s forall a b. (a -> b) -> a -> b
$ 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)         = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s forall a b. (a -> b) -> a -> b
$ 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)      = forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (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)        = forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
π (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) = 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 (forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t1) (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)   = forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c (forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) (forall τ c tv r.
(Symbol -> Symbol) -> Ref τ (RType c tv r) -> Ref τ (RType c tv r)
mapBindRef Symbol -> Symbol
f 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)    = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE  (Symbol -> Symbol
f Symbol
b) (forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t1) (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)      = forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx    (Symbol -> Symbol
f Symbol
b) (forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t1) (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)         = forall c tv r. tv -> r -> RType c tv r
RVar tv
α r
r
mapBind Symbol -> Symbol
_ (RHole r
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)     = 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 (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)       = 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)    = forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind Symbol -> Symbol
f RType c tv r
t) (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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp (forall a c b. (a -> c) -> (a, b) -> (c, b)
mapFst Symbol -> Symbol
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, τ)]
s) (forall c tv r. r -> RType c tv r
RHole r
r)
mapBindRef Symbol -> Symbol
f (RProp [(Symbol, τ)]
s RType c tv r
t)         = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp (forall a c b. (a -> c) -> (a, b) -> (c, b)
mapFst Symbol -> Symbol
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, τ)]
s) forall a b. (a -> b) -> a -> b
$ 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 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap 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 = forall c tv r. RType c tv r -> RType c tv r
stripAnnotations forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c tv r. (Symbol -> Symbol) -> RType c tv r -> RType c tv r
mapBind (forall a b. a -> b -> a
const Symbol
F.dummySymbol) forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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)     = forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
α (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)       = 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)     = 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)       = 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) = forall c tv r.
Symbol
-> RFInfo -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x RFInfo
i (forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t) (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)   = forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (forall c tv r. RType c tv r -> RType c tv r
stripAnnotations RType c tv r
t) (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)  = forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c (forall c tv r. RType c tv r -> RType c tv r
stripAnnotations forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
ts) (forall τ c tv r. Ref τ (RType c tv r) -> Ref τ (RType c tv r)
stripAnnotationsRef 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)    = 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)) = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s (forall c tv r. r -> RType c tv r
RHole r
r)
stripAnnotationsRef (RProp [(Symbol, τ)]
s RType c tv r
t)         = forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
s forall a b. (a -> b) -> a -> b
$ 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 = 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  = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(Symbol
x, a
t) 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
_) =  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 = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Reft
F.trueReft forall r. Reftable r => r -> Reft
F.toReft forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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)   = forall a. a -> Maybe a
Just r
x
stripRTypeBase (RVar tv
_ r
x)       = forall a. a -> Maybe a
Just r
x
stripRTypeBase (RFun Symbol
_ RFInfo
_ RType c tv r
_ RType c tv r
_ r
x) = forall a. a -> Maybe a
Just r
x
stripRTypeBase (RAppTy RType c tv r
_ RType c tv r
_ r
x)   = forall a. a -> Maybe a
Just r
x
stripRTypeBase (RAllT RTVU c tv
_ RType c tv r
_ r
x)    = forall a. a -> Maybe a
Just r
x
stripRTypeBase RType c tv 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 = forall r c tv. (r -> r) -> RType c tv r -> RType c tv r
mapRBase 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)   = 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 forall a b. (a -> b) -> a -> b
$ r -> r
f r
r
mapRBase r -> r
f (RVar tv
a r
r)         = forall c tv r. tv -> r -> RType c tv r
RVar tv
a 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) = 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 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)   = 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 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
_ = 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) = forall a. PPrint a => a -> Doc
F.pprint Symbol
s Doc -> Doc -> Doc
<+> [Doc] -> Doc
hsep (forall a. PPrint a => a -> Doc
F.pprint forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall {a}. [(a, Symbol, Expr)] -> [Expr]
dargs [(a, Symbol, Expr)]
xts)
  where
    dargs :: [(a, Symbol, Expr)] -> [Expr]
dargs              = forall a b. (a -> b) -> [a] -> [b]
map forall a b c. (a, b, c) -> c
thd3 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
takeWhile (\(a
_, Symbol
x, Expr
y) -> Symbol -> Expr
F.EVar Symbol
x forall a. Eq a => a -> a -> Bool
/= Expr
y)


instance F.PPrint Predicate where
  pprintTidy :: Tidy -> Predicate -> Doc
pprintTidy Tidy
_ (Pr [])  = [Char] -> Doc
text [Char]
"True"
  pprintTidy Tidy
k (Pr [UsedPVar]
pvs) = [Doc] -> Doc
hsep forall a b. (a -> b) -> a -> b
$ Doc -> [Doc] -> [Doc]
punctuate ([Char] -> Doc
text [Char]
"&") (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k 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) = forall t. HashMap Symbol t -> HashMap Symbol t -> AREnv t
REnv (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f HashMap Symbol a
g) (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
$+$
    forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (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
$+$
    forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (forall t. AREnv t -> HashMap Symbol t
reGlobal AREnv t
re)

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

instance Monoid REnv where
  mempty :: REnv
mempty = forall t. HashMap Symbol t -> HashMap Symbol t -> AREnv t
REnv forall a. Monoid a => a
mempty 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Warning -> Warning -> Bool
$c/= :: Warning -> Warning -> Bool
== :: Warning -> Warning -> Bool
$c== :: Warning -> Warning -> Bool
Eq, Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Warning] -> ShowS
$cshowList :: [Warning] -> ShowS
show :: Warning -> [Char]
$cshow :: Warning -> [Char]
showsPrec :: Int -> Warning -> ShowS
$cshowsPrec :: Int -> 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Diagnostics -> Diagnostics -> Bool
$c/= :: Diagnostics -> Diagnostics -> Bool
== :: Diagnostics -> Diagnostics -> Bool
$c== :: 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 forall a. Semigroup a => a -> a -> a
<> [Warning]
w2) ([Error]
e1 forall a. Semigroup a => a -> a -> a
<> [Error]
e2)

instance Monoid Diagnostics where
  mempty :: Diagnostics
mempty  = Diagnostics
emptyDiagnostics
  mappend :: Diagnostics -> Diagnostics -> Diagnostics
mappend = 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 forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

noErrors :: Diagnostics -> Bool
noErrors :: Diagnostics -> Bool
noErrors = forall (t :: * -> *) a. Foldable t => t a -> Bool
L.null 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 -> DynFlags -> Warning -> IO ()
printWarning :: Logger -> DynFlags -> Warning -> IO ()
printWarning Logger
logger DynFlags
dyn (Warning SrcSpan
srcSpan Doc
doc) = Logger -> DynFlags -> SrcSpan -> Doc -> IO ()
GHC.putWarnMsg Logger
logger DynFlags
dyn 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cinfo -> Cinfo -> Bool
$c/= :: Cinfo -> Cinfo -> Bool
== :: Cinfo -> Cinfo -> Bool
$c== :: Cinfo -> Cinfo -> Bool
Eq, 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
$cto :: forall x. Rep Cinfo x -> Cinfo
$cfrom :: forall x. Cinfo -> Rep Cinfo x
Generic)

instance F.Loc Cinfo where
  srcSpan :: Cinfo -> SrcSpan
srcSpan = SrcSpan -> SrcSpan
srcSpanFSrcSpan 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 = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModName -> ModName -> Bool
$c/= :: ModName -> ModName -> Bool
== :: ModName -> ModName -> Bool
$c== :: ModName -> ModName -> Bool
Eq, Eq 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
min :: ModName -> ModName -> ModName
$cmin :: ModName -> ModName -> ModName
max :: ModName -> ModName -> ModName
$cmax :: ModName -> ModName -> ModName
>= :: ModName -> ModName -> Bool
$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
compare :: ModName -> ModName -> Ordering
$ccompare :: ModName -> ModName -> Ordering
Ord, Int -> ModName -> ShowS
[ModName] -> ShowS
ModName -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [ModName] -> ShowS
$cshowList :: [ModName] -> ShowS
show :: ModName -> [Char]
$cshow :: ModName -> [Char]
showsPrec :: Int -> ModName -> ShowS
$cshowsPrec :: Int -> ModName -> ShowS
Show, 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
$cto :: forall x. Rep ModName x -> ModName
$cfrom :: forall x. ModName -> Rep ModName x
Generic, Typeable ModName
ModName -> DataType
ModName -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModName -> m ModName
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ModName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ModName -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModName -> r
gmapT :: (forall b. Data b => b -> b) -> ModName -> ModName
$cgmapT :: (forall b. Data b => b -> b) -> ModName -> ModName
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModName)
dataTypeOf :: ModName -> DataType
$cdataTypeOf :: ModName -> DataType
toConstr :: ModName -> Constr
$ctoConstr :: ModName -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModName -> c ModName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModName -> c ModName
Data, Typeable)

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

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

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

instance F.Symbolic ModuleName where
  symbol :: ModuleName -> Symbol
symbol = forall a. Symbolic a => a -> Symbol
F.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 -> [Char]
getModString = ModuleName -> [Char]
moduleNameString 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         = 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  = forall tv t.
HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
RTE forall k v. HashMap k v
M.empty forall k v. HashMap k v
M.empty
  mappend :: RTEnv tv t -> RTEnv tv t -> RTEnv tv t
mappend = 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' = 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 forall k v.
(Eq k, Hashable 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 forall k v.
(Eq k, Hashable 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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Body] -> ShowS
$cshowList :: [Body] -> ShowS
show :: Body -> [Char]
$cshow :: Body -> [Char]
showsPrec :: Int -> Body -> ShowS
$cshowsPrec :: Int -> Body -> ShowS
Show, Typeable Body
Body -> DataType
Body -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Body -> m Body
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Body -> m Body
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Body -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Body -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Body -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Body -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r
gmapT :: (forall b. Data b => b -> b) -> Body -> Body
$cgmapT :: (forall b. Data b => b -> b) -> Body -> Body
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Body)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Body)
dataTypeOf :: Body -> DataType
$cdataTypeOf :: Body -> DataType
toConstr :: Body -> Constr
$ctoConstr :: Body -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Body
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Body
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Body -> c Body
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Body -> c Body
Data, Typeable, 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
$cto :: forall x. Rep Body x -> Body
$cfrom :: forall x. Body -> Rep Body x
Generic, Body -> Body -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Body -> Body -> Bool
$c/= :: Body -> Body -> Bool
== :: Body -> Body -> Bool
$c== :: Body -> Body -> Bool
Eq)
  deriving Eq Body
Int -> Body -> Int
Body -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: Body -> Int
$chash :: Body -> Int
hashWithSalt :: Int -> Body -> Int
$chashWithSalt :: Int -> 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
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([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 -> [Char]
showList :: [Def ty ctor] -> ShowS
$cshowList :: forall ty ctor. (Show ctor, Show ty) => [Def ty ctor] -> ShowS
show :: Def ty ctor -> [Char]
$cshow :: forall ty ctor. (Show ctor, Show ty) => Def ty ctor -> [Char]
showsPrec :: Int -> Def ty ctor -> ShowS
$cshowsPrec :: forall ty ctor. (Show ctor, Show ty) => Int -> Def ty ctor -> ShowS
Show, Def ty ctor -> DataType
Def ty ctor -> Constr
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 {ty} {ctor}. (Data ty, Data ctor) => Typeable (Def ty ctor)
forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> DataType
forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> Constr
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 (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 e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
$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)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> Def ty ctor -> [u]
$cgmapQ :: forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> Def ty ctor -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
$cgmapQl :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
gmapT :: (forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor
$cgmapT :: forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> Def ty ctor -> 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))
$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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
$cdataCast1 :: forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
dataTypeOf :: Def ty ctor -> DataType
$cdataTypeOf :: forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> DataType
toConstr :: Def ty ctor -> Constr
$ctoConstr :: forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
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)
$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)
Data, Typeable, 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
$cto :: forall ty ctor x. Rep (Def ty ctor) x -> Def ty ctor
$cfrom :: forall ty ctor x. Def ty ctor -> Rep (Def ty ctor) x
Generic, Def ty ctor -> Def ty ctor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
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
$c== :: forall ty ctor.
(Eq ctor, Eq ty) =>
Def ty ctor -> Def ty ctor -> Bool
Eq, 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
<$ :: forall a b. a -> Def ty b -> Def ty a
$c<$ :: forall ty a b. a -> Def ty b -> Def ty a
fmap :: forall a b. (a -> b) -> Def ty a -> Def ty b
$cfmap :: forall ty a b. (a -> b) -> Def ty a -> Def ty b
Functor)
    deriving 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
hash :: Def ty ctor -> Int
$chash :: forall ty ctor. (Hashable ctor, Hashable ty) => Def ty ctor -> Int
hashWithSalt :: Int -> Def ty ctor -> Int
$chashWithSalt :: forall ty ctor.
(Hashable ctor, Hashable ty) =>
Int -> 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
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
$c== :: forall ty ctor.
(Eq ty, Eq ctor) =>
Measure ty ctor -> Measure ty ctor -> Bool
Eq, Measure ty ctor -> DataType
Measure ty ctor -> Constr
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 {ty} {ctor}.
(Data ty, Data ctor) =>
Typeable (Measure ty ctor)
forall ty ctor. (Data ty, Data ctor) => Measure ty ctor -> DataType
forall ty ctor. (Data ty, Data ctor) => Measure ty ctor -> Constr
forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty ctor
forall ty ctor u.
(Data ty, Data ctor) =>
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> Measure ty ctor -> [u]
forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall ty ctor r r'.
(Data ty, Data ctor) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall ty ctor (m :: * -> *).
(Data ty, Data ctor, Monad m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure 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 (Measure 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) -> Measure ty ctor -> c (Measure ty ctor)
forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure 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 (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 e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
$cgmapMo :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, 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)
$cgmapMp :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, MonadPlus 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)
$cgmapM :: forall ty ctor (m :: * -> *).
(Data ty, Data ctor, Monad m) =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
$cgmapQi :: forall ty ctor u.
(Data ty, Data ctor) =>
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Measure ty ctor -> [u]
$cgmapQ :: forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> Measure ty ctor -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
$cgmapQr :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(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
$cgmapQl :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
gmapT :: (forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty ctor
$cgmapT :: forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> Measure ty ctor -> 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))
$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 (Measure ty ctor))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
$cdataCast1 :: forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
dataTypeOf :: Measure ty ctor -> DataType
$cdataTypeOf :: forall ty ctor. (Data ty, Data ctor) => Measure ty ctor -> DataType
toConstr :: Measure ty ctor -> Constr
$ctoConstr :: forall ty ctor. (Data ty, Data ctor) => Measure ty ctor -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure 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 (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)
$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) -> Measure ty ctor -> c (Measure ty ctor)
Data, Typeable, 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
$cto :: forall ty ctor x. Rep (Measure ty ctor) x -> Measure ty ctor
$cfrom :: forall ty ctor x. Measure ty ctor -> Rep (Measure ty ctor) x
Generic, 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
<$ :: forall a b. a -> Measure ty b -> Measure ty a
$c<$ :: forall ty a b. a -> Measure ty b -> Measure ty a
fmap :: forall a b. (a -> b) -> Measure ty a -> Measure ty b
$cfmap :: forall ty a b. (a -> b) -> Measure ty a -> Measure ty b
Functor)
    deriving 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
hash :: Measure ty ctor -> Int
$chash :: forall ty ctor.
(Hashable ty, Hashable ctor) =>
Measure ty ctor -> Int
hashWithSalt :: Int -> Measure ty ctor -> Int
$chashWithSalt :: forall ty ctor.
(Hashable ty, Hashable ctor) =>
Int -> 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MeasureKind -> MeasureKind -> Bool
$c/= :: MeasureKind -> MeasureKind -> Bool
== :: MeasureKind -> MeasureKind -> Bool
$c== :: MeasureKind -> MeasureKind -> Bool
Eq, Eq 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
min :: MeasureKind -> MeasureKind -> MeasureKind
$cmin :: MeasureKind -> MeasureKind -> MeasureKind
max :: MeasureKind -> MeasureKind -> MeasureKind
$cmax :: MeasureKind -> MeasureKind -> MeasureKind
>= :: MeasureKind -> MeasureKind -> Bool
$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
compare :: MeasureKind -> MeasureKind -> Ordering
$ccompare :: MeasureKind -> MeasureKind -> Ordering
Ord, Int -> MeasureKind -> ShowS
[MeasureKind] -> ShowS
MeasureKind -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [MeasureKind] -> ShowS
$cshowList :: [MeasureKind] -> ShowS
show :: MeasureKind -> [Char]
$cshow :: MeasureKind -> [Char]
showsPrec :: Int -> MeasureKind -> ShowS
$cshowsPrec :: Int -> MeasureKind -> ShowS
Show, Typeable MeasureKind
MeasureKind -> DataType
MeasureKind -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeasureKind -> r
gmapT :: (forall b. Data b => b -> b) -> MeasureKind -> MeasureKind
$cgmapT :: (forall b. Data b => b -> b) -> MeasureKind -> MeasureKind
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MeasureKind)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MeasureKind)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeasureKind)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeasureKind)
dataTypeOf :: MeasureKind -> DataType
$cdataTypeOf :: MeasureKind -> DataType
toConstr :: MeasureKind -> Constr
$ctoConstr :: MeasureKind -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeasureKind
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeasureKind
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeasureKind -> c MeasureKind
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeasureKind -> c MeasureKind
Data, Typeable, 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
$cto :: forall x. Rep MeasureKind x -> MeasureKind
$cfrom :: forall x. MeasureKind -> Rep MeasureKind x
Generic)
  deriving Eq MeasureKind
Int -> MeasureKind -> Int
MeasureKind -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: MeasureKind -> Int
$chash :: MeasureKind -> Int
hashWithSalt :: Int -> MeasureKind -> Int
$chashWithSalt :: Int -> MeasureKind -> Int
Hashable via Generically MeasureKind

instance F.Loc (Measure a b) where
  srcSpan :: Measure a b -> SrcSpan
srcSpan = forall a. Loc a => a -> SrcSpan
F.srcSpan forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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) = forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m c
c (a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe a
s) (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) 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) = 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) = forall ty ctor.
LocSymbol
-> ty
-> [Def ty ctor]
-> MeasureKind
-> UnSortedExprs
-> Measure ty ctor
M LocSymbol
n (a -> b
f a
s) (forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f 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) = forall ty ctor.
LocSymbol
-> ty
-> [Def ty ctor]
-> MeasureKind
-> UnSortedExprs
-> Measure ty ctor
M LocSymbol
n a
s (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second b -> c
f 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 (CMeasure ty -> DataType
CMeasure ty -> Constr
forall {ty}. Data ty => Typeable (CMeasure ty)
forall ty. Data ty => CMeasure ty -> DataType
forall ty. Data ty => CMeasure ty -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
$cgmapM :: forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> CMeasure ty -> [u]
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> CMeasure ty -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
$cgmapQl :: forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
gmapT :: (forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
$cgmapT :: forall ty.
Data ty =>
(forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
$cdataCast1 :: forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
dataTypeOf :: CMeasure ty -> DataType
$cdataTypeOf :: forall ty. Data ty => CMeasure ty -> DataType
toConstr :: CMeasure ty -> Constr
$ctoConstr :: forall ty. Data ty => CMeasure ty -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> 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)
Data, Typeable, 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
$cto :: forall ty x. Rep (CMeasure ty) x -> CMeasure ty
$cfrom :: forall ty x. CMeasure ty -> Rep (CMeasure ty) x
Generic, 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
<$ :: forall a b. a -> CMeasure b -> CMeasure a
$c<$ :: forall a b. a -> CMeasure b -> CMeasure a
fmap :: forall a b. (a -> b) -> CMeasure a -> CMeasure b
$cfmap :: forall a b. (a -> b) -> CMeasure a -> CMeasure b
Functor)

instance F.PPrint Body where
  pprintTidy :: Tidy -> Body -> Doc
pprintTidy Tidy
k (E Expr
e)   = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e
  pprintTidy Tidy
k (P Expr
p)   = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
p
  pprintTidy Tidy
k (R Symbol
v Expr
p) = Doc -> Doc
braces (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Symbol
v Doc -> Doc -> Doc
<+> Doc
"|" Doc -> Doc -> 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)
           = 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
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Body
body
    where
      cbsd :: Doc
cbsd = Doc -> Doc
parens (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
c Doc -> Doc -> Doc
<-> [Doc] -> Doc
hsep (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` (forall a b. (a, b) -> a
fst 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
_) =  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
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k t
s
                                  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k 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 -> [Char]
show = forall a. PPrint a => a -> [Char]
F.showpp

instance F.PPrint t => F.PPrint (CMeasure t) where
  pprintTidy :: Tidy -> CMeasure t -> Doc
pprintTidy Tidy
k (CM LocSymbol
n t
s) =  forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k LocSymbol
n Doc -> Doc -> Doc
<+> Doc
"::" Doc -> Doc -> 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 -> [Char]
show = forall a. PPrint a => a -> [Char]
F.showpp


instance F.Subable (Measure ty ctor) where
  syms :: Measure ty ctor -> [Symbol]
syms  Measure ty ctor
m     = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a. Subable a => a -> [Symbol]
F.syms (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 :: [Def ty ctor]
msEqns = forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f  forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall ty ctor. Measure ty ctor -> [Def ty ctor]
msEqns Measure ty ctor
m }
  substf :: (Symbol -> Expr) -> Measure ty ctor -> Measure ty ctor
substf Symbol -> Expr
f Measure ty ctor
m  = Measure ty ctor
m { msEqns :: [Def ty ctor]
msEqns = forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f  forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall ty ctor. Measure ty ctor -> [Def ty ctor]
msEqns Measure ty ctor
m }
  subst :: Subst -> Measure ty ctor -> Measure ty ctor
subst  Subst
su Measure ty ctor
m = Measure ty ctor
m { msEqns :: [Def ty ctor]
msEqns = forall a. Subable a => Subst -> a -> a
F.subst  Subst
su forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall ty ctor. Measure ty ctor -> [Def ty ctor]
msEqns Measure ty ctor
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)  = (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Maybe ty)]
sb) forall a. [a] -> [a] -> [a]
++ 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) = 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 forall a b. (a -> b) -> a -> b
$ 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) = 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 forall a b. (a -> b) -> a -> b
$ 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) = 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 forall a b. (a -> b) -> a -> b
$ 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)       = forall a. Subable a => a -> [Symbol]
F.syms Expr
e
  syms (P Expr
e)       = forall a. Subable a => a -> [Symbol]
F.syms Expr
e
  syms (R Symbol
s Expr
e)     = Symbol
s forall a. a -> [a] -> [a]
: 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   (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   (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 (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   (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   (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 (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   (forall a. Subable a => Subst -> a -> a
F.subst Subst
su Expr
e)
  subst Subst
su (P Expr
e)   = Expr -> Body
P   (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 (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)     = forall a. Subable a => a -> [Symbol]
F.syms t
t
  syms (WithModel Doc
_ t
t) = forall a. Subable a => a -> [Symbol]
F.syms t
t
  substa :: (Symbol -> Symbol) -> WithModel t -> WithModel t
substa Symbol -> Symbol
f             = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f)
  substf :: (Symbol -> Expr) -> WithModel t -> WithModel t
substf Symbol -> Expr
f             = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f)
  subst :: Subst -> WithModel t -> WithModel t
subst Subst
su             = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (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
forall ty. Eq ty => RClass ty -> RClass ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RClass ty -> RClass ty -> Bool
$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
Eq, Int -> RClass ty -> ShowS
forall ty. Show ty => Int -> RClass ty -> ShowS
forall ty. Show ty => [RClass ty] -> ShowS
forall ty. Show ty => RClass ty -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RClass ty] -> ShowS
$cshowList :: forall ty. Show ty => [RClass ty] -> ShowS
show :: RClass ty -> [Char]
$cshow :: forall ty. Show ty => RClass ty -> [Char]
showsPrec :: Int -> RClass ty -> ShowS
$cshowsPrec :: forall ty. Show ty => Int -> RClass ty -> ShowS
Show, 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
<$ :: forall a b. a -> RClass b -> RClass a
$c<$ :: forall a b. a -> RClass b -> RClass a
fmap :: forall a b. (a -> b) -> RClass a -> RClass b
$cfmap :: forall a b. (a -> b) -> RClass a -> RClass b
Functor, RClass ty -> DataType
RClass ty -> Constr
forall {ty}. Data ty => Typeable (RClass ty)
forall ty. Data ty => RClass ty -> DataType
forall ty. Data ty => RClass ty -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
$cgmapM :: forall ty (m :: * -> *).
(Data ty, Monad m) =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> RClass ty -> [u]
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RClass ty -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
$cgmapQl :: forall ty r r'.
Data ty =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
gmapT :: (forall b. Data b => b -> b) -> RClass ty -> RClass ty
$cgmapT :: forall ty.
Data ty =>
(forall b. Data b => b -> b) -> RClass ty -> RClass ty
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
$cdataCast1 :: forall ty (t :: * -> *) (c :: * -> *).
(Data ty, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
dataTypeOf :: RClass ty -> DataType
$cdataTypeOf :: forall ty. Data ty => RClass ty -> DataType
toConstr :: RClass ty -> Constr
$ctoConstr :: forall ty. Data ty => RClass ty -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> 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)
Data, Typeable, 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
$cto :: forall ty x. Rep (RClass ty) x -> RClass ty
$cfrom :: forall ty x. RClass ty -> Rep (RClass ty) x
Generic)
    deriving 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
hash :: RClass ty -> Int
$chash :: forall ty. Hashable ty => RClass ty -> Int
hashWithSalt :: Int -> RClass ty -> Int
$chashWithSalt :: forall ty. Hashable ty => Int -> 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)
                = 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
<+> forall {a}. PPrint a => [a] -> Doc
supers [t]
ts) BTyCon
n [BTyVar]
as [(LocSymbol
m, 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 (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k   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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Doc] -> Doc
hcat 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 ()
_) = 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
<+> 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 (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k   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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Doc] -> Doc
hcat 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 forall a b. (a -> b) -> a -> b
$ Doc
hdr Doc -> Doc -> Doc
<+> Doc
dName Doc -> Doc -> Doc
<+> Doc
"where"
         forall a. a -> [a] -> [a]
: [ Int -> Doc -> Doc
nest Int
4 (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  (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k n
name Doc -> Doc -> Doc
<+> Doc
dArgs)
      dArgs :: Doc
dArgs    = [Doc] -> Doc
gaps    (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
args)
      gaps :: [Doc] -> Doc
gaps     = [Doc] -> Doc
hcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
" "
      bind :: a -> a -> Doc
bind a
m a
t = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
m Doc -> Doc -> Doc
<+> Doc
"=" Doc -> Doc -> 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 forall a b. (a -> b) -> a -> b
$ Doc
hdr Doc -> Doc -> Doc
<+> Doc
dName Doc -> Doc -> Doc
<+> Doc
"where"
         forall a. a -> [a] -> [a]
: [ Int -> Doc -> Doc
nest Int
4 (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  (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k n
name Doc -> Doc -> Doc
<+> Doc
dArgs)
      dArgs :: Doc
dArgs    = [Doc] -> Doc
gaps    (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
args)
      gaps :: [Doc] -> Doc
gaps     = [Doc] -> Doc
hcat 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 = 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 :: b
htype = a -> b
f (forall i t. HoleInfo i t -> t
htype HoleInfo i a
hinfo), henv :: AREnv b
henv = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall i t. HoleInfo i t -> AREnv t
henv HoleInfo i a
hinfo)}

instance (F.PPrint t) => F.PPrint (HoleInfo  i t) where
  pprintTidy :: Tidy -> HoleInfo i t -> Doc
pprintTidy Tidy
k HoleInfo i t
hinfo = [Char] -> Doc
text [Char]
"type:" Doc -> Doc -> Doc
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (forall i t. HoleInfo i t -> t
htype HoleInfo i t
hinfo)
                       Doc -> Doc -> Doc
<+> [Char] -> Doc
text [Char]
"\n loc:" Doc -> Doc -> Doc
<+> forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (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 (AnnInfo a -> DataType
AnnInfo a -> Constr
forall {a}. Data a => Typeable (AnnInfo a)
forall a. Data a => AnnInfo a -> DataType
forall a. Data a => AnnInfo a -> Constr
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 (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))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnInfo a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> AnnInfo a -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
gmapT :: (forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> 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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
dataTypeOf :: AnnInfo a -> DataType
$cdataTypeOf :: forall a. Data a => AnnInfo a -> DataType
toConstr :: AnnInfo a -> Constr
$ctoConstr :: forall a. Data a => AnnInfo a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> 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)
Data, Typeable, 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
$cto :: forall a x. Rep (AnnInfo a) x -> AnnInfo a
$cfrom :: forall a x. AnnInfo a -> Rep (AnnInfo a) x
Generic, 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
<$ :: forall a b. a -> AnnInfo b -> AnnInfo a
$c<$ :: forall a b. a -> AnnInfo b -> AnnInfo a
fmap :: forall a b. (a -> b) -> AnnInfo a -> AnnInfo b
$cfmap :: forall a b. (a -> b) -> AnnInfo a -> AnnInfo b
Functor)

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

instance Monoid (AnnInfo a) where
  mempty :: AnnInfo a
mempty  = forall a. HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
AI forall k v. HashMap k v
M.empty
  mappend :: AnnInfo a -> AnnInfo a -> AnnInfo a
mappend = 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 = forall a. HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
AI forall a b. (a -> b) -> a -> b
$ forall k v.
(Eq k, Hashable k) =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
M.unionWith 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 [[Char]]
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 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
$cto :: forall a x. Rep (Output a) x -> Output a
$cfrom :: forall a x. Output a -> Rep (Output a) x
Generic, 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
<$ :: forall a b. a -> Output b -> Output a
$c<$ :: forall a b. a -> Output b -> Output a
fmap :: forall a b. (a -> b) -> Output a -> Output b
$cfmap :: forall a b. (a -> b) -> Output a -> Output b
Functor)

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

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

instance Monoid (Output a) where
  mempty :: Output a
mempty  = forall a. Output a
emptyOutput
  mappend :: Output a -> Output a -> Output a
mappend = 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 [[Char]]
o_vars   =            forall a. Ord a => [a] -> [a]
sortNub forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Monoid a => a -> a -> a
mappend (forall a. Output a -> Maybe [[Char]]
o_vars   Output a
o1) (forall a. Output a -> Maybe [[Char]]
o_vars   Output a
o2)
               , o_types :: AnnInfo a
o_types  =                        forall a. Monoid a => a -> a -> a
mappend (forall a. Output a -> AnnInfo a
o_types  Output a
o1) (forall a. Output a -> AnnInfo a
o_types  Output a
o2)
               , o_templs :: AnnInfo a
o_templs =                        forall a. Monoid a => a -> a -> a
mappend (forall a. Output a -> AnnInfo a
o_templs Output a
o1) (forall a. Output a -> AnnInfo a
o_templs Output a
o2)
               , o_bots :: [SrcSpan]
o_bots   = forall a. Eq a => (a -> a -> Ordering) -> [a] -> [a]
sortNubBy SrcSpan -> SrcSpan -> Ordering
ordSrcSpan forall a b. (a -> b) -> a -> b
$ forall a. Monoid a => a -> a -> a
mappend (forall a. Output a -> [SrcSpan]
o_bots Output a
o1)   (forall a. Output a -> [SrcSpan]
o_bots   Output a
o2)
               , o_result :: ErrorResult
o_result =                        forall a. Monoid a => a -> a -> a
mappend (forall a. Output a -> ErrorResult
o_result Output a
o1) (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 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. 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
$cto :: forall x. Rep KVKind x -> KVKind
$cfrom :: forall x. KVKind -> Rep KVKind x
Generic, KVKind -> KVKind -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KVKind -> KVKind -> Bool
$c/= :: KVKind -> KVKind -> Bool
== :: KVKind -> KVKind -> Bool
$c== :: KVKind -> KVKind -> Bool
Eq, Eq 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
min :: KVKind -> KVKind -> KVKind
$cmin :: KVKind -> KVKind -> KVKind
max :: KVKind -> KVKind -> KVKind
$cmax :: KVKind -> KVKind -> KVKind
>= :: KVKind -> KVKind -> Bool
$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
compare :: KVKind -> KVKind -> Ordering
$ccompare :: KVKind -> KVKind -> Ordering
Ord, Int -> KVKind -> ShowS
[KVKind] -> ShowS
KVKind -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [KVKind] -> ShowS
$cshowList :: [KVKind] -> ShowS
show :: KVKind -> [Char]
$cshow :: KVKind -> [Char]
showsPrec :: Int -> KVKind -> ShowS
$cshowsPrec :: Int -> KVKind -> ShowS
Show, Typeable KVKind
KVKind -> DataType
KVKind -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KVKind -> m KVKind
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> KVKind -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KVKind -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KVKind -> r
gmapT :: (forall b. Data b => b -> b) -> KVKind -> KVKind
$cgmapT :: (forall b. Data b => b -> b) -> KVKind -> KVKind
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KVKind)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KVKind)
dataTypeOf :: KVKind -> DataType
$cdataTypeOf :: KVKind -> DataType
toConstr :: KVKind -> Constr
$ctoConstr :: KVKind -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KVKind
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KVKind
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KVKind -> c KVKind
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KVKind -> c KVKind
Data, Typeable)

instance Hashable KVKind

newtype KVProf = KVP (M.HashMap KVKind Int) deriving (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
$cto :: forall x. Rep KVProf x -> KVProf
$cfrom :: forall x. KVProf -> Rep KVProf x
Generic)

emptyKVProf :: KVProf
emptyKVProf :: KVProf
emptyKVProf = HashMap KVKind Int -> KVProf
KVP 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 forall a b. (a -> b) -> a -> b
$ forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
M.insert KVKind
k (Int
kn forall a. Num a => a -> a -> a
+ Int
n) HashMap KVKind Int
m
  where
    kn :: Int
kn                  = 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                   = 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
_ = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> [Char]
show

instance F.PPrint KVProf where
  pprintTidy :: Tidy -> KVProf -> Doc
pprintTidy Tidy
k (KVP HashMap KVKind Int
m) = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (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" 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 = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Expr -> Bool
isHole forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr]
F.conjuncts forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reft -> Expr
F.reftPred forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r. Reftable r => r -> Reft
F.toReft

instance F.Symbolic DataCon where
  symbol :: DataCon -> Symbol
symbol = forall a. Symbolic a => a -> Symbol
F.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
_ = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Outputable a => a -> [Char]
showPpr

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

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

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

instance Show DataCon where
  show :: DataCon -> [Char]
show = forall a. PPrint a => a -> [Char]
F.showpp

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

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

liquidEnd :: String
liquidEnd :: [Char]
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 (MSpec ty ctor -> DataType
MSpec ty ctor -> Constr
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 {ty} {ctor}.
(Data ty, Data ctor) =>
Typeable (MSpec ty ctor)
forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> DataType
forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> Constr
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 (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 e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
gmapMo :: 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)
gmapMp :: forall (m :: * -> *).
MonadPlus 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)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
$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)
gmapQi :: forall u. Int -> (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
gmapQ :: forall u. (forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
$cgmapQ :: forall ty ctor u.
(Data ty, Data ctor) =>
(forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
$cgmapQl :: forall ty ctor r r'.
(Data ty, Data ctor) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
gmapT :: (forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor
$cgmapT :: forall ty ctor.
(Data ty, Data ctor) =>
(forall b. Data b => b -> b) -> MSpec ty ctor -> 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))
$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))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
$cdataCast1 :: forall ty ctor (t :: * -> *) (c :: * -> *).
(Data ty, Data ctor, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
dataTypeOf :: MSpec ty ctor -> DataType
$cdataTypeOf :: forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> DataType
toConstr :: MSpec ty ctor -> Constr
$ctoConstr :: forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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)
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)
$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)
Data, Typeable, 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
$cto :: forall ty ctor x. Rep (MSpec ty ctor) x -> MSpec ty ctor
$cfrom :: forall ty ctor x. MSpec ty ctor -> Rep (MSpec ty ctor) x
Generic, 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
<$ :: forall a b. a -> MSpec ty b -> MSpec ty a
$c<$ :: forall ty a b. a -> MSpec ty b -> MSpec ty a
fmap :: forall a b. (a -> b) -> MSpec ty a -> MSpec ty b
$cfmap :: forall ty a b. (a -> b) -> MSpec ty a -> MSpec ty b
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) = forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (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)
                                    (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (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)
                                    (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) HashMap LocSymbol (Measure a ())
cm)
                                    (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (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                    = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k v. HashMap k v -> [(k, v)]
M.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 -> [Char]
show (MSpec HashMap Symbol [Def ty ctor]
ct HashMap LocSymbol (Measure ty ctor)
m HashMap LocSymbol (Measure ty ())
cm [Measure ty ctor]
im)
    = [Char]
"\nMSpec:\n" forall a. [a] -> [a] -> [a]
++
      [Char]
"\nctorMap:\t "  forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show HashMap Symbol [Def ty ctor]
ct forall a. [a] -> [a] -> [a]
++
      [Char]
"\nmeasMap:\t "  forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show HashMap LocSymbol (Measure ty ctor)
m  forall a. [a] -> [a] -> [a]
++
      [Char]
"\ncmeasMap:\t " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show HashMap LocSymbol (Measure ty ())
cm forall a. [a] -> [a] -> [a]
++
      [Char]
"\nimeas:\t "    forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show [Measure ty ctor]
im forall a. [a] -> [a] -> [a]
++
      [Char]
"\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)
    = forall a. UserError -> a
uError forall a b. (a -> b) -> a -> b
$ forall {a} {t}. PPrint a => Located a -> Located a -> TError t
err LocSymbol
k1 LocSymbol
k2
    | Bool
otherwise
    = forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec (forall k v.
(Eq k, Hashable k) =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
M.unionWith forall a. [a] -> [a] -> [a]
(++) HashMap Symbol [Def ty ctor]
c1 HashMap Symbol [Def ty ctor]
c2) (HashMap LocSymbol (Measure ty ctor)
m1 forall k v.
(Eq k, Hashable k) =>
HashMap k v -> HashMap k v -> HashMap k v
`M.union` HashMap LocSymbol (Measure ty ctor)
m2) (HashMap LocSymbol (Measure ty ())
cm1 forall k v.
(Eq k, Hashable k) =>
HashMap k v -> HashMap k v -> HashMap k v
`M.union` HashMap LocSymbol (Measure ty ())
cm2) ([Measure ty ctor]
im1 forall a. [a] -> [a] -> [a]
++ [Measure ty ctor]
im2)
    where
      dups :: [(LocSymbol, LocSymbol)]
dups = [(LocSymbol
k1, LocSymbol
k2) | LocSymbol
k1 <- forall k v. HashMap k v -> [k]
M.keys HashMap LocSymbol (Measure ty ctor)
m1 , LocSymbol
k2 <- forall k v. HashMap k v -> [k]
M.keys HashMap LocSymbol (Measure ty ctor)
m2, forall a. Located a -> a
F.val LocSymbol
k1 forall a. Eq a => a -> a -> Bool
== forall a. Located a -> a
F.val LocSymbol
k2]
      err :: Located a -> Located a -> TError t
err Located a
k1 Located a
k2 = forall t. SrcSpan -> Doc -> [SrcSpan] -> TError t
ErrDupMeas (forall a. Loc a => a -> SrcSpan
fSrcSpan Located a
k1) (forall a. PPrint a => a -> Doc
F.pprint (forall a. Located a -> a
F.val Located a
k1)) (forall a. Loc a => a -> SrcSpan
fSrcSpan 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 = forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec forall k v. HashMap k v
M.empty forall k v. HashMap k v
M.empty forall k v. HashMap k v
M.empty []
  mappend :: MSpec ty ctor -> MSpec ty ctor -> MSpec ty ctor
mappend = forall a. Semigroup a => a -> a -> a
(<>)



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

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

instance F.PPrint RTyVar where
  pprintTidy :: Tidy -> RTyVar -> Doc
pprintTidy Tidy
k (RTV Var
α)
   | PPEnv -> Bool
ppTyVar PPEnv
ppEnv  = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (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 = [Char] -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Outputable a => a -> [Char]
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 (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, t)]
ss) Doc -> Doc -> 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 = [Char] -> Doc
text [Char]
"\\" Doc -> Doc -> Doc
<-> [Doc] -> Doc
hsep (forall a. (Eq a, IsString a, PPrint a) => Tidy -> a -> Doc
ppRefSym Tidy
k forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Symbol]
ss forall a. [a] -> [a] -> [a]
++ [Maybe SubcId -> Symbol
F.vv 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
"" = [Char] -> Doc
text [Char]
"_"
ppRefSym Tidy
k a
s  = forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k a
s