{-# LANGUAGE StandaloneDeriving         #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveFunctor              #-}
{-# LANGUAGE DeriveFoldable             #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DeriveTraversable          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE TypeSynonymInstances       #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE UndecidableInstances       #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE ConstraintKinds            #-}
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE TupleSections              #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE DerivingVia                #-}

-- | 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

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

  -- * 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(..)

  -- * 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
  , rImpF, rFun, rCls, rRCls

  -- * 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
  , 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
  )
  where

import           Language.Haskell.Liquid.GHC.API hiding (Expr, Target, isFunTy, LM)
import           Data.String
import           GHC.Generics
import           PrelInfo                               (isNumericClass)
import           Prelude                          hiding  (error)
import qualified Prelude
import           TyCon

import           Control.Monad                          (liftM, liftM2, liftM3, liftM4)
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                             (fromMaybe, 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 
  }
 

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

data PPEnv = PP 
  { PPEnv -> Bool
ppPs    :: Bool -- ^ print abstract-predicates 
  , PPEnv -> Bool
ppTyVar :: Bool -- ^ print the unique suffix for each tyvar
  , PPEnv -> Bool
ppShort :: Bool -- ^ print the tycons without qualification 
  , PPEnv -> Bool
ppDebug :: Bool -- ^ gross with full info
  }
  deriving (Int -> PPEnv -> ShowS
[PPEnv] -> ShowS
PPEnv -> String
(Int -> PPEnv -> ShowS)
-> (PPEnv -> String) -> ([PPEnv] -> ShowS) -> Show PPEnv
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PPEnv] -> ShowS
$cshowList :: [PPEnv] -> ShowS
show :: PPEnv -> String
$cshow :: PPEnv -> String
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 -> String
(Int -> LogicMap -> ShowS)
-> (LogicMap -> String) -> ([LogicMap] -> ShowS) -> Show LogicMap
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogicMap] -> ShowS
$cshowList :: [LogicMap] -> ShowS
show :: LogicMap -> String
$cshow :: LogicMap -> String
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 HashMap Symbol LMap
forall k v. HashMap k v
M.empty HashMap Var (Maybe Symbol)
forall k v. HashMap k v
M.empty
  mappend :: LogicMap -> LogicMap -> LogicMap
mappend = LogicMap -> LogicMap -> LogicMap
forall a. Semigroup a => a -> a -> a
(<>)

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

toLogicMap :: [(F.LocSymbol, [Symbol], Expr)] -> LogicMap
toLogicMap :: [(LocSymbol, [Symbol], Expr)] -> LogicMap
toLogicMap [(LocSymbol, [Symbol], Expr)]
ls = LogicMap
forall a. Monoid a => a
mempty {lmSymDefs :: HashMap Symbol LMap
lmSymDefs = [(Symbol, LMap)] -> HashMap Symbol LMap
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
M.fromList ([(Symbol, LMap)] -> HashMap Symbol LMap)
-> [(Symbol, LMap)] -> HashMap Symbol LMap
forall a b. (a -> b) -> a -> b
$ ((LocSymbol, [Symbol], Expr) -> (Symbol, LMap))
-> [(LocSymbol, [Symbol], Expr)] -> [(Symbol, LMap)]
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) = (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
x, LMap :: LocSymbol -> [Symbol] -> Expr -> LMap
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
def
  | Just (LMap LocSymbol
_ [Symbol]
xs Expr
e) <- Symbol -> HashMap Symbol LMap -> Maybe LMap
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
f) (LogicMap -> HashMap Symbol LMap
lmSymDefs LogicMap
lmap)
  , [Symbol] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
xs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [Expr] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Expr]
es
  = Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst ([(Symbol, Expr)] -> Subst
F.mkSubst ([(Symbol, Expr)] -> Subst) -> [(Symbol, Expr)] -> Subst
forall a b. (a -> b) -> a -> b
$ [Symbol] -> [Expr] -> [(Symbol, Expr)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Symbol]
xs [Expr]
es) Expr
e
  | Just (LMap LocSymbol
_ [Symbol]
xs Expr
e) <- Symbol -> HashMap Symbol LMap -> Maybe LMap
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
f) (LogicMap -> HashMap Symbol LMap
lmSymDefs LogicMap
lmap)
  , Expr -> Bool
isApp Expr
e
  = Subst -> Expr -> Expr
forall a. Subable a => Subst -> a -> a
F.subst ([(Symbol, Expr)] -> Subst
F.mkSubst ([(Symbol, Expr)] -> Subst) -> [(Symbol, Expr)] -> Subst
forall a b. (a -> b) -> a -> b
$ [Symbol] -> [Expr] -> [(Symbol, Expr)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Symbol]
xs [Expr]
es) (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ Expr -> Int -> Expr
dropApp Expr
e ([Symbol] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
xs Int -> Int -> Int
forall a. Num a => a -> a -> a
- [Expr] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Expr]
es)
  | Bool
otherwise
  = Expr
def

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

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

data TyConP = TyConP
  { TyConP -> SourcePos
tcpLoc          :: !F.SourcePos
  , TyConP -> TyCon
tcpCon          :: !TyCon
  , TyConP -> [RTyVar]
tcpFreeTyVarsTy :: ![RTyVar]
  , TyConP -> [PVar RSort]
tcpFreePredTy   :: ![PVar RSort]
  , TyConP -> VarianceInfo
tcpVarianceTs   :: !VarianceInfo
  , TyConP -> VarianceInfo
tcpVariancePs   :: !VarianceInfo
  , TyConP -> Maybe SizeFun
tcpSizeFun      :: !(Maybe SizeFun)
  } deriving ((forall x. TyConP -> Rep TyConP x)
-> (forall x. Rep TyConP x -> TyConP) -> Generic TyConP
forall x. Rep TyConP x -> TyConP
forall x. TyConP -> Rep TyConP x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TyConP x -> TyConP
$cfrom :: forall x. TyConP -> Rep TyConP x
Generic, Typeable TyConP
DataType
Constr
Typeable TyConP
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TyConP -> c TyConP)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TyConP)
-> (TyConP -> Constr)
-> (TyConP -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TyConP))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConP))
-> ((forall b. Data b => b -> b) -> TyConP -> TyConP)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConP -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConP -> r)
-> (forall u. (forall d. Data d => d -> u) -> TyConP -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TyConP -> m TyConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConP -> m TyConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConP -> m TyConP)
-> Data TyConP
TyConP -> DataType
TyConP -> Constr
(forall b. Data b => b -> b) -> TyConP -> TyConP
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConP -> c TyConP
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cTyConP :: Constr
$tTyConP :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> TyConP -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConP -> u
gmapQ :: (forall d. Data d => d -> u) -> TyConP -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TyConP -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable TyConP
Data, Typeable)

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


-- TODO: just use Located instead of dc_loc, dc_locE
data DataConP = DataConP
  { DataConP -> SourcePos
dcpLoc        :: !F.SourcePos
  , DataConP -> DataCon
dcpCon        :: !DataCon                -- ^ Corresponding GHC DataCon 
  , DataConP -> [RTyVar]
dcpFreeTyVars :: ![RTyVar]               -- ^ Type parameters
  , DataConP -> [PVar RSort]
dcpFreePred   :: ![PVar RSort]           -- ^ Abstract Refinement parameters
  , DataConP -> [SpecType]
dcpTyConstrs  :: ![SpecType]             -- ^ ? Class constraints (via `dataConStupidTheta`)
  , DataConP -> [(Symbol, SpecType)]
dcpTyArgs     :: ![(Symbol, SpecType)]   -- ^ Value parameters
  , DataConP -> SpecType
dcpTyRes      :: !SpecType               -- ^ Result type
  -- , tyData     :: !SpecType               -- ^ The 'generic' ADT, see [NOTE:DataCon-Data]
  , DataConP -> Bool
dcpIsGadt     :: !Bool                   -- ^ Was this specified in GADT style (if so, DONT use function names as fields)
  , DataConP -> Symbol
dcpModule     :: !F.Symbol               -- ^ Which module was this defined in
  , DataConP -> SourcePos
dcpLocE       :: !F.SourcePos
  } deriving ((forall x. DataConP -> Rep DataConP x)
-> (forall x. Rep DataConP x -> DataConP) -> Generic DataConP
forall x. Rep DataConP x -> DataConP
forall x. DataConP -> Rep DataConP x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataConP x -> DataConP
$cfrom :: forall x. DataConP -> Rep DataConP x
Generic, Typeable DataConP
DataType
Constr
Typeable DataConP
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DataConP -> c DataConP)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataConP)
-> (DataConP -> Constr)
-> (DataConP -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataConP))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConP))
-> ((forall b. Data b => b -> b) -> DataConP -> DataConP)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataConP -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataConP -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataConP -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataConP -> m DataConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataConP -> m DataConP)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataConP -> m DataConP)
-> Data DataConP
DataConP -> DataType
DataConP -> Constr
(forall b. Data b => b -> b) -> DataConP -> DataConP
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConP -> c DataConP
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cDataConP :: Constr
$tDataConP :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> DataConP -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConP -> u
gmapQ :: (forall d. Data d => d -> u) -> DataConP -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataConP -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable 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
  { PVar t -> Symbol
pname :: !Symbol
  , PVar t -> PVKind t
ptype :: !(PVKind t)
  , PVar t -> Symbol
parg  :: !Symbol
  , PVar t -> [(t, Symbol, Expr)]
pargs :: ![(t, Symbol, Expr)]
  } deriving ((forall x. PVar t -> Rep (PVar t) x)
-> (forall x. Rep (PVar t) x -> PVar t) -> Generic (PVar t)
forall x. Rep (PVar t) x -> PVar t
forall x. PVar t -> Rep (PVar t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (PVar t) x -> PVar t
forall t x. PVar t -> Rep (PVar t) x
$cto :: forall t x. Rep (PVar t) x -> PVar t
$cfrom :: forall t x. PVar t -> Rep (PVar t) x
Generic, Typeable (PVar t)
DataType
Constr
Typeable (PVar t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PVar t -> c (PVar t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PVar t))
-> (PVar t -> Constr)
-> (PVar t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (PVar t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t)))
-> ((forall b. Data b => b -> b) -> PVar t -> PVar t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PVar t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PVar t -> r)
-> (forall u. (forall d. Data d => d -> u) -> PVar t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PVar t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PVar t -> m (PVar t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVar t -> m (PVar t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVar t -> m (PVar t))
-> Data (PVar t)
PVar t -> DataType
PVar t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
(forall b. Data b => b -> b) -> PVar t -> PVar t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> c (PVar t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVar t)
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 u. Int -> (forall d. Data d => d -> u) -> PVar t -> u
forall u. (forall d. Data d => d -> u) -> PVar t -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PVar t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVar t -> m (PVar t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVar t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVar t -> c (PVar t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVar t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVar t))
$cPV :: Constr
$tPVar :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> PVar t -> [u]
$cgmapQ :: forall t u. Data t => (forall d. Data d => d -> u) -> PVar t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (PVar t)
Data, Typeable, Int -> PVar t -> ShowS
[PVar t] -> ShowS
PVar t -> String
(Int -> PVar t -> ShowS)
-> (PVar t -> String) -> ([PVar t] -> ShowS) -> Show (PVar t)
forall t. Show t => Int -> PVar t -> ShowS
forall t. Show t => [PVar t] -> ShowS
forall t. Show t => PVar t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PVar t] -> ShowS
$cshowList :: forall t. Show t => [PVar t] -> ShowS
show :: PVar t -> String
$cshow :: forall t. Show t => PVar t -> String
showsPrec :: Int -> PVar t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> PVar t -> ShowS
Show, a -> PVar b -> PVar a
(a -> b) -> PVar a -> PVar b
(forall a b. (a -> b) -> PVar a -> PVar b)
-> (forall a b. a -> PVar b -> PVar a) -> Functor PVar
forall a b. a -> PVar b -> PVar a
forall a b. (a -> b) -> PVar a -> PVar b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> PVar b -> PVar a
$c<$ :: forall a b. a -> PVar b -> PVar a
fmap :: (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' = PVar t -> Symbol
forall t. PVar t -> Symbol
pname PVar t
pv Symbol -> Symbol -> Bool
forall a. Eq a => a -> a -> Bool
== PVar t -> Symbol
forall t. PVar t -> Symbol
pname PVar t
pv' {- UNIFY: What about: && eqArgs pv pv' -}

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

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

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

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

data PVKind t
  = PVProp t
  | PVHProp
  deriving ((forall x. PVKind t -> Rep (PVKind t) x)
-> (forall x. Rep (PVKind t) x -> PVKind t) -> Generic (PVKind t)
forall x. Rep (PVKind t) x -> PVKind t
forall x. PVKind t -> Rep (PVKind t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (PVKind t) x -> PVKind t
forall t x. PVKind t -> Rep (PVKind t) x
$cto :: forall t x. Rep (PVKind t) x -> PVKind t
$cfrom :: forall t x. PVKind t -> Rep (PVKind t) x
Generic, Typeable (PVKind t)
DataType
Constr
Typeable (PVKind t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PVKind t -> c (PVKind t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PVKind t))
-> (PVKind t -> Constr)
-> (PVKind t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (PVKind t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (PVKind t)))
-> ((forall b. Data b => b -> b) -> PVKind t -> PVKind t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PVKind t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PVKind t -> r)
-> (forall u. (forall d. Data d => d -> u) -> PVKind t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PVKind t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t))
-> Data (PVKind t)
PVKind t -> DataType
PVKind t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (PVKind t))
(forall b. Data b => b -> b) -> PVKind t -> PVKind t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVKind t -> c (PVKind t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVKind t)
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 u. Int -> (forall d. Data d => d -> u) -> PVKind t -> u
forall u. (forall d. Data d => d -> u) -> PVKind t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PVKind t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PVKind t -> m (PVKind t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PVKind t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PVKind t -> c (PVKind t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PVKind t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PVKind t))
$cPVHProp :: Constr
$cPVProp :: Constr
$tPVKind :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> PVKind t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> PVKind t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (PVKind t)
Data, Typeable, a -> PVKind b -> PVKind a
(a -> b) -> PVKind a -> PVKind b
(forall a b. (a -> b) -> PVKind a -> PVKind b)
-> (forall a b. a -> PVKind b -> PVKind a) -> Functor PVKind
forall a b. a -> PVKind b -> PVKind a
forall a b. (a -> b) -> PVKind a -> PVKind b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> PVKind b -> PVKind a
$c<$ :: forall a b. a -> PVKind b -> PVKind a
fmap :: (a -> b) -> PVKind a -> PVKind b
$cfmap :: forall a b. (a -> b) -> PVKind a -> PVKind b
Functor, PVKind a -> Bool
(a -> m) -> PVKind a -> m
(a -> b -> b) -> b -> PVKind a -> b
(forall m. Monoid m => PVKind m -> m)
-> (forall m a. Monoid m => (a -> m) -> PVKind a -> m)
-> (forall m a. Monoid m => (a -> m) -> PVKind a -> m)
-> (forall a b. (a -> b -> b) -> b -> PVKind a -> b)
-> (forall a b. (a -> b -> b) -> b -> PVKind a -> b)
-> (forall b a. (b -> a -> b) -> b -> PVKind a -> b)
-> (forall b a. (b -> a -> b) -> b -> PVKind a -> b)
-> (forall a. (a -> a -> a) -> PVKind a -> a)
-> (forall a. (a -> a -> a) -> PVKind a -> a)
-> (forall a. PVKind a -> [a])
-> (forall a. PVKind a -> Bool)
-> (forall a. PVKind a -> Int)
-> (forall a. Eq a => a -> PVKind a -> Bool)
-> (forall a. Ord a => PVKind a -> a)
-> (forall a. Ord a => PVKind a -> a)
-> (forall a. Num a => PVKind a -> a)
-> (forall a. Num a => PVKind a -> a)
-> Foldable PVKind
forall a. Eq a => a -> PVKind a -> Bool
forall a. Num a => PVKind a -> a
forall a. Ord a => PVKind a -> a
forall m. Monoid m => PVKind m -> m
forall a. PVKind a -> Bool
forall a. PVKind a -> Int
forall a. PVKind a -> [a]
forall a. (a -> a -> a) -> PVKind a -> a
forall m a. Monoid m => (a -> m) -> PVKind a -> m
forall b a. (b -> a -> b) -> b -> PVKind a -> b
forall a b. (a -> b -> b) -> b -> PVKind a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: PVKind a -> a
$cproduct :: forall a. Num a => PVKind a -> a
sum :: PVKind a -> a
$csum :: forall a. Num a => PVKind a -> a
minimum :: PVKind a -> a
$cminimum :: forall a. Ord a => PVKind a -> a
maximum :: PVKind a -> a
$cmaximum :: forall a. Ord a => PVKind a -> a
elem :: a -> PVKind a -> Bool
$celem :: forall a. Eq a => a -> PVKind a -> Bool
length :: PVKind a -> Int
$clength :: forall a. PVKind a -> Int
null :: PVKind a -> Bool
$cnull :: forall a. PVKind a -> Bool
toList :: PVKind a -> [a]
$ctoList :: forall a. PVKind a -> [a]
foldl1 :: (a -> a -> a) -> PVKind a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> PVKind a -> a
foldr1 :: (a -> a -> a) -> PVKind a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> PVKind a -> a
foldl' :: (b -> a -> b) -> b -> PVKind a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> PVKind a -> b
foldl :: (b -> a -> b) -> b -> PVKind a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> PVKind a -> b
foldr' :: (a -> b -> b) -> b -> PVKind a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> PVKind a -> b
foldr :: (a -> b -> b) -> b -> PVKind a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> PVKind a -> b
foldMap' :: (a -> m) -> PVKind a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> PVKind a -> m
foldMap :: (a -> m) -> PVKind a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> PVKind a -> m
fold :: PVKind m -> m
$cfold :: forall m. Monoid m => PVKind m -> m
F.Foldable, Functor PVKind
Foldable PVKind
Functor PVKind
-> Foldable PVKind
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> PVKind a -> f (PVKind b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    PVKind (f a) -> f (PVKind a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> PVKind a -> m (PVKind b))
-> (forall (m :: * -> *) a.
    Monad m =>
    PVKind (m a) -> m (PVKind a))
-> Traversable PVKind
(a -> f b) -> PVKind a -> f (PVKind b)
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 :: PVKind (m a) -> m (PVKind a)
$csequence :: forall (m :: * -> *) a. Monad m => PVKind (m a) -> m (PVKind a)
mapM :: (a -> m b) -> PVKind a -> m (PVKind b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> PVKind a -> m (PVKind b)
sequenceA :: PVKind (f a) -> f (PVKind a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
PVKind (f a) -> f (PVKind a)
traverse :: (a -> f b) -> PVKind a -> f (PVKind b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> PVKind a -> f (PVKind b)
$cp2Traversable :: Foldable PVKind
$cp1Traversable :: Functor PVKind
Traversable, Int -> PVKind t -> ShowS
[PVKind t] -> ShowS
PVKind t -> String
(Int -> PVKind t -> ShowS)
-> (PVKind t -> String) -> ([PVKind t] -> ShowS) -> Show (PVKind t)
forall t. Show t => Int -> PVKind t -> ShowS
forall t. Show t => [PVKind t] -> ShowS
forall t. Show t => PVKind t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PVKind t] -> ShowS
$cshowList :: forall t. Show t => [PVKind t] -> ShowS
show :: PVKind t -> String
$cshow :: forall t. Show t => PVKind t -> String
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. Predicate -> Rep Predicate x)
-> (forall x. Rep Predicate x -> Predicate) -> Generic Predicate
forall x. Rep Predicate x -> Predicate
forall x. Predicate -> Rep Predicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Predicate x -> Predicate
$cfrom :: forall x. Predicate -> Rep Predicate x
Generic, Typeable Predicate
DataType
Constr
Typeable Predicate
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Predicate -> c Predicate)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Predicate)
-> (Predicate -> Constr)
-> (Predicate -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Predicate))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Predicate))
-> ((forall b. Data b => b -> b) -> Predicate -> Predicate)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Predicate -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Predicate -> r)
-> (forall u. (forall d. Data d => d -> u) -> Predicate -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Predicate -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Predicate -> m Predicate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Predicate -> m Predicate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Predicate -> m Predicate)
-> Data Predicate
Predicate -> DataType
Predicate -> Constr
(forall b. Data b => b -> b) -> Predicate -> Predicate
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Predicate -> c Predicate
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cPr :: Constr
$tPredicate :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> Predicate -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Predicate -> u
gmapQ :: (forall d. Data d => d -> u) -> Predicate -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Predicate -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable Predicate
Data, Typeable)
  deriving Int -> Predicate -> Int
Predicate -> Int
(Int -> Predicate -> Int)
-> (Predicate -> Int) -> Hashable Predicate
forall 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)
      = [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> [Bool] -> Bool
forall a b. (a -> b) -> a -> b
$ ([UsedPVar] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [UsedPVar]
vs' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [UsedPVar] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [UsedPVar]
ws') Bool -> [Bool] -> [Bool]
forall a. a -> [a] -> [a]
: [UsedPVar
v UsedPVar -> UsedPVar -> Bool
forall a. Eq a => a -> a -> Bool
== UsedPVar
w | (UsedPVar
v, UsedPVar
w) <- [UsedPVar] -> [UsedPVar] -> [(UsedPVar, UsedPVar)]
forall a b. [a] -> [b] -> [(a, b)]
zip [UsedPVar]
vs' [UsedPVar]
ws']
        where
          vs' :: [UsedPVar]
vs' = [UsedPVar] -> [UsedPVar]
forall a. Ord a => [a] -> [a]
L.sort [UsedPVar]
vs
          ws' :: [UsedPVar]
ws' = [UsedPVar] -> [UsedPVar]
forall a. Ord a => [a] -> [a]
L.sort [UsedPVar]
ws



instance B.Binary Predicate

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

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

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

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

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


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

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

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

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


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

instance NFData r => NFData (UReft r)


newtype BTyVar = BTV Symbol deriving (Int -> BTyVar -> ShowS
[BTyVar] -> ShowS
BTyVar -> String
(Int -> BTyVar -> ShowS)
-> (BTyVar -> String) -> ([BTyVar] -> ShowS) -> Show BTyVar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BTyVar] -> ShowS
$cshowList :: [BTyVar] -> ShowS
show :: BTyVar -> String
$cshow :: BTyVar -> String
showsPrec :: Int -> BTyVar -> ShowS
$cshowsPrec :: Int -> BTyVar -> ShowS
Show, (forall x. BTyVar -> Rep BTyVar x)
-> (forall x. Rep BTyVar x -> BTyVar) -> Generic BTyVar
forall x. Rep BTyVar x -> BTyVar
forall x. BTyVar -> Rep BTyVar x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BTyVar x -> BTyVar
$cfrom :: forall x. BTyVar -> Rep BTyVar x
Generic, Typeable BTyVar
DataType
Constr
Typeable BTyVar
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BTyVar -> c BTyVar)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BTyVar)
-> (BTyVar -> Constr)
-> (BTyVar -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BTyVar))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyVar))
-> ((forall b. Data b => b -> b) -> BTyVar -> BTyVar)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyVar -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyVar -> r)
-> (forall u. (forall d. Data d => d -> u) -> BTyVar -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BTyVar -> m BTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyVar -> m BTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyVar -> m BTyVar)
-> Data BTyVar
BTyVar -> DataType
BTyVar -> Constr
(forall b. Data b => b -> b) -> BTyVar -> BTyVar
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyVar -> c BTyVar
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cBTV :: Constr
$tBTyVar :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> BTyVar -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyVar -> u
gmapQ :: (forall d. Data d => d -> u) -> BTyVar -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BTyVar -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable BTyVar
Data, Typeable)

newtype RTyVar = RTV TyVar deriving ((forall x. RTyVar -> Rep RTyVar x)
-> (forall x. Rep RTyVar x -> RTyVar) -> Generic RTyVar
forall x. Rep RTyVar x -> RTyVar
forall x. RTyVar -> Rep RTyVar x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RTyVar x -> RTyVar
$cfrom :: forall x. RTyVar -> Rep RTyVar x
Generic, Typeable RTyVar
DataType
Constr
Typeable RTyVar
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RTyVar -> c RTyVar)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RTyVar)
-> (RTyVar -> Constr)
-> (RTyVar -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RTyVar))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyVar))
-> ((forall b. Data b => b -> b) -> RTyVar -> RTyVar)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyVar -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyVar -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTyVar -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RTyVar -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTyVar -> m RTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyVar -> m RTyVar)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyVar -> m RTyVar)
-> Data RTyVar
RTyVar -> DataType
RTyVar -> Constr
(forall b. Data b => b -> b) -> RTyVar -> RTyVar
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyVar -> c RTyVar
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cRTV :: Constr
$tRTyVar :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> RTyVar -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTyVar -> u
gmapQ :: (forall d. Data d => d -> u) -> RTyVar -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RTyVar -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable RTyVar
Data, Typeable)

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

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

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

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

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

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

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

data BTyCon = BTyCon
  { BTyCon -> LocSymbol
btc_tc    :: !F.LocSymbol    -- ^ TyCon name with location information
  , BTyCon -> Bool
btc_class :: !Bool           -- ^ Is this a class type constructor?
  , BTyCon -> Bool
btc_prom  :: !Bool           -- ^ Is Promoted Data Con?
  }
  deriving ((forall x. BTyCon -> Rep BTyCon x)
-> (forall x. Rep BTyCon x -> BTyCon) -> Generic BTyCon
forall x. Rep BTyCon x -> BTyCon
forall x. BTyCon -> Rep BTyCon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BTyCon x -> BTyCon
$cfrom :: forall x. BTyCon -> Rep BTyCon x
Generic, Typeable BTyCon
DataType
Constr
Typeable BTyCon
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BTyCon -> c BTyCon)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BTyCon)
-> (BTyCon -> Constr)
-> (BTyCon -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BTyCon))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BTyCon))
-> ((forall b. Data b => b -> b) -> BTyCon -> BTyCon)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyCon -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BTyCon -> r)
-> (forall u. (forall d. Data d => d -> u) -> BTyCon -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BTyCon -> m BTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyCon -> m BTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BTyCon -> m BTyCon)
-> Data BTyCon
BTyCon -> DataType
BTyCon -> Constr
(forall b. Data b => b -> b) -> BTyCon -> BTyCon
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BTyCon -> c BTyCon
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cBTyCon :: Constr
$tBTyCon :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> BTyCon -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BTyCon -> u
gmapQ :: (forall d. Data d => d -> u) -> BTyCon -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BTyCon -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable BTyCon
Data, Typeable)
  deriving Int -> BTyCon -> Int
BTyCon -> Int
(Int -> BTyCon -> Int) -> (BTyCon -> Int) -> Hashable BTyCon
forall 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 -> [PVar RSort]
rtc_pvars :: ![RPVar]      -- ^ Predicate Parameters
  , RTyCon -> TyConInfo
rtc_info  :: !TyConInfo    -- ^ TyConInfo
  }
  deriving ((forall x. RTyCon -> Rep RTyCon x)
-> (forall x. Rep RTyCon x -> RTyCon) -> Generic RTyCon
forall x. Rep RTyCon x -> RTyCon
forall x. RTyCon -> Rep RTyCon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RTyCon x -> RTyCon
$cfrom :: forall x. RTyCon -> Rep RTyCon x
Generic, Typeable RTyCon
DataType
Constr
Typeable RTyCon
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RTyCon -> c RTyCon)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RTyCon)
-> (RTyCon -> Constr)
-> (RTyCon -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RTyCon))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RTyCon))
-> ((forall b. Data b => b -> b) -> RTyCon -> RTyCon)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyCon -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTyCon -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTyCon -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RTyCon -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTyCon -> m RTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyCon -> m RTyCon)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTyCon -> m RTyCon)
-> Data RTyCon
RTyCon -> DataType
RTyCon -> Constr
(forall b. Data b => b -> b) -> RTyCon -> RTyCon
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTyCon -> c RTyCon
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cRTyCon :: Constr
$tRTyCon :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> RTyCon -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RTyCon -> u
gmapQ :: (forall d. Data d => d -> u) -> RTyCon -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RTyCon -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable RTyCon
Data, Typeable)

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

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

instance NFData BTyCon

instance NFData RTyCon

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

tyVarVar :: RTVar RTyVar c -> Var
tyVarVar :: 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 :: RType RTyCon t t1 -> Bool
isBool (RApp (RTyCon{rtc_tc :: RTyCon -> TyCon
rtc_tc = TyCon
c}) [RType RTyCon t t1]
_ [RTProp RTyCon t t1]
_ t1
_) = TyCon
c TyCon -> TyCon -> Bool
forall a. Eq a => a -> a -> Bool
== TyCon
boolTyCon
isBool RType RTyCon t t1
_                                 = Bool
False

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

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

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

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

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

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

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


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

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

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


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

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


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

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

data TyConInfo = TyConInfo
  { TyConInfo -> VarianceInfo
varianceTyArgs  :: !VarianceInfo      -- ^ variance info for type variables
  , TyConInfo -> VarianceInfo
variancePsArgs  :: !VarianceInfo      -- ^ variance info for predicate variables
  , TyConInfo -> Maybe SizeFun
sizeFunction    :: !(Maybe SizeFun)   -- ^ logical UNARY function that computes the size of the structure
  } deriving ((forall x. TyConInfo -> Rep TyConInfo x)
-> (forall x. Rep TyConInfo x -> TyConInfo) -> Generic TyConInfo
forall x. Rep TyConInfo x -> TyConInfo
forall x. TyConInfo -> Rep TyConInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TyConInfo x -> TyConInfo
$cfrom :: forall x. TyConInfo -> Rep TyConInfo x
Generic, Typeable TyConInfo
DataType
Constr
Typeable TyConInfo
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TyConInfo -> c TyConInfo)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TyConInfo)
-> (TyConInfo -> Constr)
-> (TyConInfo -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TyConInfo))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyConInfo))
-> ((forall b. Data b => b -> b) -> TyConInfo -> TyConInfo)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConInfo -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TyConInfo -> r)
-> (forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TyConInfo -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TyConInfo -> m TyConInfo)
-> Data TyConInfo
TyConInfo -> DataType
TyConInfo -> Constr
(forall b. Data b => b -> b) -> TyConInfo -> TyConInfo
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TyConInfo -> c TyConInfo
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cTyConInfo :: Constr
$tTyConInfo :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TyConInfo -> u
gmapQ :: (forall d. Data d => d -> u) -> TyConInfo -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TyConInfo -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable TyConInfo
Data, Typeable)

instance NFData TyConInfo

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

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

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

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

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

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

  | RImpF  {
      rt_bind   :: !Symbol
    , rt_in     :: !(RType c tv r)
    , rt_out    :: !(RType c tv r)
    , rt_reft   :: !r
    }

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

  -- | "forall x y <z :: Nat, w :: Int> . TYPE"
  --               ^^^^^^^^^^^^^^^^^^^ (rt_pvbind)
  | RAllP {
      RType c tv r -> PVU c tv
rt_pvbind :: !(PVU c tv)  -- ar (RType 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  {
      RType c tv r -> c
rt_tycon  :: !c
    , RType c tv r -> [RType c tv r]
rt_args   :: ![RType  c tv r]
    , RType c tv r -> [RTProp c tv r]
rt_pargs  :: ![RTProp c tv r]
    , rt_reft   :: !r
    }

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

  | REx {
      rt_bind   :: !Symbol
    , 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{
      RType c tv r -> RType c tv r
rt_arg   :: !(RType c tv r)
    , RType c tv r -> RType c tv r
rt_res   :: !(RType c tv r)
    , rt_reft  :: !r
    }

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

  | RHole r -- ^ let LH match against the Haskell type and add k-vars, e.g. `x:_`
            --   see tests/pos/Holes.hs
  deriving (RType c tv r -> RType c tv r -> Bool
(RType c tv r -> RType c tv r -> Bool)
-> (RType c tv r -> RType c tv r -> Bool) -> Eq (RType c tv r)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall c tv r.
(Eq tv, Eq 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 x. RType c tv r -> Rep (RType c tv r) x)
-> (forall x. Rep (RType c tv r) x -> RType c tv r)
-> Generic (RType c tv r)
forall x. Rep (RType c tv r) x -> RType c tv r
forall x. RType c tv r -> Rep (RType c tv r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c tv r x. Rep (RType c tv r) x -> RType c tv r
forall c tv r x. RType c tv r -> Rep (RType c tv r) x
$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, Typeable (RType c tv r)
DataType
Constr
Typeable (RType c tv r)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RType c tv r))
-> (RType c tv r -> Constr)
-> (RType c tv r -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RType c tv r)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RType c tv r)))
-> ((forall b. Data b => b -> b) -> RType c tv r -> RType c tv r)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RType c tv r -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RType c tv r -> r)
-> (forall u. (forall d. Data d => d -> u) -> RType c tv r -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RType c tv r -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r))
-> Data (RType c tv r)
RType c tv r -> DataType
RType c tv r -> Constr
(forall b. Data b => b -> b) -> RType c tv r -> RType c tv 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 b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RType c tv r -> u
forall u. (forall d. Data d => d -> u) -> RType c tv r -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RType c tv r -> r
forall c tv r. (Data 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 (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RType c tv r -> m (RType c tv r)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RType c tv r)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RType c tv r -> c (RType c tv r)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RType c tv r))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RType c tv r))
$cRHole :: Constr
$cRRTy :: Constr
$cRAppTy :: Constr
$cRExprArg :: Constr
$cREx :: Constr
$cRAllE :: Constr
$cRApp :: Constr
$cRAllP :: Constr
$cRAllT :: Constr
$cRImpF :: Constr
$cRFun :: Constr
$cRVar :: Constr
$tRType :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall c tv r. (Data c, Data tv, Data r) => Typeable (RType c tv r)
Data, Typeable, a -> RType c tv b -> RType c tv a
(a -> b) -> RType c tv a -> RType c tv b
(forall a b. (a -> b) -> RType c tv a -> RType c tv b)
-> (forall a b. a -> RType c tv b -> RType c tv a)
-> Functor (RType c tv)
forall a b. a -> RType c tv b -> RType c tv a
forall a b. (a -> b) -> RType c tv a -> RType c tv b
forall c tv a b. a -> RType c tv b -> RType c tv a
forall c tv a b. (a -> b) -> RType c tv a -> RType c tv b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: 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 :: (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
(Int -> RType c tv r -> Int)
-> (RType c tv r -> Int) -> Hashable (RType c tv r)
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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 :: RType t t1 t2 -> RType t t1 t2
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

dropImplicits :: RType c tv r -> RType c tv r
dropImplicits :: RType c tv r -> RType c tv r
dropImplicits (RImpF Symbol
_ RType c tv r
_ RType c tv r
o r
_) = RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
o
dropImplicits (RFun  Symbol
x RType c tv r
i RType c tv r
o r
r) = Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun Symbol
x (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
i) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
o) r
r
dropImplicits (RAllP PVU c tv
p RType c tv r
t) = PVU c tv -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP PVU c tv
p (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t)
dropImplicits (RAllT RTVU c tv
p RType c tv r
t r
r) = RTVU c tv -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVU c tv
p (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t) r
r
dropImplicits (RApp c
c [RType c tv r]
as [RTProp c tv r]
ps r
r) = c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
forall c tv r.
c -> [RType c tv r] -> [RTProp c tv r] -> r -> RType c tv r
RApp c
c (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits (RType c tv r -> RType c tv r) -> [RType c tv r] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RType c tv r]
as) (RTProp c tv r -> RTProp c tv r
forall c tv r. RTProp c tv r -> RTProp c tv r
dropImplicitsRP (RTProp c tv r -> RTProp c tv r)
-> [RTProp c tv r] -> [RTProp c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [RTProp c tv r]
ps) r
r
dropImplicits (RAllE Symbol
p RType c tv r
t RType c tv r
t') = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
RAllE Symbol
p (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t')
dropImplicits (REx Symbol
s RType c tv r
t RType c tv r
t')   = Symbol -> RType c tv r -> RType c tv r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> RType c tv r
REx   Symbol
s (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t')
dropImplicits (RAppTy RType c tv r
t RType c tv r
t' r
r)   = RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r -> r -> RType c tv r
RAppTy (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t') r
r
dropImplicits (RRTy [(Symbol, RType c tv r)]
e r
r Oblig
o RType c tv r
t) = [(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy ((RType c tv r -> RType c tv r)
-> (Symbol, RType c tv r) -> (Symbol, RType c tv r)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits ((Symbol, RType c tv r) -> (Symbol, RType c tv r))
-> [(Symbol, RType c tv r)] -> [(Symbol, RType c tv r)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e) r
r Oblig
o (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
t)
dropImplicits RType c tv r
t = RType c tv r
t

dropImplicitsRP :: RTProp c tv r -> RTProp c tv r
dropImplicitsRP :: RTProp c tv r -> RTProp c tv r
dropImplicitsRP (RProp [(Symbol, RType c tv ())]
as RType c tv r
b) = [(Symbol, RType c tv ())] -> RType c tv r -> RTProp c tv r
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp ((RType c tv () -> RType c tv ())
-> (Symbol, RType c tv ()) -> (Symbol, RType c tv ())
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second RType c tv () -> RType c tv ()
forall c tv r. RType c tv r -> RType c tv r
dropImplicits ((Symbol, RType c tv ()) -> (Symbol, RType c tv ()))
-> [(Symbol, RType c tv ())] -> [(Symbol, RType c tv ())]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv ())]
as) (RType c tv r -> RType c tv r
forall c tv r. RType c tv r -> RType c tv r
dropImplicits RType c tv r
b)


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

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

data RTVar tv s = RTVar
  { RTVar tv s -> tv
ty_var_value :: tv
  , RTVar tv s -> RTVInfo s
ty_var_info  :: RTVInfo s
  } deriving ((forall x. RTVar tv s -> Rep (RTVar tv s) x)
-> (forall x. Rep (RTVar tv s) x -> RTVar tv s)
-> Generic (RTVar tv s)
forall x. Rep (RTVar tv s) x -> RTVar tv s
forall x. RTVar tv s -> Rep (RTVar tv s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall tv s x. Rep (RTVar tv s) x -> RTVar tv s
forall tv s x. RTVar tv s -> Rep (RTVar tv s) x
$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, Typeable (RTVar tv s)
DataType
Constr
Typeable (RTVar tv s)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RTVar tv s))
-> (RTVar tv s -> Constr)
-> (RTVar tv s -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RTVar tv s)))
-> ((forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv s)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTVar tv s -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s))
-> Data (RTVar tv s)
RTVar tv s -> DataType
RTVar tv s -> Constr
(forall b. Data b => b -> b) -> RTVar tv s -> RTVar tv 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 b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTVar tv s -> u
forall u. (forall d. Data d => d -> u) -> RTVar tv s -> [u]
forall tv s. (Data 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 r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVar tv s -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVar tv s -> m (RTVar tv s)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVar tv s)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVar tv s -> c (RTVar tv s)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVar tv s))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVar tv s))
$cRTVar :: Constr
$tRTVar :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall tv s. (Data tv, Data s) => Typeable (RTVar tv s)
Data, Typeable)
    deriving Int -> RTVar tv s -> Int
RTVar tv s -> Int
(Int -> RTVar tv s -> Int)
-> (RTVar tv s -> Int) -> Hashable (RTVar tv s)
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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 :: (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 (tv1 -> tv2) -> tv1 -> tv2
forall a b. (a -> b) -> a -> b
$ RTVar tv1 s -> tv1
forall tv s. RTVar tv s -> tv
ty_var_value RTVar tv1 s
v}

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

data RTVInfo s
  = RTVNoInfo { RTVInfo s -> Bool
rtv_is_pol :: Bool }
  | RTVInfo { RTVInfo s -> Symbol
rtv_name   :: Symbol
            , RTVInfo s -> s
rtv_kind   :: s
            , RTVInfo s -> Bool
rtv_is_val :: Bool
            , rtv_is_pol :: Bool -- true iff the type variable gets instantiated with 
                                 -- any refinement (ie is polymorphic on refinements), 
                                 -- false iff instantiation is with true refinement 
            } deriving ((forall x. RTVInfo s -> Rep (RTVInfo s) x)
-> (forall x. Rep (RTVInfo s) x -> RTVInfo s)
-> Generic (RTVInfo s)
forall x. Rep (RTVInfo s) x -> RTVInfo s
forall x. RTVInfo s -> Rep (RTVInfo s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall s x. Rep (RTVInfo s) x -> RTVInfo s
forall s x. RTVInfo s -> Rep (RTVInfo s) x
$cto :: forall s x. Rep (RTVInfo s) x -> RTVInfo s
$cfrom :: forall s x. RTVInfo s -> Rep (RTVInfo s) x
Generic, Typeable (RTVInfo s)
DataType
Constr
Typeable (RTVInfo s)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RTVInfo s))
-> (RTVInfo s -> Constr)
-> (RTVInfo s -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RTVInfo s)))
-> ((forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTVInfo s -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s))
-> Data (RTVInfo s)
RTVInfo s -> DataType
RTVInfo s -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
(forall b. Data b => b -> b) -> RTVInfo s -> RTVInfo s
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVInfo s)
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 u. Int -> (forall d. Data d => d -> u) -> RTVInfo s -> u
forall u. (forall d. Data d => d -> u) -> RTVInfo s -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTVInfo s -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTVInfo s -> m (RTVInfo s)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTVInfo s)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTVInfo s -> c (RTVInfo s)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTVInfo s))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTVInfo s))
$cRTVInfo :: Constr
$cRTVNoInfo :: Constr
$tRTVInfo :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> RTVInfo s -> [u]
$cgmapQ :: forall s u.
Data s =>
(forall d. Data d => d -> u) -> RTVInfo s -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall s. Data s => Typeable (RTVInfo s)
Data, Typeable, a -> RTVInfo b -> RTVInfo a
(a -> b) -> RTVInfo a -> RTVInfo b
(forall a b. (a -> b) -> RTVInfo a -> RTVInfo b)
-> (forall a b. a -> RTVInfo b -> RTVInfo a) -> Functor RTVInfo
forall a b. a -> RTVInfo b -> RTVInfo a
forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RTVInfo b -> RTVInfo a
$c<$ :: forall a b. a -> RTVInfo b -> RTVInfo a
fmap :: (a -> b) -> RTVInfo a -> RTVInfo b
$cfmap :: forall a b. (a -> b) -> RTVInfo a -> RTVInfo b
Functor)
              deriving Int -> RTVInfo s -> Int
RTVInfo s -> Int
(Int -> RTVInfo s -> Int)
-> (RTVInfo s -> Int) -> Hashable (RTVInfo s)
forall s. Hashable s => Int -> RTVInfo s -> Int
forall s. Hashable s => RTVInfo s -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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 :: RTVar tv a -> Bool -> RTVar tv a
setRtvPol (RTVar tv
a RTVInfo a
i) Bool
b = tv -> RTVInfo a -> RTVar tv a
forall tv s. tv -> RTVInfo s -> RTVar tv s
RTVar tv
a (RTVInfo a
i{rtv_is_pol :: Bool
rtv_is_pol = Bool
b})

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

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

rtvinfo_is_val :: RTVInfo s -> Bool
rtvinfo_is_val :: RTVInfo s -> Bool
rtvinfo_is_val (RTVNoInfo {Bool
rtv_is_pol :: Bool
rtv_is_pol :: forall s. RTVInfo s -> Bool
..}) = Bool
False
rtvinfo_is_val (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
  { Ref τ t -> [(Symbol, τ)]
rf_args :: [(Symbol, τ)]
  , Ref τ t -> t
rf_body :: t -- ^ Abstract refinement associated with `RTyCon`
  } deriving (Ref τ t -> Ref τ t -> Bool
(Ref τ t -> Ref τ t -> Bool)
-> (Ref τ t -> Ref τ t -> Bool) -> Eq (Ref τ t)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall τ t. (Eq τ, Eq t) => Ref τ t -> Ref τ t -> Bool
/= :: 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 x. Ref τ t -> Rep (Ref τ t) x)
-> (forall x. Rep (Ref τ t) x -> Ref τ t) -> Generic (Ref τ t)
forall x. Rep (Ref τ t) x -> Ref τ t
forall x. Ref τ t -> Rep (Ref τ t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall τ t x. Rep (Ref τ t) x -> Ref τ t
forall τ t x. Ref τ t -> Rep (Ref τ t) x
$cto :: forall τ t x. Rep (Ref τ t) x -> Ref τ t
$cfrom :: forall τ t x. Ref τ t -> Rep (Ref τ t) x
Generic, Typeable (Ref τ t)
DataType
Constr
Typeable (Ref τ t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Ref τ t))
-> (Ref τ t -> Constr)
-> (Ref τ t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Ref τ t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t)))
-> ((forall b. Data b => b -> b) -> Ref τ t -> Ref τ t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Ref τ t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Ref τ t -> r)
-> (forall u. (forall d. Data d => d -> u) -> Ref τ t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Ref τ t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t))
-> Data (Ref τ t)
Ref τ t -> DataType
Ref τ t -> Constr
(forall b. Data b => b -> b) -> Ref τ t -> Ref τ t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Ref τ t)
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Ref τ t -> u
forall u. (forall d. Data d => d -> u) -> Ref τ t -> [u]
forall τ t. (Data τ, Data t) => Typeable (Ref τ t)
forall τ t. (Data τ, Data t) => Ref τ t -> 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 r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Ref τ t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Ref τ t -> m (Ref τ t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Ref τ t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Ref τ t -> c (Ref τ t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Ref τ t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ref τ t))
$cRProp :: Constr
$tRef :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall τ t. (Data τ, Data t) => Typeable (Ref τ t)
Data, Typeable, a -> Ref τ b -> Ref τ a
(a -> b) -> Ref τ a -> Ref τ b
(forall a b. (a -> b) -> Ref τ a -> Ref τ b)
-> (forall a b. a -> Ref τ b -> Ref τ a) -> Functor (Ref τ)
forall a b. a -> Ref τ b -> Ref τ a
forall a b. (a -> b) -> Ref τ a -> Ref τ b
forall τ a b. a -> Ref τ b -> Ref τ a
forall τ a b. (a -> b) -> Ref τ a -> Ref τ b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Ref τ b -> Ref τ a
$c<$ :: forall τ a b. a -> Ref τ b -> Ref τ a
fmap :: (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
(Int -> Ref τ t -> Int) -> (Ref τ t -> Int) -> Hashable (Ref τ t)
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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 :: [(Symbol, τ)] -> r -> Ref τ (RType c tv r)
rPropP [(Symbol, τ)]
τ r
r = [(Symbol, τ)] -> RType c tv r -> Ref τ (RType c tv r)
forall τ t. [(Symbol, τ)] -> t -> Ref τ t
RProp [(Symbol, τ)]
τ (r -> RType c tv r
forall c tv r. r -> RType c tv r
RHole r
r)

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


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

newtype World t = World [HSeg t]
                deriving ((forall x. World t -> Rep (World t) x)
-> (forall x. Rep (World t) x -> World t) -> Generic (World t)
forall x. Rep (World t) x -> World t
forall x. World t -> Rep (World t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (World t) x -> World t
forall t x. World t -> Rep (World t) x
$cto :: forall t x. Rep (World t) x -> World t
$cfrom :: forall t x. World t -> Rep (World t) x
Generic, Typeable (World t)
DataType
Constr
Typeable (World t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> World t -> c (World t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (World t))
-> (World t -> Constr)
-> (World t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (World t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t)))
-> ((forall b. Data b => b -> b) -> World t -> World t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> World t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> World t -> r)
-> (forall u. (forall d. Data d => d -> u) -> World t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> World t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> World t -> m (World t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> World t -> m (World t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> World t -> m (World t))
-> Data (World t)
World t -> DataType
World t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (World t))
(forall b. Data b => b -> b) -> World t -> World t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> c (World t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (World t)
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 u. Int -> (forall d. Data d => d -> u) -> World t -> u
forall u. (forall d. Data d => d -> u) -> World t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> World t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> World t -> m (World t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (World t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> World t -> c (World t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (World t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (World t))
$cWorld :: Constr
$tWorld :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> World t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> World t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (World t)
Data, Typeable)

data    HSeg  t = HBind {HSeg t -> Symbol
hs_addr :: !Symbol, HSeg t -> t
hs_val :: t}
                | HVar UsedPVar
                deriving ((forall x. HSeg t -> Rep (HSeg t) x)
-> (forall x. Rep (HSeg t) x -> HSeg t) -> Generic (HSeg t)
forall x. Rep (HSeg t) x -> HSeg t
forall x. HSeg t -> Rep (HSeg t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (HSeg t) x -> HSeg t
forall t x. HSeg t -> Rep (HSeg t) x
$cto :: forall t x. Rep (HSeg t) x -> HSeg t
$cfrom :: forall t x. HSeg t -> Rep (HSeg t) x
Generic, Typeable (HSeg t)
DataType
Constr
Typeable (HSeg t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HSeg t -> c (HSeg t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (HSeg t))
-> (HSeg t -> Constr)
-> (HSeg t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (HSeg t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t)))
-> ((forall b. Data b => b -> b) -> HSeg t -> HSeg t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HSeg t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HSeg t -> r)
-> (forall u. (forall d. Data d => d -> u) -> HSeg t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> HSeg t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t))
-> Data (HSeg t)
HSeg t -> DataType
HSeg t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
(forall b. Data b => b -> b) -> HSeg t -> HSeg t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> c (HSeg t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HSeg t)
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 u. Int -> (forall d. Data d => d -> u) -> HSeg t -> u
forall u. (forall d. Data d => d -> u) -> HSeg t -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HSeg t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HSeg t -> m (HSeg t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HSeg t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HSeg t -> c (HSeg t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (HSeg t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HSeg t))
$cHVar :: Constr
$cHBind :: Constr
$tHSeg :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> HSeg t -> [u]
$cgmapQ :: forall t u. Data t => (forall d. Data d => d -> u) -> HSeg t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (HSeg t)
Data, Typeable)

data UReft r = MkUReft
  { UReft r -> r
ur_reft   :: !r
  , UReft r -> Predicate
ur_pred   :: !Predicate
  }
  deriving (UReft r -> UReft r -> Bool
(UReft r -> UReft r -> Bool)
-> (UReft r -> UReft r -> Bool) -> Eq (UReft r)
forall r. Eq r => UReft r -> UReft r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: 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 x. UReft r -> Rep (UReft r) x)
-> (forall x. Rep (UReft r) x -> UReft r) -> Generic (UReft r)
forall x. Rep (UReft r) x -> UReft r
forall x. UReft r -> Rep (UReft r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (UReft r) x -> UReft r
forall r x. UReft r -> Rep (UReft r) x
$cto :: forall r x. Rep (UReft r) x -> UReft r
$cfrom :: forall r x. UReft r -> Rep (UReft r) x
Generic, Typeable (UReft r)
DataType
Constr
Typeable (UReft r)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> UReft r -> c (UReft r))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (UReft r))
-> (UReft r -> Constr)
-> (UReft r -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (UReft r)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r)))
-> ((forall b. Data b => b -> b) -> UReft r -> UReft r)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UReft r -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UReft r -> r)
-> (forall u. (forall d. Data d => d -> u) -> UReft r -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> UReft r -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> UReft r -> m (UReft r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UReft r -> m (UReft r))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UReft r -> m (UReft r))
-> Data (UReft r)
UReft r -> DataType
UReft r -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
(forall b. Data b => b -> b) -> UReft r -> UReft r
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> c (UReft r)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UReft r)
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 u. Int -> (forall d. Data d => d -> u) -> UReft r -> u
forall u. (forall d. Data d => d -> u) -> UReft r -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UReft r -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UReft r -> m (UReft r)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UReft r)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UReft r -> c (UReft r)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UReft r))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UReft r))
$cMkUReft :: Constr
$tUReft :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> UReft r -> [u]
$cgmapQ :: forall r u.
Data r =>
(forall d. Data d => d -> u) -> UReft r -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall r. Data r => Typeable (UReft r)
Data, Typeable, a -> UReft b -> UReft a
(a -> b) -> UReft a -> UReft b
(forall a b. (a -> b) -> UReft a -> UReft b)
-> (forall a b. a -> UReft b -> UReft a) -> Functor UReft
forall a b. a -> UReft b -> UReft a
forall a b. (a -> b) -> UReft a -> UReft b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> UReft b -> UReft a
$c<$ :: forall a b. a -> UReft b -> UReft a
fmap :: (a -> b) -> UReft a -> UReft b
$cfmap :: forall a b. (a -> b) -> UReft a -> UReft b
Functor, UReft a -> Bool
(a -> m) -> UReft a -> m
(a -> b -> b) -> b -> UReft a -> b
(forall m. Monoid m => UReft m -> m)
-> (forall m a. Monoid m => (a -> m) -> UReft a -> m)
-> (forall m a. Monoid m => (a -> m) -> UReft a -> m)
-> (forall a b. (a -> b -> b) -> b -> UReft a -> b)
-> (forall a b. (a -> b -> b) -> b -> UReft a -> b)
-> (forall b a. (b -> a -> b) -> b -> UReft a -> b)
-> (forall b a. (b -> a -> b) -> b -> UReft a -> b)
-> (forall a. (a -> a -> a) -> UReft a -> a)
-> (forall a. (a -> a -> a) -> UReft a -> a)
-> (forall a. UReft a -> [a])
-> (forall a. UReft a -> Bool)
-> (forall a. UReft a -> Int)
-> (forall a. Eq a => a -> UReft a -> Bool)
-> (forall a. Ord a => UReft a -> a)
-> (forall a. Ord a => UReft a -> a)
-> (forall a. Num a => UReft a -> a)
-> (forall a. Num a => UReft a -> a)
-> Foldable UReft
forall a. Eq a => a -> UReft a -> Bool
forall a. Num a => UReft a -> a
forall a. Ord a => UReft a -> a
forall m. Monoid m => UReft m -> m
forall a. UReft a -> Bool
forall a. UReft a -> Int
forall a. UReft a -> [a]
forall a. (a -> a -> a) -> UReft a -> a
forall m a. Monoid m => (a -> m) -> UReft a -> m
forall b a. (b -> a -> b) -> b -> UReft a -> b
forall a b. (a -> b -> b) -> b -> UReft a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: UReft a -> a
$cproduct :: forall a. Num a => UReft a -> a
sum :: UReft a -> a
$csum :: forall a. Num a => UReft a -> a
minimum :: UReft a -> a
$cminimum :: forall a. Ord a => UReft a -> a
maximum :: UReft a -> a
$cmaximum :: forall a. Ord a => UReft a -> a
elem :: a -> UReft a -> Bool
$celem :: forall a. Eq a => a -> UReft a -> Bool
length :: UReft a -> Int
$clength :: forall a. UReft a -> Int
null :: UReft a -> Bool
$cnull :: forall a. UReft a -> Bool
toList :: UReft a -> [a]
$ctoList :: forall a. UReft a -> [a]
foldl1 :: (a -> a -> a) -> UReft a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> UReft a -> a
foldr1 :: (a -> a -> a) -> UReft a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> UReft a -> a
foldl' :: (b -> a -> b) -> b -> UReft a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> UReft a -> b
foldl :: (b -> a -> b) -> b -> UReft a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> UReft a -> b
foldr' :: (a -> b -> b) -> b -> UReft a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> UReft a -> b
foldr :: (a -> b -> b) -> b -> UReft a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> UReft a -> b
foldMap' :: (a -> m) -> UReft a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> UReft a -> m
foldMap :: (a -> m) -> UReft a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> UReft a -> m
fold :: UReft m -> m
$cfold :: forall m. Monoid m => UReft m -> m
Foldable, Functor UReft
Foldable UReft
Functor UReft
-> Foldable UReft
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> UReft a -> f (UReft b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    UReft (f a) -> f (UReft a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> UReft a -> m (UReft b))
-> (forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a))
-> Traversable UReft
(a -> f b) -> UReft a -> f (UReft b)
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 :: UReft (m a) -> m (UReft a)
$csequence :: forall (m :: * -> *) a. Monad m => UReft (m a) -> m (UReft a)
mapM :: (a -> m b) -> UReft a -> m (UReft b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UReft a -> m (UReft b)
sequenceA :: UReft (f a) -> f (UReft a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => UReft (f a) -> f (UReft a)
traverse :: (a -> f b) -> UReft a -> f (UReft b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UReft a -> f (UReft b)
$cp2Traversable :: Foldable UReft
$cp1Traversable :: Functor UReft
Traversable)
  deriving Int -> UReft r -> Int
UReft r -> Int
(Int -> UReft r -> Int) -> (UReft r -> Int) -> Hashable (UReft r)
forall r. Hashable r => Int -> UReft r -> Int
forall r. Hashable r => UReft r -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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
  isEqual  :: c -> Bool

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

  isClass   = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isEqual   = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isNumCls  = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False
  isFracCls = Bool -> c -> Bool
forall a b. a -> b -> a
const Bool
False


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

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

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

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

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


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

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


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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

data RInstance t = RI
  { RInstance t -> BTyCon
riclass :: BTyCon
  , RInstance t -> [t]
ritype  :: [t]
  , RInstance t -> [(LocSymbol, RISig t)]
risigs  :: [(F.LocSymbol, RISig t)]
  } deriving (RInstance t -> RInstance t -> Bool
(RInstance t -> RInstance t -> Bool)
-> (RInstance t -> RInstance t -> Bool) -> Eq (RInstance t)
forall t. Eq t => RInstance t -> RInstance t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: 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 x. RInstance t -> Rep (RInstance t) x)
-> (forall x. Rep (RInstance t) x -> RInstance t)
-> Generic (RInstance t)
forall x. Rep (RInstance t) x -> RInstance t
forall x. RInstance t -> Rep (RInstance t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (RInstance t) x -> RInstance t
forall t x. RInstance t -> Rep (RInstance t) x
$cto :: forall t x. Rep (RInstance t) x -> RInstance t
$cfrom :: forall t x. RInstance t -> Rep (RInstance t) x
Generic, a -> RInstance b -> RInstance a
(a -> b) -> RInstance a -> RInstance b
(forall a b. (a -> b) -> RInstance a -> RInstance b)
-> (forall a b. a -> RInstance b -> RInstance a)
-> Functor RInstance
forall a b. a -> RInstance b -> RInstance a
forall a b. (a -> b) -> RInstance a -> RInstance b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RInstance b -> RInstance a
$c<$ :: forall a b. a -> RInstance b -> RInstance a
fmap :: (a -> b) -> RInstance a -> RInstance b
$cfmap :: forall a b. (a -> b) -> RInstance a -> RInstance b
Functor, Typeable (RInstance t)
DataType
Constr
Typeable (RInstance t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RInstance t -> c (RInstance t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RInstance t))
-> (RInstance t -> Constr)
-> (RInstance t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RInstance t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RInstance t)))
-> ((forall b. Data b => b -> b) -> RInstance t -> RInstance t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RInstance t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RInstance t -> r)
-> (forall u. (forall d. Data d => d -> u) -> RInstance t -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RInstance t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t))
-> Data (RInstance t)
RInstance t -> DataType
RInstance t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
(forall b. Data b => b -> b) -> RInstance t -> RInstance t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> c (RInstance t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RInstance t)
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 u. Int -> (forall d. Data d => d -> u) -> RInstance t -> u
forall u. (forall d. Data d => d -> u) -> RInstance t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RInstance t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RInstance t -> m (RInstance t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RInstance t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RInstance t -> c (RInstance t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RInstance t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RInstance t))
$cRI :: Constr
$tRInstance :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> RInstance t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> RInstance t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (RInstance t)
Data, Typeable, Int -> RInstance t -> ShowS
[RInstance t] -> ShowS
RInstance t -> String
(Int -> RInstance t -> ShowS)
-> (RInstance t -> String)
-> ([RInstance t] -> ShowS)
-> Show (RInstance t)
forall t. Show t => Int -> RInstance t -> ShowS
forall t. Show t => [RInstance t] -> ShowS
forall t. Show t => RInstance t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RInstance t] -> ShowS
$cshowList :: forall t. Show t => [RInstance t] -> ShowS
show :: RInstance t -> String
$cshow :: forall t. Show t => RInstance t -> String
showsPrec :: Int -> RInstance t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> RInstance t -> ShowS
Show)
    deriving Int -> RInstance t -> Int
RInstance t -> Int
(Int -> RInstance t -> Int)
-> (RInstance t -> Int) -> Hashable (RInstance t)
forall t. Hashable t => Int -> RInstance t -> Int
forall t. Hashable t => RInstance t -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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
  { RILaws ty -> BTyCon
rilName    :: BTyCon
  , RILaws ty -> [ty]
rilSupers  :: [ty]
  , RILaws ty -> [ty]
rilTyArgs  :: [ty]
  , RILaws ty -> [(LocSymbol, LocSymbol)]
rilEqus    :: [(F.LocSymbol, F.LocSymbol)]
  , RILaws ty -> Located ()
rilPos     :: F.Located ()
  } deriving (RILaws ty -> RILaws ty -> Bool
(RILaws ty -> RILaws ty -> Bool)
-> (RILaws ty -> RILaws ty -> Bool) -> Eq (RILaws ty)
forall ty. Eq ty => RILaws ty -> RILaws ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: 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
[RILaws ty] -> ShowS
RILaws ty -> String
(Int -> RILaws ty -> ShowS)
-> (RILaws ty -> String)
-> ([RILaws ty] -> ShowS)
-> Show (RILaws ty)
forall ty. Show ty => Int -> RILaws ty -> ShowS
forall ty. Show ty => [RILaws ty] -> ShowS
forall ty. Show ty => RILaws ty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RILaws ty] -> ShowS
$cshowList :: forall ty. Show ty => [RILaws ty] -> ShowS
show :: RILaws ty -> String
$cshow :: forall ty. Show ty => RILaws ty -> String
showsPrec :: Int -> RILaws ty -> ShowS
$cshowsPrec :: forall ty. Show ty => Int -> RILaws ty -> ShowS
Show, a -> RILaws b -> RILaws a
(a -> b) -> RILaws a -> RILaws b
(forall a b. (a -> b) -> RILaws a -> RILaws b)
-> (forall a b. a -> RILaws b -> RILaws a) -> Functor RILaws
forall a b. a -> RILaws b -> RILaws a
forall a b. (a -> b) -> RILaws a -> RILaws b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RILaws b -> RILaws a
$c<$ :: forall a b. a -> RILaws b -> RILaws a
fmap :: (a -> b) -> RILaws a -> RILaws b
$cfmap :: forall a b. (a -> b) -> RILaws a -> RILaws b
Functor, Typeable (RILaws ty)
DataType
Constr
Typeable (RILaws ty)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RILaws ty))
-> (RILaws ty -> Constr)
-> (RILaws ty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RILaws ty)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RILaws ty)))
-> ((forall b. Data b => b -> b) -> RILaws ty -> RILaws ty)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RILaws ty -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RILaws ty -> r)
-> (forall u. (forall d. Data d => d -> u) -> RILaws ty -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RILaws ty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty))
-> Data (RILaws ty)
RILaws ty -> DataType
RILaws ty -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
(forall b. Data b => b -> b) -> RILaws ty -> RILaws ty
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RILaws ty)
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 u. Int -> (forall d. Data d => d -> u) -> RILaws ty -> u
forall u. (forall d. Data d => d -> u) -> RILaws ty -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RILaws ty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RILaws ty -> m (RILaws ty)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RILaws ty)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RILaws ty -> c (RILaws ty)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RILaws ty))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RILaws ty))
$cRIL :: Constr
$tRILaws :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> RILaws ty -> [u]
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RILaws ty -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall ty. Data ty => Typeable (RILaws ty)
Data, Typeable, (forall x. RILaws ty -> Rep (RILaws ty) x)
-> (forall x. Rep (RILaws ty) x -> RILaws ty)
-> Generic (RILaws ty)
forall x. Rep (RILaws ty) x -> RILaws ty
forall x. RILaws ty -> Rep (RILaws ty) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty x. Rep (RILaws ty) x -> RILaws ty
forall ty x. RILaws ty -> Rep (RILaws ty) x
$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
(Int -> RILaws ty -> Int)
-> (RILaws ty -> Int) -> Hashable (RILaws ty)
forall ty. Hashable ty => Int -> RILaws ty -> Int
forall ty. Hashable ty => RILaws ty -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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
(RISig t -> RISig t -> Bool)
-> (RISig t -> RISig t -> Bool) -> Eq (RISig t)
forall t. Eq t => RISig t -> RISig t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: 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 x. RISig t -> Rep (RISig t) x)
-> (forall x. Rep (RISig t) x -> RISig t) -> Generic (RISig t)
forall x. Rep (RISig t) x -> RISig t
forall x. RISig t -> Rep (RISig t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (RISig t) x -> RISig t
forall t x. RISig t -> Rep (RISig t) x
$cto :: forall t x. Rep (RISig t) x -> RISig t
$cfrom :: forall t x. RISig t -> Rep (RISig t) x
Generic, a -> RISig b -> RISig a
(a -> b) -> RISig a -> RISig b
(forall a b. (a -> b) -> RISig a -> RISig b)
-> (forall a b. a -> RISig b -> RISig a) -> Functor RISig
forall a b. a -> RISig b -> RISig a
forall a b. (a -> b) -> RISig a -> RISig b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RISig b -> RISig a
$c<$ :: forall a b. a -> RISig b -> RISig a
fmap :: (a -> b) -> RISig a -> RISig b
$cfmap :: forall a b. (a -> b) -> RISig a -> RISig b
Functor, Typeable (RISig t)
DataType
Constr
Typeable (RISig t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RISig t -> c (RISig t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RISig t))
-> (RISig t -> Constr)
-> (RISig t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RISig t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t)))
-> ((forall b. Data b => b -> b) -> RISig t -> RISig t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RISig t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RISig t -> r)
-> (forall u. (forall d. Data d => d -> u) -> RISig t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RISig t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RISig t -> m (RISig t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RISig t -> m (RISig t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RISig t -> m (RISig t))
-> Data (RISig t)
RISig t -> DataType
RISig t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
(forall b. Data b => b -> b) -> RISig t -> RISig t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> c (RISig t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RISig t)
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 u. Int -> (forall d. Data d => d -> u) -> RISig t -> u
forall u. (forall d. Data d => d -> u) -> RISig t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RISig t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RISig t -> m (RISig t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RISig t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RISig t -> c (RISig t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RISig t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RISig t))
$cRISig :: Constr
$cRIAssumed :: Constr
$tRISig :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> RISig t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> RISig t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (RISig t)
Data, Typeable, Int -> RISig t -> ShowS
[RISig t] -> ShowS
RISig t -> String
(Int -> RISig t -> ShowS)
-> (RISig t -> String) -> ([RISig t] -> ShowS) -> Show (RISig t)
forall t. Show t => Int -> RISig t -> ShowS
forall t. Show t => [RISig t] -> ShowS
forall t. Show t => RISig t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RISig t] -> ShowS
$cshowList :: forall t. Show t => [RISig t] -> ShowS
show :: RISig t -> String
$cshow :: forall t. Show t => RISig t -> String
showsPrec :: Int -> RISig t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> RISig t -> ShowS
Show)
  deriving Int -> RISig t -> Int
RISig t -> Int
(Int -> RISig t -> Int) -> (RISig t -> Int) -> Hashable (RISig t)
forall t. Hashable t => Int -> RISig t -> Int
forall t. Hashable t => RISig t -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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 = Tidy -> Doc -> RISig t -> Doc
forall k t. (PPrint k, PPrint t) => Tidy -> k -> RISig t -> Doc
ppRISig Tidy
k (Doc
empty :: Doc) 

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

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

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

newtype DEnv x ty = DEnv (M.HashMap x (M.HashMap Symbol (RISig ty)))
                    deriving (b -> DEnv x ty -> DEnv x ty
NonEmpty (DEnv x ty) -> DEnv x ty
DEnv x ty -> DEnv x ty -> DEnv x ty
(DEnv x ty -> DEnv x ty -> DEnv x ty)
-> (NonEmpty (DEnv x ty) -> DEnv x ty)
-> (forall b. Integral b => b -> DEnv x ty -> DEnv x ty)
-> Semigroup (DEnv x ty)
forall b. Integral b => b -> DEnv x ty -> DEnv x ty
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall x ty.
(Eq x, Hashable x) =>
NonEmpty (DEnv x ty) -> DEnv x ty
forall x ty.
(Eq x, Hashable x) =>
DEnv x ty -> DEnv x ty -> DEnv x ty
forall x ty b.
(Eq x, Hashable x, Integral b) =>
b -> DEnv x ty -> DEnv x ty
stimes :: b -> DEnv x ty -> DEnv x ty
$cstimes :: forall x ty b.
(Eq x, Hashable x, Integral b) =>
b -> DEnv x ty -> DEnv x ty
sconcat :: NonEmpty (DEnv x ty) -> DEnv x ty
$csconcat :: forall x ty.
(Eq x, Hashable x) =>
NonEmpty (DEnv x ty) -> DEnv x ty
<> :: DEnv x ty -> DEnv x ty -> DEnv x ty
$c<> :: forall x ty.
(Eq x, Hashable x) =>
DEnv x ty -> DEnv x ty -> DEnv x ty
Semigroup, Semigroup (DEnv x ty)
DEnv x ty
Semigroup (DEnv x ty)
-> DEnv x ty
-> (DEnv x ty -> DEnv x ty -> DEnv x ty)
-> ([DEnv x ty] -> DEnv x ty)
-> Monoid (DEnv x ty)
[DEnv x ty] -> DEnv x ty
DEnv x ty -> DEnv x ty -> DEnv x ty
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall x ty. (Eq x, Hashable x) => Semigroup (DEnv x ty)
forall x ty. (Eq x, Hashable x) => DEnv x ty
forall x ty. (Eq x, Hashable x) => [DEnv x ty] -> DEnv x ty
forall x ty.
(Eq x, Hashable x) =>
DEnv x ty -> DEnv x ty -> DEnv x ty
mconcat :: [DEnv x ty] -> DEnv x ty
$cmconcat :: forall x ty. (Eq x, Hashable x) => [DEnv x ty] -> DEnv x ty
mappend :: DEnv x ty -> DEnv x ty -> DEnv x ty
$cmappend :: forall x ty.
(Eq x, Hashable x) =>
DEnv x ty -> DEnv x ty -> DEnv x ty
mempty :: DEnv x ty
$cmempty :: forall x ty. (Eq x, Hashable x) => DEnv x ty
$cp1Monoid :: forall x ty. (Eq x, Hashable x) => Semigroup (DEnv x ty)
Monoid, Int -> DEnv x ty -> ShowS
[DEnv x ty] -> ShowS
DEnv x ty -> String
(Int -> DEnv x ty -> ShowS)
-> (DEnv x ty -> String)
-> ([DEnv x ty] -> ShowS)
-> Show (DEnv x ty)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall x ty. (Show x, Show ty) => Int -> DEnv x ty -> ShowS
forall x ty. (Show x, Show ty) => [DEnv x ty] -> ShowS
forall x ty. (Show x, Show ty) => DEnv x ty -> String
showList :: [DEnv x ty] -> ShowS
$cshowList :: forall x ty. (Show x, Show ty) => [DEnv x ty] -> ShowS
show :: DEnv x ty -> String
$cshow :: forall x ty. (Show x, Show ty) => DEnv x ty -> String
showsPrec :: Int -> DEnv x ty -> ShowS
$cshowsPrec :: forall x ty. (Show x, Show ty) => Int -> DEnv x ty -> ShowS
Show, a -> DEnv x b -> DEnv x a
(a -> b) -> DEnv x a -> DEnv x b
(forall a b. (a -> b) -> DEnv x a -> DEnv x b)
-> (forall a b. a -> DEnv x b -> DEnv x a) -> Functor (DEnv x)
forall a b. a -> DEnv x b -> DEnv x a
forall a b. (a -> b) -> DEnv x a -> DEnv x b
forall x a b. a -> DEnv x b -> DEnv x a
forall x a b. (a -> b) -> DEnv x a -> DEnv x b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> DEnv x b -> DEnv x a
$c<$ :: forall x a b. a -> DEnv x b -> DEnv x a
fmap :: (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 {MethodType t -> Maybe t
tyInstance :: !(Maybe t), MethodType t -> Maybe t
tyClass :: !(Maybe t) }
  deriving (Int -> MethodType t -> ShowS
[MethodType t] -> ShowS
MethodType t -> String
(Int -> MethodType t -> ShowS)
-> (MethodType t -> String)
-> ([MethodType t] -> ShowS)
-> Show (MethodType t)
forall t. Show t => Int -> MethodType t -> ShowS
forall t. Show t => [MethodType t] -> ShowS
forall t. Show t => MethodType t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MethodType t] -> ShowS
$cshowList :: forall t. Show t => [MethodType t] -> ShowS
show :: MethodType t -> String
$cshow :: forall t. Show t => MethodType t -> String
showsPrec :: Int -> MethodType t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> MethodType t -> ShowS
Show)

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

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

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

type HAxiom = Axiom Var    Type CoreExpr

-- type AxiomEq = F.Equation

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

--------------------------------------------------------------------------------
-- | Data type refinements
--------------------------------------------------------------------------------
data DataDecl   = DataDecl
  { DataDecl -> DataName
tycName   :: DataName              -- ^ Type  Constructor Name
  , DataDecl -> [Symbol]
tycTyVars :: [Symbol]              -- ^ Tyvar Parameters
  , DataDecl -> [PVar BSort]
tycPVars  :: [PVar BSort]          -- ^ PVar  Parameters
  , DataDecl -> [DataCtor]
tycDCons  :: [DataCtor]            -- ^ Data Constructors
  , 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
DataType
Constr
Typeable DataDecl
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DataDecl -> c DataDecl)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataDecl)
-> (DataDecl -> Constr)
-> (DataDecl -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataDecl))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDecl))
-> ((forall b. Data b => b -> b) -> DataDecl -> DataDecl)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDecl -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDecl -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataDecl -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataDecl -> m DataDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDecl -> m DataDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDecl -> m DataDecl)
-> Data DataDecl
DataDecl -> DataType
DataDecl -> Constr
(forall b. Data b => b -> b) -> DataDecl -> DataDecl
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDecl -> c DataDecl
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cDataDecl :: Constr
$tDataDecl :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> DataDecl -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDecl -> u
gmapQ :: (forall d. Data d => d -> u) -> DataDecl -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDecl -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable DataDecl
Data, Typeable, (forall x. DataDecl -> Rep DataDecl x)
-> (forall x. Rep DataDecl x -> DataDecl) -> Generic DataDecl
forall x. Rep DataDecl x -> DataDecl
forall x. DataDecl -> Rep DataDecl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataDecl x -> DataDecl
$cfrom :: forall x. DataDecl -> Rep DataDecl x
Generic)
    deriving Int -> DataDecl -> Int
DataDecl -> Int
(Int -> DataDecl -> Int) -> (DataDecl -> Int) -> Hashable DataDecl
forall 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
(DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool) -> Eq DataName
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
Eq DataName
-> (DataName -> DataName -> Ordering)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> Bool)
-> (DataName -> DataName -> DataName)
-> (DataName -> DataName -> DataName)
-> Ord DataName
DataName -> DataName -> Bool
DataName -> DataName -> Ordering
DataName -> DataName -> DataName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
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
$cp1Ord :: Eq DataName
Ord, Typeable DataName
DataType
Constr
Typeable DataName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DataName -> c DataName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataName)
-> (DataName -> Constr)
-> (DataName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataName))
-> ((forall b. Data b => b -> b) -> DataName -> DataName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataName -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataName -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataName -> m DataName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataName -> m DataName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataName -> m DataName)
-> Data DataName
DataName -> DataType
DataName -> Constr
(forall b. Data b => b -> b) -> DataName -> DataName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataName -> c DataName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cDnCon :: Constr
$cDnName :: Constr
$tDataName :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> DataName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataName -> u
gmapQ :: (forall d. Data d => d -> u) -> DataName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataName -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable DataName
Data, Typeable, (forall x. DataName -> Rep DataName x)
-> (forall x. Rep DataName x -> DataName) -> Generic DataName
forall x. Rep DataName x -> DataName
forall x. DataName -> Rep DataName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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
DataType
Constr
Typeable DataCtor
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DataCtor -> c DataCtor)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataCtor)
-> (DataCtor -> Constr)
-> (DataCtor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataCtor))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataCtor))
-> ((forall b. Data b => b -> b) -> DataCtor -> DataCtor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataCtor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataCtor -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataCtor -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataCtor -> m DataCtor)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataCtor -> m DataCtor)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataCtor -> m DataCtor)
-> Data DataCtor
DataCtor -> DataType
DataCtor -> Constr
(forall b. Data b => b -> b) -> DataCtor -> DataCtor
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataCtor -> c DataCtor
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cDataCtor :: Constr
$tDataCtor :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> DataCtor -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataCtor -> u
gmapQ :: (forall d. Data d => d -> u) -> DataCtor -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataCtor -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable DataCtor
Data, Typeable, (forall x. DataCtor -> Rep DataCtor x)
-> (forall x. Rep DataCtor x -> DataCtor) -> Generic DataCtor
forall x. Rep DataCtor x -> DataCtor
forall x. DataCtor -> Rep DataCtor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataCtor x -> DataCtor
$cfrom :: forall x. DataCtor -> Rep DataCtor x
Generic)
    deriving Int -> DataCtor -> Int
DataCtor -> Int
(Int -> DataCtor -> Int) -> (DataCtor -> Int) -> Hashable DataCtor
forall 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
DataType
Constr
Typeable SizeFun
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SizeFun -> c SizeFun)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SizeFun)
-> (SizeFun -> Constr)
-> (SizeFun -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SizeFun))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SizeFun))
-> ((forall b. Data b => b -> b) -> SizeFun -> SizeFun)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SizeFun -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SizeFun -> r)
-> (forall u. (forall d. Data d => d -> u) -> SizeFun -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SizeFun -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SizeFun -> m SizeFun)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SizeFun -> m SizeFun)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SizeFun -> m SizeFun)
-> Data SizeFun
SizeFun -> DataType
SizeFun -> Constr
(forall b. Data b => b -> b) -> SizeFun -> SizeFun
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SizeFun -> c SizeFun
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSymSizeFun :: Constr
$cIdSizeFun :: Constr
$tSizeFun :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> SizeFun -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SizeFun -> u
gmapQ :: (forall d. Data d => d -> u) -> SizeFun -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SizeFun -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable SizeFun
Data, Typeable, (forall x. SizeFun -> Rep SizeFun x)
-> (forall x. Rep SizeFun x -> SizeFun) -> Generic SizeFun
forall x. Rep SizeFun x -> SizeFun
forall x. SizeFun -> Rep SizeFun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SizeFun x -> SizeFun
$cfrom :: forall x. SizeFun -> Rep SizeFun x
Generic)
  deriving Int -> SizeFun -> Int
SizeFun -> Int
(Int -> SizeFun -> Int) -> (SizeFun -> Int) -> Hashable SizeFun
forall 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
(DataDeclKind -> DataDeclKind -> Bool)
-> (DataDeclKind -> DataDeclKind -> Bool) -> Eq DataDeclKind
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
DataType
Constr
Typeable DataDeclKind
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DataDeclKind -> c DataDeclKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataDeclKind)
-> (DataDeclKind -> Constr)
-> (DataDeclKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataDeclKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DataDeclKind))
-> ((forall b. Data b => b -> b) -> DataDeclKind -> DataDeclKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataDeclKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataDeclKind -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDeclKind -> m DataDeclKind)
-> Data DataDeclKind
DataDeclKind -> DataType
DataDeclKind -> Constr
(forall b. Data b => b -> b) -> DataDeclKind -> DataDeclKind
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclKind -> c DataDeclKind
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cDataReflected :: Constr
$cDataUser :: Constr
$tDataDeclKind :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclKind -> u
gmapQ :: (forall d. Data d => d -> u) -> DataDeclKind -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclKind -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable DataDeclKind
Data, Typeable, (forall x. DataDeclKind -> Rep DataDeclKind x)
-> (forall x. Rep DataDeclKind x -> DataDeclKind)
-> Generic DataDeclKind
forall x. Rep DataDeclKind x -> DataDeclKind
forall x. DataDeclKind -> Rep DataDeclKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataDeclKind x -> DataDeclKind
$cfrom :: forall x. DataDeclKind -> Rep DataDeclKind x
Generic, Int -> DataDeclKind -> ShowS
[DataDeclKind] -> ShowS
DataDeclKind -> String
(Int -> DataDeclKind -> ShowS)
-> (DataDeclKind -> String)
-> ([DataDeclKind] -> ShowS)
-> Show DataDeclKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataDeclKind] -> ShowS
$cshowList :: [DataDeclKind] -> ShowS
show :: DataDeclKind -> String
$cshow :: DataDeclKind -> String
showsPrec :: Int -> DataDeclKind -> ShowS
$cshowsPrec :: Int -> DataDeclKind -> ShowS
Show)
  deriving Int -> DataDeclKind -> Int
DataDeclKind -> Int
(Int -> DataDeclKind -> Int)
-> (DataDeclKind -> Int) -> Hashable DataDeclKind
forall 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 -> String
show SizeFun
IdSizeFun      = String
"IdSizeFun"
  show (SymSizeFun LocSymbol
x) = String
"SymSizeFun " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Symbol -> String
forall a. Show a => a -> String
show (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
x)

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

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

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

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

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


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

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

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

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

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

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


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


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

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

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

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

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

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

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

--------------------------------------------------------------------------------
-- | Refinement Type Aliases
--------------------------------------------------------------------------------
data RTAlias x a = RTA
  { RTAlias x a -> Symbol
rtName  :: Symbol             -- ^ name of the alias
  , RTAlias x a -> [x]
rtTArgs :: [x]                -- ^ type parameters
  , RTAlias x a -> [Symbol]
rtVArgs :: [Symbol]           -- ^ value parameters
  , RTAlias x a -> a
rtBody  :: a                  -- ^ what the alias expands to
  -- , rtMod   :: !ModName           -- ^ module where alias was defined
  } deriving (RTAlias x a -> RTAlias x a -> Bool
(RTAlias x a -> RTAlias x a -> Bool)
-> (RTAlias x a -> RTAlias x a -> Bool) -> Eq (RTAlias x a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall x a. (Eq x, Eq a) => RTAlias x a -> RTAlias x a -> Bool
/= :: 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, Typeable (RTAlias x a)
DataType
Constr
Typeable (RTAlias x a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RTAlias x a))
-> (RTAlias x a -> Constr)
-> (RTAlias x a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RTAlias x a)))
-> ((forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r)
-> (forall u. (forall d. Data d => d -> u) -> RTAlias x a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a))
-> Data (RTAlias x a)
RTAlias x a -> DataType
RTAlias x a -> Constr
(forall b. Data b => b -> b) -> RTAlias x a -> RTAlias x 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 b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTAlias x a)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RTAlias x a -> u
forall u. (forall d. Data d => d -> u) -> RTAlias x a -> [u]
forall x a. (Data x, Data a) => Typeable (RTAlias x a)
forall x a. (Data x, Data a) => RTAlias x a -> 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 r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RTAlias x a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RTAlias x a -> m (RTAlias x a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RTAlias x a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RTAlias x a -> c (RTAlias x a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RTAlias x a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RTAlias x a))
$cRTA :: Constr
$tRTAlias :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall x a. (Data x, Data a) => Typeable (RTAlias x a)
Data, Typeable, (forall x. RTAlias x a -> Rep (RTAlias x a) x)
-> (forall x. Rep (RTAlias x a) x -> RTAlias x a)
-> Generic (RTAlias x a)
forall x. Rep (RTAlias x a) x -> RTAlias x a
forall x. RTAlias x a -> Rep (RTAlias x a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall x a x. Rep (RTAlias x a) x -> RTAlias x a
forall x a x. RTAlias x a -> Rep (RTAlias x a) x
$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, a -> RTAlias x b -> RTAlias x a
(a -> b) -> RTAlias x a -> RTAlias x b
(forall a b. (a -> b) -> RTAlias x a -> RTAlias x b)
-> (forall a b. a -> RTAlias x b -> RTAlias x a)
-> Functor (RTAlias x)
forall a b. a -> RTAlias x b -> RTAlias x a
forall a b. (a -> b) -> RTAlias x a -> RTAlias x b
forall x a b. a -> RTAlias x b -> RTAlias x a
forall x a b. (a -> b) -> RTAlias x a -> RTAlias x b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RTAlias x b -> RTAlias x a
$c<$ :: forall x a b. a -> RTAlias x b -> RTAlias x a
fmap :: (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
(Int -> RTAlias x a -> Int)
-> (RTAlias x a -> Int) -> Hashable (RTAlias x a)
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable 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 :: (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 (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RTAlias a ty -> [a]
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) = LocSymbol -> RTAlias Symbol Expr -> Located (RTAlias Symbol Expr)
forall l b. Loc l => l -> b -> Located b
F.atLoc LocSymbol
v (Symbol -> [Symbol] -> [Symbol] -> Expr -> RTAlias Symbol Expr
forall x a. Symbol -> [x] -> [Symbol] -> a -> RTAlias x a
RTA (LocSymbol -> Symbol
forall a. Located a -> a
F.val LocSymbol
v) [] [Symbol]
ys Expr
e) -- (F.loc v) (F.loc v)


--------------------------------------------------------------------------------
-- | Constructor and Destructors for RTypes ------------------------------------
--------------------------------------------------------------------------------
data RTypeRep c tv r = RTypeRep
  { RTypeRep c tv r -> [(RTVar tv (RType c tv ()), r)]
ty_vars   :: [(RTVar tv (RType c tv ()), r)]
  , RTypeRep c tv r -> [PVar (RType c tv ())]
ty_preds  :: [PVar (RType c tv ())]
  , RTypeRep c tv r -> [Symbol]
ty_ebinds  :: [Symbol]
  , RTypeRep c tv r -> [r]
ty_erefts  :: [r]
  , RTypeRep c tv r -> [RType c tv r]
ty_eargs   :: [RType c tv r]
  , RTypeRep c tv r -> [Symbol]
ty_binds  :: [Symbol]
  , RTypeRep c tv r -> [r]
ty_refts  :: [r]
  , RTypeRep c tv r -> [RType c tv r]
ty_args   :: [RType 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 :: 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 ())]
RType c tv r
ty_res :: RType c tv r
ty_args :: [RType c tv r]
ty_refts :: [r]
ty_binds :: [Symbol]
ty_eargs :: [RType c tv r]
ty_erefts :: [r]
ty_ebinds :: [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_binds :: forall c tv r. RTypeRep c tv r -> [Symbol]
ty_eargs :: forall c tv r. RTypeRep c tv r -> [RType c tv r]
ty_erefts :: forall c tv r. RTypeRep c tv r -> [r]
ty_ebinds :: 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)]
..})
  = [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [(Symbol, RType c tv r, r)]
-> [(Symbol, RType c tv r, r)]
-> RType c tv r
-> RType c tv r
forall tv c r.
[(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [(Symbol, RType c tv r, r)]
-> [(Symbol, 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, RType c tv r, r)]
earrs [(Symbol, RType c tv r, r)]
arrs RType c tv r
ty_res
  where
    arrs :: [(Symbol, RType c tv r, r)]
arrs  = String
-> [Symbol] -> [RType c tv r] -> [r] -> [(Symbol, RType c tv r, r)]
forall t t1 t2. String -> [t] -> [t1] -> [t2] -> [(t, t1, t2)]
safeZip3WithError (String
"fromRTypeRep: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Int, Int, Int) -> String
forall a. Show a => a -> String
show ([Symbol] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
ty_binds, [RType c tv r] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [RType c tv r]
ty_args, [r] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [r]
ty_refts)) [Symbol]
ty_binds [RType c tv r]
ty_args [r]
ty_refts
    earrs :: [(Symbol, RType c tv r, r)]
earrs = String
-> [Symbol] -> [RType c tv r] -> [r] -> [(Symbol, RType c tv r, r)]
forall t t1 t2. String -> [t] -> [t1] -> [t2] -> [(t, t1, t2)]
safeZip3WithError (String
"fromRTypeRep: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Int, Int, Int) -> String
forall a. Show a => a -> String
show ([Symbol] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Symbol]
ty_ebinds, [RType c tv r] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [RType c tv r]
ty_eargs, [r] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [r]
ty_erefts)) [Symbol]
ty_ebinds [RType c tv r]
ty_eargs [r]
ty_erefts

--------------------------------------------------------------------------------
toRTypeRep           :: RType c tv r -> RTypeRep c tv r
--------------------------------------------------------------------------------
toRTypeRep :: RType c tv r -> RTypeRep c tv r
toRTypeRep RType c tv r
t         = [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [Symbol]
-> [r]
-> [RType c tv r]
-> [Symbol]
-> [r]
-> [RType c tv r]
-> RType c tv r
-> RTypeRep c tv r
forall c tv r.
[(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [Symbol]
-> [r]
-> [RType c tv r]
-> [Symbol]
-> [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' [r]
rs' [RType c tv r]
ts' [Symbol]
xs [r]
rs [RType c tv r]
ts RType c tv r
t''
  where
    ([(RTVar tv (RType c tv ()), r)]
αs, [PVar (RType c tv ())]
πs, RType c tv r
t')  = RType c tv r
-> ([(RTVar tv (RType c tv ()), r)], [PVar (RType c tv ())],
    RType c tv r)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv  RType c tv r
t
    (([Symbol]
xs',[RType c tv r]
ts',[r]
rs'),([Symbol]
xs, [RType c tv r]
ts, [r]
rs), RType c tv r
t'') = RType c tv r
-> (([Symbol], [RType c tv r], [r]),
    ([Symbol], [RType c tv r], [r]), RType c tv r)
forall t t1 a.
RType t t1 a
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [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, RType c tv r, r)]
        -> [(Symbol, RType c tv r, r)]
        -> RType c tv r
        -> RType c tv r
mkArrow :: [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())]
-> [(Symbol, RType c tv r, r)]
-> [(Symbol, 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, RType c tv r, r)]
yts [(Symbol, RType c tv r, r)]
xts = [(RTVar tv (RType c tv ()), r)]
-> [PVar (RType c tv ())] -> RType c tv r -> RType c tv r
forall (t :: * -> *) (t1 :: * -> *) tv c r.
(Foldable t, Foldable t1) =>
t (RTVar tv (RType c tv ()), r)
-> t1 (PVar (RType c tv ())) -> RType c tv r -> RType c tv r
mkUnivs [(RTVar tv (RType c tv ()), r)]
αs [PVar (RType c tv ())]
πs (RType c tv r -> RType c tv r)
-> (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r)
-> [(Symbol, RType c tv r, r)] -> RType c tv r -> RType c tv r
forall (t :: * -> *) t t t t.
Foldable t =>
(t -> t -> t -> t -> t) -> t (t, t, t) -> t -> t
mkArrs Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
RImpF [(Symbol, RType c tv r, r)]
yts(RType c tv r -> RType c tv r)
-> (RType c tv r -> RType c tv r) -> RType c tv r -> RType c tv r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r)
-> [(Symbol, RType c tv r, r)] -> RType c tv r -> RType c tv r
forall (t :: * -> *) t t t t.
Foldable t =>
(t -> t -> t -> t -> t) -> t (t, t, t) -> t -> t
mkArrs Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
RFun [(Symbol, RType c tv r, r)]
xts
  where
    mkArrs :: (t -> t -> t -> t -> t) -> t (t, t, t) -> t -> t
mkArrs t -> t -> t -> t -> t
f t (t, t, t)
xts t
t  = ((t, t, t) -> t -> t) -> t -> t (t, t, t) -> t
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(t
b,t
t1,t
r) t
t2 -> t -> t -> t -> t -> t
f t
b t
t1 t
t2 t
r) t
t t (t, t, t)
xts

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

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


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

bkImp :: RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkImp :: RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkImp (RImpF Symbol
x RType t t1 a
t RType t t1 a
t' a
r) = let ([Symbol]
xs, [RType t t1 a]
ts, [a]
rs, RType t t1 a
t'') = RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
forall t t1 a.
RType t t1 a -> ([Symbol], [RType t t1 a], [a], RType t t1 a)
bkImp RType t t1 a
t'  in (Symbol
xSymbol -> [Symbol] -> [Symbol]
forall a. a -> [a] -> [a]
:[Symbol]
xs, RType t t1 a
tRType t t1 a -> [RType t t1 a] -> [RType t t1 a]
forall a. a -> [a] -> [a]
:[RType t t1 a]
ts, a
ra -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs, RType t t1 a
t'')
bkImp RType t t1 a
t                = ([], [], [], RType t t1 a
t)

safeBkArrow ::(F.PPrint (RType t t1 a)) 
            => RType t t1 a -> ( ([Symbol], [RType t t1 a], [a])
                               , ([Symbol], [RType t t1 a], [a])
                               , RType t t1 a )
safeBkArrow :: RType t t1 a
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [RType t t1 a], [a]), RType t t1 a)
safeBkArrow t :: RType t t1 a
t@(RAllT RTVU t t1
_ RType t t1 a
_ a
_) = String
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [RType t t1 a], [a]), RType t t1 a)
forall a. (?callStack::CallStack) => String -> a
Prelude.error {- panic Nothing -} (String
 -> (([Symbol], [RType t t1 a], [a]),
     ([Symbol], [RType t t1 a], [a]), RType t t1 a))
-> String
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [RType t t1 a], [a]), RType t t1 a)
forall a b. (a -> b) -> a -> b
$ String
"safeBkArrow on RAllT" String -> ShowS
forall a. [a] -> [a] -> [a]
++ RType t t1 a -> String
forall a. PPrint a => a -> String
F.showpp RType t t1 a
t
safeBkArrow (RAllP PVU t t1
_ RType t t1 a
_)     = String
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [RType t t1 a], [a]), RType t t1 a)
forall a. (?callStack::CallStack) => String -> a
Prelude.error {- panic Nothing -} String
"safeBkArrow on RAllP"
safeBkArrow RType t t1 a
t               = RType t t1 a
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [RType t t1 a], [a]), RType t t1 a)
forall t t1 a.
RType t t1 a
-> (([Symbol], [RType t t1 a], [a]),
    ([Symbol], [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 :: 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
t = ((RTVar tv (RType c tv ()), r) -> RType c tv r -> RType c tv r)
-> RType c tv r -> t (RTVar tv (RType c tv ()), r) -> RType c tv r
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(RTVar tv (RType c tv ())
a,r
r) RType c tv r
t -> RTVar tv (RType c tv ()) -> RType c tv r -> r -> RType c tv r
forall c tv r. RTVU c tv -> RType c tv r -> r -> RType c tv r
RAllT RTVar tv (RType c tv ())
a RType c tv r
t r
r) ((PVar (RType c tv ()) -> RType c tv r -> RType c tv r)
-> RType c tv r -> t1 (PVar (RType c tv ())) -> RType c tv r
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr PVar (RType c tv ()) -> RType c tv r -> RType c tv r
forall c tv r. PVU c tv -> RType c tv r -> RType c tv r
RAllP RType c tv r
t t1 (PVar (RType c tv ()))
πs) t (RTVar tv (RType c tv ()), r)
αs

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


bkUniv :: RType tv c r -> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())], RType tv c r)
bkUniv :: RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv (RAllT RTVar c (RType tv c ())
α RType tv c r
t r
r) = let ([(RTVar c (RType tv c ()), r)]
αs, [PVar (RType tv c ())]
πs, RType tv c r
t') = RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv RType tv c r
t in ((RTVar c (RType tv c ())
α, r
r)(RTVar c (RType tv c ()), r)
-> [(RTVar c (RType tv c ()), r)] -> [(RTVar c (RType tv c ()), r)]
forall a. a -> [a] -> [a]
:[(RTVar c (RType 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 ([(RTVar c (RType tv c ()), r)]
αs, [PVar (RType tv c ())]
πs, RType tv c r
t') = RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
forall tv c r.
RType tv c r
-> ([(RTVar c (RType tv c ()), r)], [PVar (RType tv c ())],
    RType tv c r)
bkUniv RType tv c r
t in ([(RTVar c (RType tv c ()), r)]
αs, PVar (RType tv c ())
πPVar (RType tv c ())
-> [PVar (RType tv c ())] -> [PVar (RType tv c ())]
forall a. a -> [a] -> [a]
:[PVar (RType tv c ())]
πs, RType tv c r
t')
bkUniv RType tv c r
t             = ([], [], RType tv c r
t)

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

rImpF :: Monoid r => Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rImpF :: Symbol -> RType c tv r -> RType c tv r -> RType c tv r
rImpF Symbol
b RType c tv r
t RType c tv r
t' = Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
forall c tv r.
Symbol -> RType c tv r -> RType c tv r -> r -> RType c tv r
RImpF Symbol
b RType c tv r
t RType c tv r
t' r
forall a. Monoid a => a
mempty

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

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

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

addInvCond :: SpecType -> RReft -> SpecType
addInvCond :: SpecType -> RReft -> SpecType
addInvCond SpecType
t RReft
r'
  | Reft -> Bool
forall r. Reftable r => r -> Bool
F.isTauto (Reft -> Bool) -> Reft -> Bool
forall a b. (a -> b) -> a -> b
$ RReft -> Reft
forall r. UReft r -> r
ur_reft RReft
r' -- null rv
  = SpecType
t
  | Bool
otherwise
  = RTypeRep RTyCon RTyVar RReft -> SpecType
forall c tv r. RTypeRep c tv r -> RType c tv r
fromRTypeRep (RTypeRep RTyCon RTyVar RReft -> SpecType)
-> RTypeRep RTyCon RTyVar RReft -> SpecType
forall a b. (a -> b) -> a -> b
$ RTypeRep RTyCon RTyVar RReft
trep {ty_res :: SpecType
ty_res = [(Symbol, SpecType)] -> RReft -> Oblig -> SpecType -> SpecType
forall c tv r.
[(Symbol, RType c tv r)]
-> r -> Oblig -> RType c tv r -> RType c tv r
RRTy [(Symbol
x', SpecType
tbd)] RReft
r Oblig
OInv SpecType
tbd}
  where
    trep :: RTypeRep RTyCon RTyVar RReft
trep = SpecType -> RTypeRep RTyCon RTyVar RReft
forall c tv r. RType c tv r -> RTypeRep c tv r
toRTypeRep SpecType
t
    tbd :: SpecType
tbd  = RTypeRep RTyCon RTyVar RReft -> SpecType
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) (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ Expr -> (Symbol, Expr) -> Expr
forall a. Subable a => a -> (Symbol, Expr) -> a
F.subst1 Expr
rv (Symbol, Expr)
su
    F.Reft(Symbol
v, Expr
rv) = RReft -> Reft
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
_) = Reft -> r
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               = UReft r -> Bool
forall r. Reftable r => UReft r -> Bool
isTauto_ureft
  ppTy :: UReft r -> Doc -> Doc
ppTy                  = UReft r -> Doc -> Doc
forall r. Reftable r => UReft r -> Doc -> Doc
ppTy_ureft
  toReft :: UReft r -> Reft
toReft (MkUReft r
r Predicate
ps) = r -> Reft
forall r. Reftable r => r -> Reft
F.toReft r
r Reft -> Reft -> Reft
forall r. Reftable r => r -> r -> r
`F.meet` Predicate -> Reft
forall r. Reftable r => r -> Reft
F.toReft Predicate
ps
  params :: UReft r -> [Symbol]
params (MkUReft r
r Predicate
_)  = r -> [Symbol]
forall r. Reftable r => r -> [Symbol]
F.params r
r
  bot :: UReft r -> UReft r
bot (MkUReft r
r Predicate
_)     = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (r -> r
forall r. Reftable r => r -> r
F.bot r
r) ([UsedPVar] -> Predicate
Pr [])
  top :: UReft r -> UReft r
top (MkUReft r
r Predicate
p)     = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (r -> r
forall r. Reftable r => r -> r
F.top r
r) (Predicate -> Predicate
forall r. Reftable r => r -> r
F.top Predicate
p)
  ofReft :: Reft -> UReft r
ofReft Reft
r              = r -> Predicate -> UReft r
forall r. r -> Predicate -> UReft r
MkUReft (Reft -> r
forall r. Reftable r => Reft -> r
F.ofReft Reft
r) Predicate
forall a. Monoid a => a
mempty

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



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

ppTy_ureft :: F.Reftable r => UReft r -> Doc -> Doc
ppTy_ureft :: UReft r -> Doc -> Doc
ppTy_ureft u :: UReft r
u@(MkUReft r
r Predicate
p) Doc
d
  | UReft r -> Bool
forall r. Reftable r => UReft r -> Bool
isTauto_ureft  UReft r
u  = Doc
d
  | Bool
otherwise         = r -> Doc -> Doc
forall r. Reftable r => r -> Doc -> Doc
ppr_reft r
r (Predicate -> Doc -> Doc
forall r. Reftable r => r -> Doc -> Doc
F.ppTy Predicate
p Doc
d)

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

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

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

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

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

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


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


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

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

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

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

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

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

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

--------------------------------------------------------------------------------
-- | Visitors ------------------------------------------------------------------
--------------------------------------------------------------------------------
mapExprReft :: (Symbol -> Expr -> Expr) -> RType c tv RReft -> RType c tv RReft
mapExprReft :: (Symbol -> Expr -> Expr) -> RType c tv RReft -> RType c tv RReft
mapExprReft Symbol -> Expr -> Expr
f = (RReft -> RReft) -> RType c tv RReft -> RType c tv RReft
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) = Reft -> Predicate -> RReft
forall r. r -> Predicate -> UReft r
MkUReft ((Symbol, Expr) -> Reft
F.Reft (Symbol
x, Symbol -> Expr -> Expr
f Symbol
x Expr
e)) Predicate
p

isTrivial :: (F.Reftable r, TyConable c) => RType c tv r -> Bool
isTrivial :: RType c tv r -> Bool
isTrivial RType c tv r
t = Bool
-> (SEnv (RType c tv r) -> r -> Bool -> Bool)
-> Bool
-> RType c tv r
-> Bool
forall r c tv a.
(Reftable r, TyConable c) =>
Bool
-> (SEnv (RType c tv r) -> r -> a -> a) -> a -> RType c tv r -> a
foldReft Bool
False (\SEnv (RType c tv r)
_ r
r Bool
b -> r -> Bool
forall r. Reftable r => r -> Bool
F.isTauto r
r Bool -> Bool -> Bool
&& Bool
b) Bool
True RType c tv r
t

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

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

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

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

foldRType :: (acc -> RType c tv r -> acc) -> acc -> RType c tv r -> acc
foldRType :: (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 (RImpF Symbol
_ RType c tv r
t RType c tv r
t' r
_)   = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
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 (RFun Symbol
_ RType c tv r
t RType c tv r
t' r
_)    = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (RAllE Symbol
_ RType c tv r
t RType c tv r
t')     = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (REx Symbol
_ RType c tv r
t RType c tv r
t')       = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (RAppTy RType c tv r
t RType c tv r
t' r
_)    = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r
t, RType c tv r
t']
    go acc
a (RApp c
_ [RType c tv r]
ts [RTProp c tv r]
rs r
_)   = (acc -> RTProp c tv r -> acc) -> acc -> [RTProp c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RTProp c tv r -> acc
prep ((acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a [RType c tv r]
ts) [RTProp c tv r]
rs
    go acc
a (RRTy [(Symbol, RType c tv r)]
e r
_ Oblig
_ RType c tv r
t)     = (acc -> RType c tv r -> acc) -> acc -> [RType c tv r] -> acc
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' acc -> RType c tv r -> acc
step acc
a (RType c tv r
t RType c tv r -> [RType c tv r] -> [RType c tv r]
forall a. a -> [a] -> [a]
: ((Symbol, RType c tv r) -> RType c tv r
forall a b. (a, b) -> b
snd ((Symbol, RType c tv r) -> RType c tv r)
-> [(Symbol, RType c tv r)] -> [RType c tv r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, RType c tv r)]
e))

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

-- isBase :: RType a -> Bool

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

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

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



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

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

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


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

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

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



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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

rTypeReft :: (F.Reftable r) => RType c tv r -> F.Reft
rTypeReft :: RType c tv r -> Reft
rTypeReft = Reft -> Maybe Reft -> Reft
forall a. a -> Maybe a -> a
fromMaybe Reft
F.trueReft (Maybe Reft -> Reft)
-> (RType c tv r -> Maybe Reft) -> RType c tv r -> Reft
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (r -> Reft) -> Maybe r -> Maybe Reft
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap r -> Reft
forall r. Reftable r => r -> Reft
F.toReft (Maybe r -> Maybe Reft)
-> (RType c tv r -> Maybe r) -> RType c tv r -> Maybe Reft
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RType c tv r -> Maybe r
forall c tv r. RType c tv r -> Maybe r
stripRTypeBase

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

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

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

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

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

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


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


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

type REnv = AREnv SpecType 

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

instance Functor AREnv where 
  fmap :: (a -> b) -> AREnv a -> AREnv b
fmap a -> b
f (REnv HashMap Symbol a
g HashMap Symbol a
l) = HashMap Symbol b -> HashMap Symbol b -> AREnv b
forall t. HashMap Symbol t -> HashMap Symbol t -> AREnv t
REnv ((a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f HashMap Symbol a
g) ((a -> b) -> HashMap Symbol a -> HashMap Symbol b
forall (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
$+$ Tidy -> HashMap Symbol t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (AREnv t -> HashMap Symbol t
forall t. AREnv t -> HashMap Symbol t
reLocal AREnv t
re) Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<>
                    Doc
"\nRENV GLOBAL" Doc -> Doc -> Doc
$+$ Tidy -> HashMap Symbol t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (AREnv t -> HashMap Symbol t
forall t. AREnv t -> HashMap Symbol t
reGlobal AREnv t
re)
  

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

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

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

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

data Warning = Warning {
    Warning -> SrcSpan
warnSpan :: SrcSpan
  , Warning -> Doc
warnDoc  :: Doc
  } deriving (Warning -> Warning -> Bool
(Warning -> Warning -> Bool)
-> (Warning -> Warning -> Bool) -> Eq Warning
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Warning -> Warning -> Bool
$c/= :: Warning -> Warning -> Bool
== :: Warning -> Warning -> Bool
$c== :: Warning -> Warning -> Bool
Eq, Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> String
(Int -> Warning -> ShowS)
-> (Warning -> String) -> ([Warning] -> ShowS) -> Show Warning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Warning] -> ShowS
$cshowList :: [Warning] -> ShowS
show :: Warning -> String
$cshow :: Warning -> String
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
(Diagnostics -> Diagnostics -> Bool)
-> (Diagnostics -> Diagnostics -> Bool) -> Eq Diagnostics
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 [Warning] -> [Warning] -> [Warning]
forall a. Semigroup a => a -> a -> a
<> [Warning]
w2) ([Error]
e1 [Error] -> [Error] -> [Error]
forall a. Semigroup a => a -> a -> a
<> [Error]
e2)

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

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

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

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

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

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

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

printWarning :: DynFlags -> Warning -> IO ()
printWarning :: DynFlags -> Warning -> IO ()
printWarning DynFlags
dyn (Warning SrcSpan
span Doc
doc) = DynFlags -> SrcSpan -> Doc -> IO ()
GHC.putWarnMsg DynFlags
dyn SrcSpan
span Doc
doc

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

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


instance NFData a => NFData (TError a)

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

data Cinfo    = Ci { Cinfo -> SrcSpan
ci_loc :: !SrcSpan
                   , Cinfo -> Maybe Error
ci_err :: !(Maybe Error)
                   , Cinfo -> Maybe Var
ci_var :: !(Maybe Var)
                   }
                deriving (Cinfo -> Cinfo -> Bool
(Cinfo -> Cinfo -> Bool) -> (Cinfo -> Cinfo -> Bool) -> Eq Cinfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cinfo -> Cinfo -> Bool
$c/= :: Cinfo -> Cinfo -> Bool
== :: Cinfo -> Cinfo -> Bool
$c== :: Cinfo -> Cinfo -> Bool
Eq, Eq Cinfo
Eq Cinfo
-> (Cinfo -> Cinfo -> Ordering)
-> (Cinfo -> Cinfo -> Bool)
-> (Cinfo -> Cinfo -> Bool)
-> (Cinfo -> Cinfo -> Bool)
-> (Cinfo -> Cinfo -> Bool)
-> (Cinfo -> Cinfo -> Cinfo)
-> (Cinfo -> Cinfo -> Cinfo)
-> Ord Cinfo
Cinfo -> Cinfo -> Bool
Cinfo -> Cinfo -> Ordering
Cinfo -> Cinfo -> Cinfo
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 :: Cinfo -> Cinfo -> Cinfo
$cmin :: Cinfo -> Cinfo -> Cinfo
max :: Cinfo -> Cinfo -> Cinfo
$cmax :: Cinfo -> Cinfo -> Cinfo
>= :: Cinfo -> Cinfo -> Bool
$c>= :: Cinfo -> Cinfo -> Bool
> :: Cinfo -> Cinfo -> Bool
$c> :: Cinfo -> Cinfo -> Bool
<= :: Cinfo -> Cinfo -> Bool
$c<= :: Cinfo -> Cinfo -> Bool
< :: Cinfo -> Cinfo -> Bool
$c< :: Cinfo -> Cinfo -> Bool
compare :: Cinfo -> Cinfo -> Ordering
$ccompare :: Cinfo -> Cinfo -> Ordering
$cp1Ord :: Eq Cinfo
Ord, (forall x. Cinfo -> Rep Cinfo x)
-> (forall x. Rep Cinfo x -> Cinfo) -> Generic Cinfo
forall x. Rep Cinfo x -> Cinfo
forall x. Cinfo -> Rep Cinfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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 (SrcSpan -> SrcSpan) -> (Cinfo -> SrcSpan) -> Cinfo -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cinfo -> SrcSpan
ci_loc

instance NFData Cinfo

--------------------------------------------------------------------------------
-- | Module Names --------------------------------------------------------------
--------------------------------------------------------------------------------

data ModName = ModName !ModType !ModuleName 
  deriving (ModName -> ModName -> Bool
(ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool) -> Eq ModName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModName -> ModName -> Bool
$c/= :: ModName -> ModName -> Bool
== :: ModName -> ModName -> Bool
$c== :: ModName -> ModName -> Bool
Eq, Eq ModName
Eq ModName
-> (ModName -> ModName -> Ordering)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> Bool)
-> (ModName -> ModName -> ModName)
-> (ModName -> ModName -> ModName)
-> Ord ModName
ModName -> ModName -> Bool
ModName -> ModName -> Ordering
ModName -> ModName -> ModName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
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
$cp1Ord :: Eq ModName
Ord, Int -> ModName -> ShowS
[ModName] -> ShowS
ModName -> String
(Int -> ModName -> ShowS)
-> (ModName -> String) -> ([ModName] -> ShowS) -> Show ModName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModName] -> ShowS
$cshowList :: [ModName] -> ShowS
show :: ModName -> String
$cshow :: ModName -> String
showsPrec :: Int -> ModName -> ShowS
$cshowsPrec :: Int -> ModName -> ShowS
Show, (forall x. ModName -> Rep ModName x)
-> (forall x. Rep ModName x -> ModName) -> Generic ModName
forall x. Rep ModName x -> ModName
forall x. ModName -> Rep ModName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModName x -> ModName
$cfrom :: forall x. ModName -> Rep ModName x
Generic, Typeable ModName
DataType
Constr
Typeable ModName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ModName -> c ModName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ModName)
-> (ModName -> Constr)
-> (ModName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ModName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModName))
-> ((forall b. Data b => b -> b) -> ModName -> ModName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ModName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ModName -> r)
-> (forall u. (forall d. Data d => d -> u) -> ModName -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ModName -> m ModName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModName -> m ModName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModName -> m ModName)
-> Data ModName
ModName -> DataType
ModName -> Constr
(forall b. Data b => b -> b) -> ModName -> ModName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModName -> c ModName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cModName :: Constr
$tModName :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> ModName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModName -> u
gmapQ :: (forall d. Data d => d -> u) -> ModName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ModName -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable ModName
Data, Typeable)

data ModType = Target | SrcImport | SpecImport 
  deriving (ModType -> ModType -> Bool
(ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool) -> Eq ModType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModType -> ModType -> Bool
$c/= :: ModType -> ModType -> Bool
== :: ModType -> ModType -> Bool
$c== :: ModType -> ModType -> Bool
Eq, Eq ModType
Eq ModType
-> (ModType -> ModType -> Ordering)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> Bool)
-> (ModType -> ModType -> ModType)
-> (ModType -> ModType -> ModType)
-> Ord ModType
ModType -> ModType -> Bool
ModType -> ModType -> Ordering
ModType -> ModType -> ModType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
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
$cp1Ord :: Eq ModType
Ord, Int -> ModType -> ShowS
[ModType] -> ShowS
ModType -> String
(Int -> ModType -> ShowS)
-> (ModType -> String) -> ([ModType] -> ShowS) -> Show ModType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModType] -> ShowS
$cshowList :: [ModType] -> ShowS
show :: ModType -> String
$cshow :: ModType -> String
showsPrec :: Int -> ModType -> ShowS
$cshowsPrec :: Int -> ModType -> ShowS
Show, (forall x. ModType -> Rep ModType x)
-> (forall x. Rep ModType x -> ModType) -> Generic ModType
forall x. Rep ModType x -> ModType
forall x. ModType -> Rep ModType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModType x -> ModType
$cfrom :: forall x. ModType -> Rep ModType x
Generic, Typeable ModType
DataType
Constr
Typeable ModType
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ModType -> c ModType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ModType)
-> (ModType -> Constr)
-> (ModType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ModType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModType))
-> ((forall b. Data b => b -> b) -> ModType -> ModType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ModType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ModType -> r)
-> (forall u. (forall d. Data d => d -> u) -> ModType -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ModType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ModType -> m ModType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModType -> m ModType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ModType -> m ModType)
-> Data ModType
ModType -> DataType
ModType -> Constr
(forall b. Data b => b -> b) -> ModType -> ModType
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModType -> c ModType
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSpecImport :: Constr
$cSrcImport :: Constr
$cTarget :: Constr
$tModType :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> ModType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModType -> u
gmapQ :: (forall d. Data d => d -> u) -> ModType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ModType -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable ModType
Data, Typeable)

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

instance Hashable ModType 

instance Hashable ModuleName where
  hashWithSalt :: Int -> ModuleName -> Int
hashWithSalt Int
i = Int -> String -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
i (String -> Int) -> (ModuleName -> String) -> ModuleName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> String
forall a. Show a => a -> String
show

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

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

instance Show ModuleName where
  show :: ModuleName -> String
show = ModuleName -> String
moduleNameString

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

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


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

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

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

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

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

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

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


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

instance Semigroup (RTEnv tv t) where
  RTE HashMap Symbol (Located (RTAlias tv t))
x HashMap Symbol (Located (RTAlias Symbol Expr))
y <> :: RTEnv tv t -> RTEnv tv t -> RTEnv tv t
<> RTE HashMap Symbol (Located (RTAlias tv t))
x' HashMap Symbol (Located (RTAlias Symbol Expr))
y' = HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
forall tv t.
HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias Symbol Expr)) -> RTEnv tv t
RTE (HashMap Symbol (Located (RTAlias tv t))
x HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias tv t))
-> HashMap Symbol (Located (RTAlias tv t))
forall k v.
(Eq k, 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 HashMap Symbol (Located (RTAlias Symbol Expr))
-> HashMap Symbol (Located (RTAlias Symbol Expr))
-> HashMap Symbol (Located (RTAlias Symbol Expr))
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 -> String
(Int -> Body -> ShowS)
-> (Body -> String) -> ([Body] -> ShowS) -> Show Body
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Body] -> ShowS
$cshowList :: [Body] -> ShowS
show :: Body -> String
$cshow :: Body -> String
showsPrec :: Int -> Body -> ShowS
$cshowsPrec :: Int -> Body -> ShowS
Show, Typeable Body
DataType
Constr
Typeable Body
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Body -> c Body)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Body)
-> (Body -> Constr)
-> (Body -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Body))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Body))
-> ((forall b. Data b => b -> b) -> Body -> Body)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Body -> r)
-> (forall u. (forall d. Data d => d -> u) -> Body -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Body -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Body -> m Body)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Body -> m Body)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Body -> m Body)
-> Data Body
Body -> DataType
Body -> Constr
(forall b. Data b => b -> b) -> Body -> Body
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Body -> c Body
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cR :: Constr
$cP :: Constr
$cE :: Constr
$tBody :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> Body -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Body -> u
gmapQ :: (forall d. Data d => d -> u) -> Body -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Body -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable Body
Data, Typeable, (forall x. Body -> Rep Body x)
-> (forall x. Rep Body x -> Body) -> Generic Body
forall x. Rep Body x -> Body
forall x. Body -> Rep Body x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Body x -> Body
$cfrom :: forall x. Body -> Rep Body x
Generic, Body -> Body -> Bool
(Body -> Body -> Bool) -> (Body -> Body -> Bool) -> Eq Body
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 Int -> Body -> Int
Body -> Int
(Int -> Body -> Int) -> (Body -> Int) -> Hashable Body
forall 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
  { Def ty ctor -> LocSymbol
measure :: F.LocSymbol
  , Def ty ctor -> ctor
ctor    :: ctor
  , Def ty ctor -> Maybe ty
dsort   :: Maybe ty
  , Def ty ctor -> [(Symbol, Maybe ty)]
binds   :: [(Symbol, Maybe ty)]    -- measure binders: the ADT argument fields
  , Def ty ctor -> Body
body    :: Body
  } deriving (Int -> Def ty ctor -> ShowS
[Def ty ctor] -> ShowS
Def ty ctor -> String
(Int -> Def ty ctor -> ShowS)
-> (Def ty ctor -> String)
-> ([Def ty ctor] -> ShowS)
-> Show (Def ty ctor)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall ty ctor. (Show ctor, Show ty) => Int -> Def ty ctor -> ShowS
forall ty ctor. (Show ctor, Show ty) => [Def ty ctor] -> ShowS
forall ty ctor. (Show ctor, Show ty) => Def ty ctor -> String
showList :: [Def ty ctor] -> ShowS
$cshowList :: forall ty ctor. (Show ctor, Show ty) => [Def ty ctor] -> ShowS
show :: Def ty ctor -> String
$cshow :: forall ty ctor. (Show ctor, Show ty) => Def ty ctor -> String
showsPrec :: Int -> Def ty ctor -> ShowS
$cshowsPrec :: forall ty ctor. (Show ctor, Show ty) => Int -> Def ty ctor -> ShowS
Show, Typeable (Def ty ctor)
DataType
Constr
Typeable (Def ty ctor)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Def ty ctor))
-> (Def ty ctor -> Constr)
-> (Def ty ctor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Def ty ctor)))
-> ((forall b. Data b => b -> b) -> Def ty ctor -> Def ty ctor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r)
-> (forall u. (forall d. Data d => d -> u) -> Def ty ctor -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor))
-> Data (Def ty ctor)
Def ty ctor -> DataType
Def ty ctor -> Constr
(forall b. Data b => b -> b) -> Def ty ctor -> Def ty 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 b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Def ty ctor)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Def ty ctor -> u
forall u. (forall d. Data d => d -> u) -> Def ty ctor -> [u]
forall ty ctor. (Data ty, Data ctor) => Typeable (Def ty ctor)
forall ty ctor. (Data ty, Data ctor) => Def ty ctor -> 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 r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Def ty ctor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Def ty ctor -> m (Def ty ctor)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Def ty ctor)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Def ty ctor -> c (Def ty ctor)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Def ty ctor))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Def ty ctor))
$cDef :: Constr
$tDef :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall ty ctor. (Data ty, Data ctor) => Typeable (Def ty ctor)
Data, Typeable, (forall x. Def ty ctor -> Rep (Def ty ctor) x)
-> (forall x. Rep (Def ty ctor) x -> Def ty ctor)
-> Generic (Def ty ctor)
forall x. Rep (Def ty ctor) x -> Def ty ctor
forall x. Def ty ctor -> Rep (Def ty ctor) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty ctor x. Rep (Def ty ctor) x -> Def ty ctor
forall ty ctor x. Def ty ctor -> Rep (Def ty ctor) x
$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
(Def ty ctor -> Def ty ctor -> Bool)
-> (Def ty ctor -> Def ty ctor -> Bool) -> Eq (Def ty ctor)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall ty ctor.
(Eq ctor, Eq ty) =>
Def ty ctor -> Def ty ctor -> Bool
/= :: 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, a -> Def ty b -> Def ty a
(a -> b) -> Def ty a -> Def ty b
(forall a b. (a -> b) -> Def ty a -> Def ty b)
-> (forall a b. a -> Def ty b -> Def ty a) -> Functor (Def ty)
forall a b. a -> Def ty b -> Def ty a
forall a b. (a -> b) -> Def ty a -> Def ty b
forall ty a b. a -> Def ty b -> Def ty a
forall ty a b. (a -> b) -> Def ty a -> Def ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Def ty b -> Def ty a
$c<$ :: forall ty a b. a -> Def ty b -> Def ty a
fmap :: (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
(Int -> Def ty ctor -> Int)
-> (Def ty ctor -> Int) -> Hashable (Def ty ctor)
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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
  { Measure ty ctor -> LocSymbol
msName :: F.LocSymbol
  , Measure ty ctor -> ty
msSort :: ty
  , Measure ty ctor -> [Def ty ctor]
msEqns :: [Def ty ctor]
  , Measure ty ctor -> MeasureKind
msKind :: !MeasureKind 
  , Measure ty ctor -> UnSortedExprs
msUnSorted :: !UnSortedExprs -- potential unsorted expressions used at measure denifinitions
  } deriving (Measure ty ctor -> Measure ty ctor -> Bool
(Measure ty ctor -> Measure ty ctor -> Bool)
-> (Measure ty ctor -> Measure ty ctor -> Bool)
-> Eq (Measure ty ctor)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall ty ctor.
(Eq ty, Eq ctor) =>
Measure ty ctor -> Measure ty ctor -> Bool
/= :: 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, Typeable (Measure ty ctor)
DataType
Constr
Typeable (Measure ty ctor)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Measure ty ctor))
-> (Measure ty ctor -> Constr)
-> (Measure ty ctor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Measure ty ctor)))
-> ((forall b. Data b => b -> b)
    -> Measure ty ctor -> Measure ty ctor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> Measure ty ctor -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Measure ty ctor -> m (Measure ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Measure ty ctor -> m (Measure ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Measure ty ctor -> m (Measure ty ctor))
-> Data (Measure ty ctor)
Measure ty ctor -> DataType
Measure ty ctor -> Constr
(forall b. Data b => b -> b) -> Measure ty ctor -> Measure ty 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 b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure ty ctor)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> Measure ty ctor -> u
forall u. (forall d. Data d => d -> u) -> Measure ty ctor -> [u]
forall ty ctor. (Data 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 r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Measure ty ctor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Measure ty ctor -> m (Measure ty ctor)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Measure ty ctor)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Measure ty ctor -> c (Measure ty ctor)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Measure ty ctor))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Measure ty ctor))
$cM :: Constr
$tMeasure :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall ty ctor. (Data ty, Data ctor) => Typeable (Measure ty ctor)
Data, Typeable, (forall x. Measure ty ctor -> Rep (Measure ty ctor) x)
-> (forall x. Rep (Measure ty ctor) x -> Measure ty ctor)
-> Generic (Measure ty ctor)
forall x. Rep (Measure ty ctor) x -> Measure ty ctor
forall x. Measure ty ctor -> Rep (Measure ty ctor) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty ctor x. Rep (Measure ty ctor) x -> Measure ty ctor
forall ty ctor x. Measure ty ctor -> Rep (Measure ty ctor) x
$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, a -> Measure ty b -> Measure ty a
(a -> b) -> Measure ty a -> Measure ty b
(forall a b. (a -> b) -> Measure ty a -> Measure ty b)
-> (forall a b. a -> Measure ty b -> Measure ty a)
-> Functor (Measure ty)
forall a b. a -> Measure ty b -> Measure ty a
forall a b. (a -> b) -> Measure ty a -> Measure ty b
forall ty a b. a -> Measure ty b -> Measure ty a
forall ty a b. (a -> b) -> Measure ty a -> Measure ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Measure ty b -> Measure ty a
$c<$ :: forall ty a b. a -> Measure ty b -> Measure ty a
fmap :: (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
(Int -> Measure ty ctor -> Int)
-> (Measure ty ctor -> Int) -> Hashable (Measure ty ctor)
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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
(MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool) -> Eq MeasureKind
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
Eq MeasureKind
-> (MeasureKind -> MeasureKind -> Ordering)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> Bool)
-> (MeasureKind -> MeasureKind -> MeasureKind)
-> (MeasureKind -> MeasureKind -> MeasureKind)
-> Ord MeasureKind
MeasureKind -> MeasureKind -> Bool
MeasureKind -> MeasureKind -> Ordering
MeasureKind -> MeasureKind -> MeasureKind
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
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
$cp1Ord :: Eq MeasureKind
Ord, Int -> MeasureKind -> ShowS
[MeasureKind] -> ShowS
MeasureKind -> String
(Int -> MeasureKind -> ShowS)
-> (MeasureKind -> String)
-> ([MeasureKind] -> ShowS)
-> Show MeasureKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MeasureKind] -> ShowS
$cshowList :: [MeasureKind] -> ShowS
show :: MeasureKind -> String
$cshow :: MeasureKind -> String
showsPrec :: Int -> MeasureKind -> ShowS
$cshowsPrec :: Int -> MeasureKind -> ShowS
Show, Typeable MeasureKind
DataType
Constr
Typeable MeasureKind
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> MeasureKind -> c MeasureKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MeasureKind)
-> (MeasureKind -> Constr)
-> (MeasureKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MeasureKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c MeasureKind))
-> ((forall b. Data b => b -> b) -> MeasureKind -> MeasureKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MeasureKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MeasureKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> MeasureKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MeasureKind -> m MeasureKind)
-> Data MeasureKind
MeasureKind -> DataType
MeasureKind -> Constr
(forall b. Data b => b -> b) -> MeasureKind -> MeasureKind
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeasureKind -> c MeasureKind
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cMsChecker :: Constr
$cMsSelector :: Constr
$cMsAbsMeasure :: Constr
$cMsClass :: Constr
$cMsLifted :: Constr
$cMsMeasure :: Constr
$cMsReflect :: Constr
$tMeasureKind :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MeasureKind -> u
gmapQ :: (forall d. Data d => d -> u) -> MeasureKind -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MeasureKind -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable MeasureKind
Data, Typeable, (forall x. MeasureKind -> Rep MeasureKind x)
-> (forall x. Rep MeasureKind x -> MeasureKind)
-> Generic MeasureKind
forall x. Rep MeasureKind x -> MeasureKind
forall x. MeasureKind -> Rep MeasureKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MeasureKind x -> MeasureKind
$cfrom :: forall x. MeasureKind -> Rep MeasureKind x
Generic)
  deriving Int -> MeasureKind -> Int
MeasureKind -> Int
(Int -> MeasureKind -> Int)
-> (MeasureKind -> Int) -> Hashable MeasureKind
forall 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 = LocSymbol -> SrcSpan
forall a. Loc a => a -> SrcSpan
F.srcSpan (LocSymbol -> SrcSpan)
-> (Measure a b -> LocSymbol) -> Measure a b -> SrcSpan
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Measure a b -> LocSymbol
forall ty ctor. Measure ty ctor -> LocSymbol
msName

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


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

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

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

data CMeasure ty = CM
  { CMeasure ty -> LocSymbol
cName :: F.LocSymbol
  , CMeasure ty -> ty
cSort :: ty
  } deriving (Typeable (CMeasure ty)
DataType
Constr
Typeable (CMeasure ty)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (CMeasure ty))
-> (CMeasure ty -> Constr)
-> (CMeasure ty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (CMeasure ty)))
-> ((forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r)
-> (forall u. (forall d. Data d => d -> u) -> CMeasure ty -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty))
-> Data (CMeasure ty)
CMeasure ty -> DataType
CMeasure ty -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
(forall b. Data b => b -> b) -> CMeasure ty -> CMeasure ty
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CMeasure ty)
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 u. Int -> (forall d. Data d => d -> u) -> CMeasure ty -> u
forall u. (forall d. Data d => d -> u) -> CMeasure ty -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CMeasure ty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CMeasure ty -> m (CMeasure ty)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CMeasure ty)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CMeasure ty -> c (CMeasure ty)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CMeasure ty))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CMeasure ty))
$cCM :: Constr
$tCMeasure :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> CMeasure ty -> [u]
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> CMeasure ty -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall ty. Data ty => Typeable (CMeasure ty)
Data, Typeable, (forall x. CMeasure ty -> Rep (CMeasure ty) x)
-> (forall x. Rep (CMeasure ty) x -> CMeasure ty)
-> Generic (CMeasure ty)
forall x. Rep (CMeasure ty) x -> CMeasure ty
forall x. CMeasure ty -> Rep (CMeasure ty) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty x. Rep (CMeasure ty) x -> CMeasure ty
forall ty x. CMeasure ty -> Rep (CMeasure ty) x
$cto :: forall ty x. Rep (CMeasure ty) x -> CMeasure ty
$cfrom :: forall ty x. CMeasure ty -> Rep (CMeasure ty) x
Generic, a -> CMeasure b -> CMeasure a
(a -> b) -> CMeasure a -> CMeasure b
(forall a b. (a -> b) -> CMeasure a -> CMeasure b)
-> (forall a b. a -> CMeasure b -> CMeasure a) -> Functor CMeasure
forall a b. a -> CMeasure b -> CMeasure a
forall a b. (a -> b) -> CMeasure a -> CMeasure b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> CMeasure b -> CMeasure a
$c<$ :: forall a b. a -> CMeasure b -> CMeasure a
fmap :: (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)   = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
e
  pprintTidy Tidy
k (P Expr
p)   = Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
p
  pprintTidy Tidy
k (R Symbol
v Expr
p) = Doc -> Doc
braces (Tidy -> Symbol -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Symbol
v Doc -> Doc -> Doc
<+> Doc
"|" Doc -> Doc -> Doc
<+> Tidy -> Expr -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k Expr
p)

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

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


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

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

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


instance F.Subable (Measure ty ctor) where
  syms :: Measure ty ctor -> [Symbol]
syms  Measure ty ctor
m     = (Def ty ctor -> [Symbol]) -> [Def ty ctor] -> [Symbol]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Def ty ctor -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms (Measure ty ctor -> [Def ty ctor]
forall ty ctor. Measure ty ctor -> [Def ty ctor]
msEqns Measure ty ctor
m) 
  substa :: (Symbol -> Symbol) -> Measure ty ctor -> Measure ty ctor
substa Symbol -> Symbol
f Measure ty ctor
m  = Measure ty ctor
m { msEqns :: [Def ty ctor]
msEqns = (Symbol -> Symbol) -> Def ty ctor -> Def ty ctor
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f  (Def ty ctor -> Def ty ctor) -> [Def ty ctor] -> [Def ty ctor]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Measure ty ctor -> [Def ty ctor]
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 = (Symbol -> Expr) -> Def ty ctor -> Def ty ctor
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f  (Def ty ctor -> Def ty ctor) -> [Def ty ctor] -> [Def ty ctor]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Measure ty ctor -> [Def ty ctor]
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 = Subst -> Def ty ctor -> Def ty ctor
forall a. Subable a => Subst -> a -> a
F.subst  Subst
su (Def ty ctor -> Def ty ctor) -> [Def ty ctor] -> [Def ty ctor]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Measure ty ctor -> [Def ty ctor]
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)  = ((Symbol, Maybe ty) -> Symbol
forall a b. (a, b) -> a
fst ((Symbol, Maybe ty) -> Symbol) -> [(Symbol, Maybe ty)] -> [Symbol]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Maybe ty)]
sb) [Symbol] -> [Symbol] -> [Symbol]
forall a. [a] -> [a] -> [a]
++ Body -> [Symbol]
forall a. Subable a => a -> [Symbol]
F.syms Body
bd
  substa :: (Symbol -> Symbol) -> Def ty ctor -> Def ty ctor
substa Symbol -> Symbol
f  (Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b Body
bd) = LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b (Body -> Def ty ctor) -> Body -> Def ty ctor
forall a b. (a -> b) -> a -> b
$ (Symbol -> Symbol) -> Body -> Body
forall a. Subable a => (Symbol -> Symbol) -> a -> a
F.substa Symbol -> Symbol
f  Body
bd
  substf :: (Symbol -> Expr) -> Def ty ctor -> Def ty ctor
substf Symbol -> Expr
f  (Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b Body
bd) = LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b (Body -> Def ty ctor) -> Body -> Def ty ctor
forall a b. (a -> b) -> a -> b
$ (Symbol -> Expr) -> Body -> Body
forall a. Subable a => (Symbol -> Expr) -> a -> a
F.substf Symbol -> Expr
f  Body
bd
  subst :: Subst -> Def ty ctor -> Def ty ctor
subst  Subst
su (Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b Body
bd) = LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
forall ty ctor.
LocSymbol
-> ctor -> Maybe ty -> [(Symbol, Maybe ty)] -> Body -> Def ty ctor
Def LocSymbol
m ctor
c Maybe ty
t [(Symbol, Maybe ty)]
b (Body -> Def ty ctor) -> Body -> Def ty ctor
forall a b. (a -> b) -> a -> b
$ Subst -> Body -> Body
forall a. Subable a => Subst -> a -> a
F.subst  Subst
su Body
bd

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

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

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

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

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

data RClass ty = RClass
  { RClass ty -> BTyCon
rcName    :: BTyCon
  , RClass ty -> [ty]
rcSupers  :: [ty]
  , RClass ty -> [BTyVar]
rcTyVars  :: [BTyVar]
  , RClass ty -> [(LocSymbol, ty)]
rcMethods :: [(F.LocSymbol, ty)]
  } deriving (RClass ty -> RClass ty -> Bool
(RClass ty -> RClass ty -> Bool)
-> (RClass ty -> RClass ty -> Bool) -> Eq (RClass ty)
forall ty. Eq ty => RClass ty -> RClass ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: 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
[RClass ty] -> ShowS
RClass ty -> String
(Int -> RClass ty -> ShowS)
-> (RClass ty -> String)
-> ([RClass ty] -> ShowS)
-> Show (RClass ty)
forall ty. Show ty => Int -> RClass ty -> ShowS
forall ty. Show ty => [RClass ty] -> ShowS
forall ty. Show ty => RClass ty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RClass ty] -> ShowS
$cshowList :: forall ty. Show ty => [RClass ty] -> ShowS
show :: RClass ty -> String
$cshow :: forall ty. Show ty => RClass ty -> String
showsPrec :: Int -> RClass ty -> ShowS
$cshowsPrec :: forall ty. Show ty => Int -> RClass ty -> ShowS
Show, a -> RClass b -> RClass a
(a -> b) -> RClass a -> RClass b
(forall a b. (a -> b) -> RClass a -> RClass b)
-> (forall a b. a -> RClass b -> RClass a) -> Functor RClass
forall a b. a -> RClass b -> RClass a
forall a b. (a -> b) -> RClass a -> RClass b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> RClass b -> RClass a
$c<$ :: forall a b. a -> RClass b -> RClass a
fmap :: (a -> b) -> RClass a -> RClass b
$cfmap :: forall a b. (a -> b) -> RClass a -> RClass b
Functor, Typeable (RClass ty)
DataType
Constr
Typeable (RClass ty)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RClass ty -> c (RClass ty))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (RClass ty))
-> (RClass ty -> Constr)
-> (RClass ty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (RClass ty)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (RClass ty)))
-> ((forall b. Data b => b -> b) -> RClass ty -> RClass ty)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RClass ty -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RClass ty -> r)
-> (forall u. (forall d. Data d => d -> u) -> RClass ty -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RClass ty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty))
-> Data (RClass ty)
RClass ty -> DataType
RClass ty -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
(forall b. Data b => b -> b) -> RClass ty -> RClass ty
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> c (RClass ty)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RClass ty)
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 u. Int -> (forall d. Data d => d -> u) -> RClass ty -> u
forall u. (forall d. Data d => d -> u) -> RClass ty -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RClass ty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RClass ty -> m (RClass ty)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (RClass ty)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RClass ty -> c (RClass ty)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (RClass ty))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (RClass ty))
$cRClass :: Constr
$tRClass :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> RClass ty -> [u]
$cgmapQ :: forall ty u.
Data ty =>
(forall d. Data d => d -> u) -> RClass ty -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall ty. Data ty => Typeable (RClass ty)
Data, Typeable, (forall x. RClass ty -> Rep (RClass ty) x)
-> (forall x. Rep (RClass ty) x -> RClass ty)
-> Generic (RClass ty)
forall x. Rep (RClass ty) x -> RClass ty
forall x. RClass ty -> Rep (RClass ty) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty x. Rep (RClass ty) x -> RClass ty
forall ty x. RClass ty -> Rep (RClass ty) x
$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
(Int -> RClass ty -> Int)
-> (RClass ty -> Int) -> Hashable (RClass ty)
forall ty. Hashable ty => Int -> RClass ty -> Int
forall ty. Hashable ty => RClass ty -> Int
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
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) 
                = Tidy -> Doc -> BTyCon -> [BTyVar] -> [(LocSymbol, RISig t)] -> Doc
forall x t a n.
(PPrint x, PPrint t, PPrint a, PPrint n) =>
Tidy -> Doc -> n -> [a] -> [(x, RISig t)] -> Doc
ppMethods Tidy
k (Doc
"class" Doc -> Doc -> Doc
<+> [t] -> Doc
forall a. PPrint a => [a] -> Doc
supers [t]
ts) BTyCon
n [BTyVar]
as [(LocSymbol
m, t -> RISig t
forall t. t -> RISig t
RISig t
t) | (LocSymbol
m, t
t) <- [(LocSymbol, t)]
mts] 
    where 
      supers :: [a] -> Doc
supers [] = Doc
"" 
      supers [a]
ts = [Doc] -> Doc
tuplify (Tidy -> a -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k   (a -> Doc) -> [a] -> [Doc]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a]
ts) Doc -> Doc -> Doc
<+> Doc
"=>"
      tuplify :: [Doc] -> Doc
tuplify   = Doc -> Doc
parens (Doc -> Doc) -> ([Doc] -> Doc) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Doc] -> Doc
hcat ([Doc] -> Doc) -> ([Doc] -> [Doc]) -> [Doc] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
", "


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


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

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

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


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

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

instance Functor (HoleInfo i) where 
  fmap :: (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 (HoleInfo i a -> a
forall i t. HoleInfo i t -> t
htype HoleInfo i a
hinfo), henv :: AREnv b
henv = (a -> b) -> AREnv a -> AREnv b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (HoleInfo i a -> AREnv a
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 = String -> Doc
text String
"type:" Doc -> Doc -> Doc
<+> Tidy -> t -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (HoleInfo i t -> t
forall i t. HoleInfo i t -> t
htype HoleInfo i t
hinfo) 
                       Doc -> Doc -> Doc
<+> String -> Doc
text String
"\n loc:" Doc -> Doc -> Doc
<+> Tidy -> SrcSpan -> Doc
forall a. PPrint a => Tidy -> a -> Doc
F.pprintTidy Tidy
k (HoleInfo i t -> SrcSpan
forall i t. HoleInfo i t -> SrcSpan
hloc HoleInfo i t
hinfo) 
  -- to print the hole environment uncomment the following
  --                     <+> text "\n env:" <+> F.pprintTidy k (henv hinfo)

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

newtype AnnInfo a = AI (M.HashMap SrcSpan [(Maybe Text, a)])
                    deriving (Typeable (AnnInfo a)
DataType
Constr
Typeable (AnnInfo a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (AnnInfo a))
-> (AnnInfo a -> Constr)
-> (AnnInfo a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (AnnInfo a)))
-> ((forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnInfo a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a))
-> Data (AnnInfo a)
AnnInfo a -> DataType
AnnInfo a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
(forall b. Data b => b -> b) -> AnnInfo a -> AnnInfo a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (AnnInfo a)
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 u. Int -> (forall d. Data d => d -> u) -> AnnInfo a -> u
forall u. (forall d. Data d => d -> u) -> AnnInfo a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnInfo a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnInfo a -> m (AnnInfo a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (AnnInfo a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnInfo a -> c (AnnInfo a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (AnnInfo a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (AnnInfo a))
$cAI :: Constr
$tAnnInfo :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> AnnInfo a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> AnnInfo a -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall a. Data a => Typeable (AnnInfo a)
Data, Typeable, (forall x. AnnInfo a -> Rep (AnnInfo a) x)
-> (forall x. Rep (AnnInfo a) x -> AnnInfo a)
-> Generic (AnnInfo a)
forall x. Rep (AnnInfo a) x -> AnnInfo a
forall x. AnnInfo a -> Rep (AnnInfo a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (AnnInfo a) x -> AnnInfo a
forall a x. AnnInfo a -> Rep (AnnInfo a) x
$cto :: forall a x. Rep (AnnInfo a) x -> AnnInfo a
$cfrom :: forall a x. AnnInfo a -> Rep (AnnInfo a) x
Generic, a -> AnnInfo b -> AnnInfo a
(a -> b) -> AnnInfo a -> AnnInfo b
(forall a b. (a -> b) -> AnnInfo a -> AnnInfo b)
-> (forall a b. a -> AnnInfo b -> AnnInfo a) -> Functor AnnInfo
forall a b. a -> AnnInfo b -> AnnInfo a
forall a b. (a -> b) -> AnnInfo a -> AnnInfo b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> AnnInfo b -> AnnInfo a
$c<$ :: forall a b. a -> AnnInfo b -> AnnInfo a
fmap :: (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 (Typeable (Annot t)
DataType
Constr
Typeable (Annot t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Annot t -> c (Annot t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Annot t))
-> (Annot t -> Constr)
-> (Annot t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Annot t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t)))
-> ((forall b. Data b => b -> b) -> Annot t -> Annot t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Annot t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Annot t -> r)
-> (forall u. (forall d. Data d => d -> u) -> Annot t -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Annot t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Annot t -> m (Annot t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Annot t -> m (Annot t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Annot t -> m (Annot t))
-> Data (Annot t)
Annot t -> DataType
Annot t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Annot t))
(forall b. Data b => b -> b) -> Annot t -> Annot t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Annot t -> c (Annot t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Annot t)
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 u. Int -> (forall d. Data d => d -> u) -> Annot t -> u
forall u. (forall d. Data d => d -> u) -> Annot t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Annot t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Annot t -> m (Annot t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Annot t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Annot t -> c (Annot t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Annot t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Annot t))
$cAnnLoc :: Constr
$cAnnRDf :: Constr
$cAnnDef :: Constr
$cAnnUse :: Constr
$tAnnot :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> Annot t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> Annot t -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall t. Data t => Typeable (Annot t)
Data, Typeable, (forall x. Annot t -> Rep (Annot t) x)
-> (forall x. Rep (Annot t) x -> Annot t) -> Generic (Annot t)
forall x. Rep (Annot t) x -> Annot t
forall x. Annot t -> Rep (Annot t) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (Annot t) x -> Annot t
forall t x. Annot t -> Rep (Annot t) x
$cto :: forall t x. Rep (Annot t) x -> Annot t
$cfrom :: forall t x. Annot t -> Rep (Annot t) x
Generic, a -> Annot b -> Annot a
(a -> b) -> Annot a -> Annot b
(forall a b. (a -> b) -> Annot a -> Annot b)
-> (forall a b. a -> Annot b -> Annot a) -> Functor Annot
forall a b. a -> Annot b -> Annot a
forall a b. (a -> b) -> Annot a -> Annot b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Annot b -> Annot a
$c<$ :: forall a b. a -> Annot b -> Annot a
fmap :: (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  = HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
forall a. HashMap SrcSpan [(Maybe Text, a)] -> AnnInfo a
AI HashMap SrcSpan [(Maybe Text, a)]
forall k v. HashMap k v
M.empty
  mappend :: AnnInfo a -> AnnInfo a -> AnnInfo a
mappend = AnnInfo a -> AnnInfo a -> AnnInfo a
forall a. Semigroup a => a -> a -> a
(<>)

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

instance NFData a => NFData (AnnInfo a)

instance NFData a => NFData (Annot a)

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

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

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

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

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

--------------------------------------------------------------------------------
-- | 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
  | ImplictE
  | ProjectE        -- ^ Projecting out field of
  deriving ((forall x. KVKind -> Rep KVKind x)
-> (forall x. Rep KVKind x -> KVKind) -> Generic KVKind
forall x. Rep KVKind x -> KVKind
forall x. KVKind -> Rep KVKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KVKind x -> KVKind
$cfrom :: forall x. KVKind -> Rep KVKind x
Generic, KVKind -> KVKind -> Bool
(KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool) -> Eq KVKind
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
Eq KVKind
-> (KVKind -> KVKind -> Ordering)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> Bool)
-> (KVKind -> KVKind -> KVKind)
-> (KVKind -> KVKind -> KVKind)
-> Ord KVKind
KVKind -> KVKind -> Bool
KVKind -> KVKind -> Ordering
KVKind -> KVKind -> KVKind
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
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
$cp1Ord :: Eq KVKind
Ord, Int -> KVKind -> ShowS
[KVKind] -> ShowS
KVKind -> String
(Int -> KVKind -> ShowS)
-> (KVKind -> String) -> ([KVKind] -> ShowS) -> Show KVKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KVKind] -> ShowS
$cshowList :: [KVKind] -> ShowS
show :: KVKind -> String
$cshow :: KVKind -> String
showsPrec :: Int -> KVKind -> ShowS
$cshowsPrec :: Int -> KVKind -> ShowS
Show, Typeable KVKind
DataType
Constr
Typeable KVKind
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> KVKind -> c KVKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c KVKind)
-> (KVKind -> Constr)
-> (KVKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c KVKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KVKind))
-> ((forall b. Data b => b -> b) -> KVKind -> KVKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> KVKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> KVKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> KVKind -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> KVKind -> m KVKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KVKind -> m KVKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KVKind -> m KVKind)
-> Data KVKind
KVKind -> DataType
KVKind -> Constr
(forall b. Data b => b -> b) -> KVKind -> KVKind
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KVKind -> c KVKind
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cProjectE :: Constr
$cImplictE :: Constr
$cLetE :: Constr
$cCaseE :: Constr
$cLamE :: Constr
$cPredInstE :: Constr
$cTypeInstE :: Constr
$cNonRecBindE :: Constr
$cRecBindE :: Constr
$tKVKind :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> KVKind -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KVKind -> u
gmapQ :: (forall d. Data d => d -> u) -> KVKind -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KVKind -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable KVKind
Data, Typeable)

instance Hashable KVKind

newtype KVProf = KVP (M.HashMap KVKind Int) deriving ((forall x. KVProf -> Rep KVProf x)
-> (forall x. Rep KVProf x -> KVProf) -> Generic KVProf
forall x. Rep KVProf x -> KVProf
forall x. KVProf -> Rep KVProf x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$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 HashMap KVKind Int
forall k v. HashMap k v
M.empty

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

instance NFData KVKind

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

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

instance NFData KVProf

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

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

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

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

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

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

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

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

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

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

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

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

data MSpec ty ctor = MSpec
  { MSpec ty ctor -> HashMap Symbol [Def ty ctor]
ctorMap  :: M.HashMap Symbol [Def ty ctor]
  , MSpec ty ctor -> HashMap LocSymbol (Measure ty ctor)
measMap  :: M.HashMap F.LocSymbol (Measure ty ctor)
  , MSpec ty ctor -> HashMap LocSymbol (Measure ty ())
cmeasMap :: M.HashMap F.LocSymbol (Measure ty ())
  , MSpec ty ctor -> [Measure ty ctor]
imeas    :: ![Measure ty ctor]
  } deriving (Typeable (MSpec ty ctor)
DataType
Constr
Typeable (MSpec ty ctor)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor))
-> (MSpec ty ctor -> Constr)
-> (MSpec ty ctor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (MSpec ty ctor)))
-> ((forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty ctor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r)
-> (forall u. (forall d. Data d => d -> u) -> MSpec ty ctor -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> MSpec ty ctor -> m (MSpec ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> MSpec ty ctor -> m (MSpec ty ctor))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> MSpec ty ctor -> m (MSpec ty ctor))
-> Data (MSpec ty ctor)
MSpec ty ctor -> DataType
MSpec ty ctor -> Constr
(forall b. Data b => b -> b) -> MSpec ty ctor -> MSpec ty 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 b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> MSpec ty ctor -> u
forall u. (forall d. Data d => d -> u) -> MSpec ty ctor -> [u]
forall ty ctor. (Data ty, Data ctor) => Typeable (MSpec ty ctor)
forall ty ctor. (Data ty, Data ctor) => MSpec ty ctor -> 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 r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MSpec ty ctor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> MSpec ty ctor -> m (MSpec ty ctor)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MSpec ty ctor)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MSpec ty ctor -> c (MSpec ty ctor)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (MSpec ty ctor))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MSpec ty ctor))
$cMSpec :: Constr
$tMSpec :: DataType
gmapMo :: (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 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 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 :: 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 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 :: (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 :: (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 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 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 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 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)
$cp1Data :: forall ty ctor. (Data ty, Data ctor) => Typeable (MSpec ty ctor)
Data, Typeable, (forall x. MSpec ty ctor -> Rep (MSpec ty ctor) x)
-> (forall x. Rep (MSpec ty ctor) x -> MSpec ty ctor)
-> Generic (MSpec ty ctor)
forall x. Rep (MSpec ty ctor) x -> MSpec ty ctor
forall x. MSpec ty ctor -> Rep (MSpec ty ctor) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall ty ctor x. Rep (MSpec ty ctor) x -> MSpec ty ctor
forall ty ctor x. MSpec ty ctor -> Rep (MSpec ty ctor) x
$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, a -> MSpec ty b -> MSpec ty a
(a -> b) -> MSpec ty a -> MSpec ty b
(forall a b. (a -> b) -> MSpec ty a -> MSpec ty b)
-> (forall a b. a -> MSpec ty b -> MSpec ty a)
-> Functor (MSpec ty)
forall a b. a -> MSpec ty b -> MSpec ty a
forall a b. (a -> b) -> MSpec ty a -> MSpec ty b
forall ty a b. a -> MSpec ty b -> MSpec ty a
forall ty a b. (a -> b) -> MSpec ty a -> MSpec ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> MSpec ty b -> MSpec ty a
$c<$ :: forall ty a b. a -> MSpec ty b -> MSpec ty a
fmap :: (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 :: (a -> b) -> MSpec a c -> MSpec b c
first a -> b
f (MSpec HashMap Symbol [Def a c]
c HashMap LocSymbol (Measure a c)
m HashMap LocSymbol (Measure a ())
cm [Measure a c]
im) = HashMap Symbol [Def b c]
-> HashMap LocSymbol (Measure b c)
-> HashMap LocSymbol (Measure b ())
-> [Measure b c]
-> MSpec b c
forall ty ctor.
HashMap Symbol [Def ty ctor]
-> HashMap LocSymbol (Measure ty ctor)
-> HashMap LocSymbol (Measure ty ())
-> [Measure ty ctor]
-> MSpec ty ctor
MSpec (([Def a c] -> [Def b c])
-> HashMap Symbol [Def a c] -> HashMap Symbol [Def b c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Def a c -> Def b c) -> [Def a c] -> [Def b c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Def a c -> Def b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f)) HashMap Symbol [Def a c]
c)
                                    ((Measure a c -> Measure b c)
-> HashMap LocSymbol (Measure a c)
-> HashMap LocSymbol (Measure b c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Measure a c -> Measure b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) HashMap LocSymbol (Measure a c)
m)
                                    ((Measure a () -> Measure b ())
-> HashMap LocSymbol (Measure a ())
-> HashMap LocSymbol (Measure b ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Measure a () -> Measure b ()
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) HashMap LocSymbol (Measure a ())
cm)
                                    ((Measure a c -> Measure b c) -> [Measure a c] -> [Measure b c]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Measure a c -> Measure b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first a -> b
f) [Measure a c]
im)
  second :: (b -> c) -> MSpec a b -> MSpec a c
second                    = (b -> c) -> MSpec a b -> MSpec a c
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

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

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

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


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



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

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

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

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

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

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