File: V0208.hs

package info (click to toggle)
haskell-template-haskell-compat-v0208 0.1.9.4-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 56 kB
  • sloc: haskell: 163; makefile: 5
file content (118 lines) | stat: -rw-r--r-- 2,767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{-# LANGUAGE CPP #-}

module TemplateHaskell.Compat.V0208 where

import Language.Haskell.TH hiding (conP)
import TemplateHaskell.Compat.V0208.Prelude

classP :: Name -> [Type] -> Pred
#if MIN_VERSION_template_haskell(2,10,0)
classP n tl =
  foldl AppT (ConT n) tl
#else
classP =
  ClassP
#endif

instanceD :: Cxt -> Type -> [Dec] -> Dec
#if MIN_VERSION_template_haskell(2,11,0)  
instanceD =
  InstanceD Nothing
#else
instanceD =
  InstanceD
#endif

dataD :: Cxt -> Name -> [UnitTyVarBndr] -> [Con] -> [Name] -> Dec
#if MIN_VERSION_template_haskell(2,21,0)
dataD cxt name varBndrs cons derivingNames =
  DataD cxt name preparedVarBndrs Nothing cons (pure (DerivClause Nothing (map ConT derivingNames)))
  where
    preparedVarBndrs :: [TyVarBndr BndrVis]
    preparedVarBndrs =
      fmap (fmap (const BndrReq)) varBndrs
#elif MIN_VERSION_template_haskell(2,12,0)
dataD cxt name varBndrs cons derivingNames =
  DataD cxt name varBndrs Nothing cons (pure (DerivClause Nothing (map ConT derivingNames)))
#elif MIN_VERSION_template_haskell(2,11,0)
dataD cxt name varBndrs cons derivingNames =
  DataD cxt name varBndrs Nothing cons (map ConT derivingNames)
#else
dataD cxt name varBndrs cons derivingNames =
  DataD cxt name varBndrs cons derivingNames
#endif

notStrict :: Strict
#if MIN_VERSION_template_haskell(2,11,0)
notStrict =
  Bang NoSourceUnpackedness NoSourceStrictness
#else
notStrict =
  NotStrict
#endif

tupE :: [Exp] -> Exp
#if MIN_VERSION_template_haskell(2,16,0)
tupE = \ case
  [a] -> a
  a -> TupE (map Just a)
#else
tupE = TupE
#endif

flaglessPlainTV :: Name -> UnitTyVarBndr
#if MIN_VERSION_template_haskell(2,17,0)
flaglessPlainTV name = PlainTV name ()
#else
flaglessPlainTV = PlainTV
#endif

specifiedPlainTV :: Name -> SpecificityTyVarBndr
#if MIN_VERSION_template_haskell(2,17,0)
specifiedPlainTV = flip PlainTV SpecifiedSpec
#else
specifiedPlainTV = PlainTV
#endif

#if MIN_VERSION_template_haskell(2,17,0)
type SpecificityTyVarBndr = TyVarBndr Specificity
#else
type SpecificityTyVarBndr = TyVarBndr
#endif

#if MIN_VERSION_template_haskell(2,17,0)
type UnitTyVarBndr = TyVarBndr ()
#else
type UnitTyVarBndr = TyVarBndr
#endif

doE :: [Stmt] -> Exp
#if MIN_VERSION_template_haskell(2,17,0)
doE = DoE Nothing
#else
doE = DoE
#endif

#if MIN_VERSION_template_haskell(2,17,0)
tyVarBndrKind :: TyVarBndr flag -> Maybe Kind
tyVarBndrKind = \ case
  KindedTV _ _ a -> Just a
  _ -> Nothing
#else
tyVarBndrKind :: TyVarBndr -> Maybe Kind
tyVarBndrKind = \ case
  KindedTV _ a -> Just a
  _ -> Nothing
#endif

#if MIN_VERSION_template_haskell(2,18,0)
conP :: Name -> [Pat] -> Pat
conP name pats = ConP name [] pats
#else
conP :: Name -> [Pat] -> Pat
conP = ConP
#endif

{-# DEPRECATED conp "Use 'conP'" #-}
conp :: Name -> [Pat] -> Pat
conp = conP