{-# Language CPP, DeriveDataTypeable #-}
#if MIN_VERSION_base(4,4,0)
#define HAS_GENERICS
{-# Language DeriveGeneric #-}
#endif
#if MIN_VERSION_template_haskell(2,12,0)
{-# Language Safe #-}
#elif __GLASGOW_HASKELL__ >= 702
{-# Language Trustworthy #-}
#endif
#if __GLASGOW_HASKELL__ >= 708
{-# Language PatternSynonyms #-}
{-# Language ViewPatterns #-}
#endif
#if __GLASGOW_HASKELL__ >= 800
#define HAS_TH_LIFT
{-# Language DeriveLift #-}
#endif
module Language.Haskell.TH.Datatype.TyVarBndr (
TyVarBndr_
, TyVarBndrUnit
, TyVarBndrSpec
, TyVarBndrVis
, Specificity(..)
#if __GLASGOW_HASKELL__ >= 907
, BndrVis(..)
#elif __GLASGOW_HASKELL__ >= 708
, BndrVis
, pattern BndrReq
, pattern BndrInvis
#else
, BndrVis
#endif
, DefaultBndrFlag(..)
, plainTVFlag
, kindedTVFlag
, plainTV
, kindedTV
, plainTVInferred
, plainTVSpecified
, kindedTVInferred
, kindedTVSpecified
, plainTVReq
, plainTVInvis
, kindedTVReq
, kindedTVInvis
, inferredSpec
, specifiedSpec
, bndrReq
, bndrInvis
, elimTV
, elimTVFlag
, mapTV
, mapTVName
, mapTVFlag
, mapTVKind
, traverseTV
, traverseTVName
, traverseTVFlag
, traverseTVKind
, mapMTV
, mapMTVName
, mapMTVFlag
, mapMTVKind
, changeTVFlags
, tvName
, tvKind
, tvFlag
) where
import Control.Applicative
import Control.Monad
import Data.Data (Typeable, Data)
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
#ifdef HAS_GENERICS
import GHC.Generics (Generic)
#endif
#if MIN_VERSION_template_haskell(2,17,0)
type TyVarBndr_ flag = TyVarBndr flag
#else
type TyVarBndr_ flag = TyVarBndr
type TyVarBndrUnit = TyVarBndr
type TyVarBndrSpec = TyVarBndr
data Specificity
= SpecifiedSpec
| InferredSpec
deriving (Show, Eq, Ord, Typeable, Data
#ifdef HAS_GENERICS
,Generic
#endif
#ifdef HAS_TH_LIFT
,Lift
#endif
)
inferredSpec :: Specificity
inferredSpec = InferredSpec
specifiedSpec :: Specificity
specifiedSpec = SpecifiedSpec
#endif
#if !MIN_VERSION_template_haskell(2,21,0)
type TyVarBndrVis = TyVarBndr_ BndrVis
type BndrVis = ()
#if __GLASGOW_HASKELL__ >= 802
{-# COMPLETE BndrReq, BndrInvis #-}
#endif
#if __GLASGOW_HASKELL__ >= 708
#if __GLASGOW_HASKELL__ >= 800
pattern BndrReq :: BndrVis
#endif
pattern $mBndrReq :: forall {r}. BndrVis -> ((# #) -> r) -> ((# #) -> r) -> r
$bBndrReq :: BndrVis
BndrReq = ()
#if __GLASGOW_HASKELL__ >= 800
pattern BndrInvis :: BndrVis
#endif
pattern $mBndrInvis :: forall {r}. BndrVis -> ((# #) -> r) -> ((# #) -> r) -> r
BndrInvis <- ((\() -> Bool
True) -> False)
#endif
bndrReq :: BndrVis
bndrReq :: BndrVis
bndrReq = ()
bndrInvis :: BndrVis
bndrInvis :: BndrVis
bndrInvis = ()
class DefaultBndrFlag flag where
defaultBndrFlag :: flag
instance DefaultBndrFlag () where
defaultBndrFlag :: BndrVis
defaultBndrFlag = ()
instance DefaultBndrFlag Specificity where
defaultBndrFlag :: Specificity
defaultBndrFlag = Specificity
SpecifiedSpec
#endif
plainTVFlag :: Name -> flag -> TyVarBndr_ flag
#if MIN_VERSION_template_haskell(2,17,0)
plainTVFlag :: forall flag. Name -> flag -> TyVarBndr_ flag
plainTVFlag = Name -> flag -> TyVarBndr flag
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV
#else
plainTVFlag n _ = PlainTV n
#endif
plainTVInferred :: Name -> TyVarBndrSpec
plainTVInferred :: Name -> TyVarBndrSpec
plainTVInferred Name
n = Name -> Specificity -> TyVarBndrSpec
forall flag. Name -> flag -> TyVarBndr_ flag
plainTVFlag Name
n Specificity
InferredSpec
plainTVSpecified :: Name -> TyVarBndrSpec
plainTVSpecified :: Name -> TyVarBndrSpec
plainTVSpecified Name
n = Name -> Specificity -> TyVarBndrSpec
forall flag. Name -> flag -> TyVarBndr_ flag
plainTVFlag Name
n Specificity
SpecifiedSpec
plainTVReq :: Name -> TyVarBndrVis
plainTVReq :: Name -> TyVarBndrVis
plainTVReq Name
n = Name -> BndrVis -> TyVarBndrVis
forall flag. Name -> flag -> TyVarBndr_ flag
plainTVFlag Name
n BndrVis
bndrReq
plainTVInvis :: Name -> TyVarBndrVis
plainTVInvis :: Name -> TyVarBndrVis
plainTVInvis Name
n = Name -> BndrVis -> TyVarBndrVis
forall flag. Name -> flag -> TyVarBndr_ flag
plainTVFlag Name
n BndrVis
bndrInvis
kindedTVFlag :: Name -> flag -> Kind -> TyVarBndr_ flag
#if MIN_VERSION_template_haskell(2,17,0)
kindedTVFlag :: forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
kindedTVFlag = Name -> flag -> Kind -> TyVarBndr flag
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV
#else
kindedTVFlag n _ kind = KindedTV n kind
#endif
kindedTVInferred :: Name -> Kind -> TyVarBndrSpec
kindedTVInferred :: Name -> Kind -> TyVarBndrSpec
kindedTVInferred Name
n Kind
k = Name -> Specificity -> Kind -> TyVarBndrSpec
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
kindedTVFlag Name
n Specificity
InferredSpec Kind
k
kindedTVSpecified :: Name -> Kind -> TyVarBndrSpec
kindedTVSpecified :: Name -> Kind -> TyVarBndrSpec
kindedTVSpecified Name
n Kind
k = Name -> Specificity -> Kind -> TyVarBndrSpec
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
kindedTVFlag Name
n Specificity
SpecifiedSpec Kind
k
kindedTVReq :: Name -> Kind -> TyVarBndrVis
kindedTVReq :: Name -> Kind -> TyVarBndrVis
kindedTVReq Name
n Kind
k = Name -> BndrVis -> Kind -> TyVarBndrVis
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
kindedTVFlag Name
n BndrVis
bndrReq Kind
k
kindedTVInvis :: Name -> Kind -> TyVarBndrVis
kindedTVInvis :: Name -> Kind -> TyVarBndrVis
kindedTVInvis Name
n Kind
k = Name -> BndrVis -> Kind -> TyVarBndrVis
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
kindedTVFlag Name
n BndrVis
bndrInvis Kind
k
elimTV :: (Name -> r) -> (Name -> Kind -> r) -> TyVarBndr_ flag -> r
#if MIN_VERSION_template_haskell(2,17,0)
elimTV :: forall r flag.
(Name -> r) -> (Name -> Kind -> r) -> TyVarBndr_ flag -> r
elimTV Name -> r
ptv Name -> Kind -> r
_ktv (PlainTV Name
n flag
_) = Name -> r
ptv Name
n
elimTV Name -> r
_ptv Name -> Kind -> r
ktv (KindedTV Name
n flag
_ Kind
k) = Name -> Kind -> r
ktv Name
n Kind
k
#else
elimTV ptv _ktv (PlainTV n) = ptv n
elimTV _ptv ktv (KindedTV n k) = ktv n k
#endif
#if MIN_VERSION_template_haskell(2,17,0)
elimTVFlag :: (Name -> flag -> r) -> (Name -> flag -> Kind -> r) -> TyVarBndr_ flag -> r
elimTVFlag :: forall flag r.
(Name -> flag -> r)
-> (Name -> flag -> Kind -> r) -> TyVarBndr_ flag -> r
elimTVFlag Name -> flag -> r
ptv Name -> flag -> Kind -> r
_ktv (PlainTV Name
n flag
flag) = Name -> flag -> r
ptv Name
n flag
flag
elimTVFlag Name -> flag -> r
_ptv Name -> flag -> Kind -> r
ktv (KindedTV Name
n flag
flag Kind
k) = Name -> flag -> Kind -> r
ktv Name
n flag
flag Kind
k
#else
elimTVFlag :: (Name -> () -> r) -> (Name -> () -> Kind -> r) -> TyVarBndr_ flag -> r
elimTVFlag ptv _ktv (PlainTV n) = ptv n ()
elimTVFlag _ptv ktv (KindedTV n k) = ktv n () k
#endif
mapTV :: (Name -> Name) -> (flag -> flag') -> (Kind -> Kind)
-> TyVarBndr_ flag -> TyVarBndr_ flag'
#if MIN_VERSION_template_haskell(2,17,0)
mapTV :: forall flag flag'.
(Name -> Name)
-> (flag -> flag')
-> (Kind -> Kind)
-> TyVarBndr_ flag
-> TyVarBndr_ flag'
mapTV Name -> Name
fn flag -> flag'
fflag Kind -> Kind
_fkind (PlainTV Name
n flag
flag) = Name -> flag' -> TyVarBndr flag'
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV (Name -> Name
fn Name
n) (flag -> flag'
fflag flag
flag)
mapTV Name -> Name
fn flag -> flag'
fflag Kind -> Kind
fkind (KindedTV Name
n flag
flag Kind
kind) = Name -> flag' -> Kind -> TyVarBndr flag'
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV (Name -> Name
fn Name
n) (flag -> flag'
fflag flag
flag) (Kind -> Kind
fkind Kind
kind)
#else
mapTV fn _fflag _fkind (PlainTV n) = PlainTV (fn n)
mapTV fn _fflag fkind (KindedTV n kind) = KindedTV (fn n) (fkind kind)
#endif
mapTVName :: (Name -> Name) -> TyVarBndr_ flag -> TyVarBndr_ flag
mapTVName :: forall flag. (Name -> Name) -> TyVarBndr_ flag -> TyVarBndr_ flag
mapTVName Name -> Name
fname = (Name -> Name)
-> (flag -> flag)
-> (Kind -> Kind)
-> TyVarBndr_ flag
-> TyVarBndr_ flag
forall flag flag'.
(Name -> Name)
-> (flag -> flag')
-> (Kind -> Kind)
-> TyVarBndr_ flag
-> TyVarBndr_ flag'
mapTV Name -> Name
fname flag -> flag
forall a. a -> a
id Kind -> Kind
forall a. a -> a
id
mapTVFlag :: (flag -> flag') -> TyVarBndr_ flag -> TyVarBndr_ flag'
#if MIN_VERSION_template_haskell(2,17,0)
mapTVFlag :: forall flag flag'.
(flag -> flag') -> TyVarBndr_ flag -> TyVarBndr_ flag'
mapTVFlag = (flag -> flag') -> TyVarBndr flag -> TyVarBndr flag'
forall flag flag'.
(flag -> flag') -> TyVarBndr_ flag -> TyVarBndr_ flag'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
#else
mapTVFlag _ = id
#endif
mapTVKind :: (Kind -> Kind) -> TyVarBndr_ flag -> TyVarBndr_ flag
mapTVKind :: forall flag. (Kind -> Kind) -> TyVarBndr_ flag -> TyVarBndr_ flag
mapTVKind Kind -> Kind
fkind = (Name -> Name)
-> (flag -> flag)
-> (Kind -> Kind)
-> TyVarBndr_ flag
-> TyVarBndr_ flag
forall flag flag'.
(Name -> Name)
-> (flag -> flag')
-> (Kind -> Kind)
-> TyVarBndr_ flag
-> TyVarBndr_ flag'
mapTV Name -> Name
forall a. a -> a
id flag -> flag
forall a. a -> a
id Kind -> Kind
fkind
traverseTV :: Applicative f
=> (Name -> f Name) -> (flag -> f flag') -> (Kind -> f Kind)
-> TyVarBndr_ flag -> f (TyVarBndr_ flag')
#if MIN_VERSION_template_haskell(2,17,0)
traverseTV :: forall (f :: * -> *) flag flag'.
Applicative f =>
(Name -> f Name)
-> (flag -> f flag')
-> (Kind -> f Kind)
-> TyVarBndr_ flag
-> f (TyVarBndr_ flag')
traverseTV Name -> f Name
fn flag -> f flag'
fflag Kind -> f Kind
_fkind (PlainTV Name
n flag
flag) =
(Name -> flag' -> TyVarBndr_ flag')
-> f Name -> f flag' -> f (TyVarBndr_ flag')
forall a b c. (a -> b -> c) -> f a -> f b -> f c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Name -> flag' -> TyVarBndr_ flag'
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV (Name -> f Name
fn Name
n) (flag -> f flag'
fflag flag
flag)
traverseTV Name -> f Name
fn flag -> f flag'
fflag Kind -> f Kind
fkind (KindedTV Name
n flag
flag Kind
kind) =
(Name -> flag' -> Kind -> TyVarBndr_ flag')
-> f Name -> f flag' -> f Kind -> f (TyVarBndr_ flag')
forall (f :: * -> *) a b c d.
Applicative f =>
(a -> b -> c -> d) -> f a -> f b -> f c -> f d
liftA3 Name -> flag' -> Kind -> TyVarBndr_ flag'
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV (Name -> f Name
fn Name
n) (flag -> f flag'
fflag flag
flag) (Kind -> f Kind
fkind Kind
kind)
#else
traverseTV fn _fflag _fkind (PlainTV n) =
PlainTV <$> fn n
traverseTV fn _fflag fkind (KindedTV n kind) =
liftA2 KindedTV (fn n) (fkind kind)
#endif
traverseTVName :: Functor f
=> (Name -> f Name)
-> TyVarBndr_ flag -> f (TyVarBndr_ flag)
#if MIN_VERSION_template_haskell(2,17,0)
traverseTVName :: forall (f :: * -> *) flag.
Functor f =>
(Name -> f Name) -> TyVarBndr_ flag -> f (TyVarBndr_ flag)
traverseTVName Name -> f Name
fn (PlainTV Name
n flag
flag) =
(\Name
n' -> Name -> flag -> TyVarBndr flag
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV Name
n' flag
flag) (Name -> TyVarBndr flag) -> f Name -> f (TyVarBndr flag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
fn Name
n
traverseTVName Name -> f Name
fn (KindedTV Name
n flag
flag Kind
kind) =
(\Name
n' -> Name -> flag -> Kind -> TyVarBndr flag
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV Name
n' flag
flag Kind
kind) (Name -> TyVarBndr flag) -> f Name -> f (TyVarBndr flag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
fn Name
n
#else
traverseTVName fn (PlainTV n) =
PlainTV <$> fn n
traverseTVName fn (KindedTV n kind) =
(\n' -> KindedTV n' kind) <$> fn n
#endif
traverseTVFlag :: Applicative f
=> (flag -> f flag')
-> TyVarBndr_ flag -> f (TyVarBndr_ flag')
#if MIN_VERSION_template_haskell(2,17,0)
traverseTVFlag :: forall (f :: * -> *) flag flag'.
Applicative f =>
(flag -> f flag') -> TyVarBndr_ flag -> f (TyVarBndr_ flag')
traverseTVFlag flag -> f flag'
fflag (PlainTV Name
n flag
flag) =
Name -> flag' -> TyVarBndr flag'
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV Name
n (flag' -> TyVarBndr flag') -> f flag' -> f (TyVarBndr flag')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> flag -> f flag'
fflag flag
flag
traverseTVFlag flag -> f flag'
fflag (KindedTV Name
n flag
flag Kind
kind) =
(\flag'
flag' -> Name -> flag' -> Kind -> TyVarBndr flag'
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV Name
n flag'
flag' Kind
kind) (flag' -> TyVarBndr flag') -> f flag' -> f (TyVarBndr flag')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> flag -> f flag'
fflag flag
flag
#else
traverseTVFlag _ = pure
#endif
traverseTVKind :: Applicative f
=> (Kind -> f Kind)
-> TyVarBndr_ flag -> f (TyVarBndr_ flag)
#if MIN_VERSION_template_haskell(2,17,0)
traverseTVKind :: forall (f :: * -> *) flag.
Applicative f =>
(Kind -> f Kind) -> TyVarBndr_ flag -> f (TyVarBndr_ flag)
traverseTVKind Kind -> f Kind
_fkind tvb :: TyVarBndr_ flag
tvb@PlainTV{} =
TyVarBndr_ flag -> f (TyVarBndr_ flag)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TyVarBndr_ flag
tvb
traverseTVKind Kind -> f Kind
fkind (KindedTV Name
n flag
flag Kind
kind) =
Name -> flag -> Kind -> TyVarBndr_ flag
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV Name
n flag
flag (Kind -> TyVarBndr_ flag) -> f Kind -> f (TyVarBndr_ flag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Kind -> f Kind
fkind Kind
kind
#else
traverseTVKind _fkind tvb@PlainTV{} =
pure tvb
traverseTVKind fkind (KindedTV n kind) =
KindedTV n <$> fkind kind
#endif
mapMTV :: Monad m
=> (Name -> m Name) -> (flag -> m flag') -> (Kind -> m Kind)
-> TyVarBndr_ flag -> m (TyVarBndr_ flag')
#if MIN_VERSION_template_haskell(2,17,0)
mapMTV :: forall (m :: * -> *) flag flag'.
Monad m =>
(Name -> m Name)
-> (flag -> m flag')
-> (Kind -> m Kind)
-> TyVarBndr_ flag
-> m (TyVarBndr_ flag')
mapMTV Name -> m Name
fn flag -> m flag'
fflag Kind -> m Kind
_fkind (PlainTV Name
n flag
flag) =
(Name -> flag' -> TyVarBndr_ flag')
-> m Name -> m flag' -> m (TyVarBndr_ flag')
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Name -> flag' -> TyVarBndr_ flag'
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV (Name -> m Name
fn Name
n) (flag -> m flag'
fflag flag
flag)
mapMTV Name -> m Name
fn flag -> m flag'
fflag Kind -> m Kind
fkind (KindedTV Name
n flag
flag Kind
kind) =
(Name -> flag' -> Kind -> TyVarBndr_ flag')
-> m Name -> m flag' -> m Kind -> m (TyVarBndr_ flag')
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 Name -> flag' -> Kind -> TyVarBndr_ flag'
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV (Name -> m Name
fn Name
n) (flag -> m flag'
fflag flag
flag) (Kind -> m Kind
fkind Kind
kind)
#else
mapMTV fn _fflag _fkind (PlainTV n) =
liftM PlainTV (fn n)
mapMTV fn _fflag fkind (KindedTV n kind) =
liftM2 KindedTV (fn n) (fkind kind)
#endif
mapMTVName :: Monad m
=> (Name -> m Name)
-> TyVarBndr_ flag -> m (TyVarBndr_ flag)
#if MIN_VERSION_template_haskell(2,17,0)
mapMTVName :: forall (m :: * -> *) flag.
Monad m =>
(Name -> m Name) -> TyVarBndr_ flag -> m (TyVarBndr_ flag)
mapMTVName Name -> m Name
fn (PlainTV Name
n flag
flag) =
(Name -> TyVarBndr flag) -> m Name -> m (TyVarBndr flag)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\Name
n' -> Name -> flag -> TyVarBndr flag
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV Name
n' flag
flag) (Name -> m Name
fn Name
n)
mapMTVName Name -> m Name
fn (KindedTV Name
n flag
flag Kind
kind) =
(Name -> TyVarBndr flag) -> m Name -> m (TyVarBndr flag)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\Name
n' -> Name -> flag -> Kind -> TyVarBndr flag
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV Name
n' flag
flag Kind
kind) (Name -> m Name
fn Name
n)
#else
mapMTVName fn (PlainTV n) =
liftM PlainTV (fn n)
mapMTVName fn (KindedTV n kind) =
liftM (\n' -> KindedTV n' kind) (fn n)
#endif
mapMTVFlag :: Monad m
=> (flag -> m flag')
-> TyVarBndr_ flag -> m (TyVarBndr_ flag')
#if MIN_VERSION_template_haskell(2,17,0)
mapMTVFlag :: forall (m :: * -> *) flag flag'.
Monad m =>
(flag -> m flag') -> TyVarBndr_ flag -> m (TyVarBndr_ flag')
mapMTVFlag flag -> m flag'
fflag (PlainTV Name
n flag
flag) =
(flag' -> TyVarBndr_ flag') -> m flag' -> m (TyVarBndr_ flag')
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Name -> flag' -> TyVarBndr_ flag'
forall flag. Name -> flag -> TyVarBndr_ flag
PlainTV Name
n) (flag -> m flag'
fflag flag
flag)
mapMTVFlag flag -> m flag'
fflag (KindedTV Name
n flag
flag Kind
kind) =
(flag' -> TyVarBndr_ flag') -> m flag' -> m (TyVarBndr_ flag')
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\flag'
flag' -> Name -> flag' -> Kind -> TyVarBndr_ flag'
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV Name
n flag'
flag' Kind
kind) (flag -> m flag'
fflag flag
flag)
#else
mapMTVFlag _ = return
#endif
mapMTVKind :: Monad m
=> (Kind -> m Kind)
-> TyVarBndr_ flag -> m (TyVarBndr_ flag)
#if MIN_VERSION_template_haskell(2,17,0)
mapMTVKind :: forall (m :: * -> *) flag.
Monad m =>
(Kind -> m Kind) -> TyVarBndr_ flag -> m (TyVarBndr_ flag)
mapMTVKind Kind -> m Kind
_fkind tvb :: TyVarBndr_ flag
tvb@PlainTV{} =
TyVarBndr_ flag -> m (TyVarBndr_ flag)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return TyVarBndr_ flag
tvb
mapMTVKind Kind -> m Kind
fkind (KindedTV Name
n flag
flag Kind
kind) =
(Kind -> TyVarBndr_ flag) -> m Kind -> m (TyVarBndr_ flag)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Name -> flag -> Kind -> TyVarBndr_ flag
forall flag. Name -> flag -> Kind -> TyVarBndr_ flag
KindedTV Name
n flag
flag) (Kind -> m Kind
fkind Kind
kind)
#else
mapMTVKind _fkind tvb@PlainTV{} =
return tvb
mapMTVKind fkind (KindedTV n kind) =
liftM (KindedTV n) (fkind kind)
#endif
changeTVFlags :: newFlag -> [TyVarBndr_ oldFlag] -> [TyVarBndr_ newFlag]
#if MIN_VERSION_template_haskell(2,17,0)
changeTVFlags :: forall newFlag oldFlag.
newFlag -> [TyVarBndr_ oldFlag] -> [TyVarBndr_ newFlag]
changeTVFlags newFlag
newFlag = (TyVarBndr_ oldFlag -> TyVarBndr_ newFlag)
-> [TyVarBndr_ oldFlag] -> [TyVarBndr_ newFlag]
forall a b. (a -> b) -> [a] -> [b]
map (newFlag
newFlag newFlag -> TyVarBndr_ oldFlag -> TyVarBndr_ newFlag
forall a b. a -> TyVarBndr b -> TyVarBndr a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$)
#else
changeTVFlags _ = id
#endif
tvName :: TyVarBndr_ flag -> Name
tvName :: forall flag. TyVarBndr_ flag -> Name
tvName = (Name -> Name) -> (Name -> Kind -> Name) -> TyVarBndr_ flag -> Name
forall r flag.
(Name -> r) -> (Name -> Kind -> r) -> TyVarBndr_ flag -> r
elimTV Name -> Name
forall a. a -> a
id (\Name
n Kind
_ -> Name
n)
tvKind :: TyVarBndr_ flag -> Kind
tvKind :: forall flag. TyVarBndr_ flag -> Kind
tvKind = (Name -> Kind) -> (Name -> Kind -> Kind) -> TyVarBndr_ flag -> Kind
forall r flag.
(Name -> r) -> (Name -> Kind -> r) -> TyVarBndr_ flag -> r
elimTV (\Name
_ -> Kind
starK) (\Name
_ Kind
k -> Kind
k)
#if MIN_VERSION_template_haskell(2,17,0)
tvFlag :: TyVarBndr_ flag -> flag
tvFlag :: forall flag. TyVarBndr_ flag -> flag
tvFlag = (Name -> flag -> flag)
-> (Name -> flag -> Kind -> flag) -> TyVarBndr_ flag -> flag
forall flag r.
(Name -> flag -> r)
-> (Name -> flag -> Kind -> r) -> TyVarBndr_ flag -> r
elimTVFlag (\Name
_ flag
flag -> flag
flag) (\Name
_ flag
flag Kind
_ -> flag
flag)
#else
tvFlag :: TyVarBndr_ flag -> ()
tvFlag _ = ()
#endif