summaryrefslogtreecommitdiff
path: root/ghc-exactprint.cabal
blob: f9b25566c272f1227538bb0483c2c5f5fb28c79d (plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name:                ghc-exactprint
version:             0.5.6.1
synopsis:            ExactPrint for GHC
description:         Using the API Annotations available from GHC 7.10.2, this
                     library provides a means to round trip any code that can
                     be compiled by GHC, currently excluding lhs files.
                     .
                     It does this with a phased approach
                     .
                        * Delta - converts GHC API Annotations into relative
                          offsets, indexed by SrcSpan
                     .
                        * Transform - functions to facilitate changes to
                          the AST, adjusting the annotations generated in the
                          Delta phase to suit the changes.
                     .
                        * Print - converts an AST and its annotations to
                          properly formatted source text.
                     .
                        * Pretty - adds annotations to an AST (fragment) so that
                          the output can be parsed back to the same AST.
                     .
                     .
                     Note: requires GHC 7.10.2 or later

license:             BSD3
license-file:        LICENSE
author:              Alan Zimmerman, Matthew Pickering
maintainer:          alan.zimm@gmail.com
category:            Development
build-type:          Simple
tested-with:    GHC == 7.10.3, GHC == 8.0.1, GHC == 8.0.2, GHC == 8.2.2
extra-source-files:  ChangeLog
                     src-ghc710/Language/Haskell/GHC/ExactPrint/*.hs
                     tests/examples/failing/*.hs
                     tests/examples/ghc710/*.hs
                     tests/examples/ghc710-only/*.hs
                     tests/examples/ghc80/*.hs
                     tests/examples/ghc82/*.hs
                     tests/examples/ghc84/*.hs
                     tests/examples/transform/*.hs
                     tests/examples/failing/*.hs.bad
                     tests/examples/transform/*.hs.expected
                     tests/examples/ghc710/*.hs-boot
cabal-version:       >=1.10

source-repository head
  type:     git
  location: https://github.com/alanz/ghc-exactprint.git

Flag roundtrip {
  Description: Build roundtripping executables
  Default:     False
}

Flag dev {
  Description: Development mode, do not use ghc-exactprint lib in the tests
  Default:     False
}


library
  exposed-modules:     Language.Haskell.GHC.ExactPrint
                     , Language.Haskell.GHC.ExactPrint.Annotate
                     , Language.Haskell.GHC.ExactPrint.AnnotateTypes
                     , Language.Haskell.GHC.ExactPrint.Annotater
                     , Language.Haskell.GHC.ExactPrint.Delta
                     , Language.Haskell.GHC.ExactPrint.Lookup
                     , Language.Haskell.GHC.ExactPrint.Parsers
                     , Language.Haskell.GHC.ExactPrint.Preprocess
                     , Language.Haskell.GHC.ExactPrint.Pretty
                     , Language.Haskell.GHC.ExactPrint.Print
                     , Language.Haskell.GHC.ExactPrint.Transform
                     , Language.Haskell.GHC.ExactPrint.Types
                     , Language.Haskell.GHC.ExactPrint.Utils

  if impl (ghc <= 8.0.2)
      exposed-modules: Language.Haskell.GHC.ExactPrint.GhcInterim

  -- other-modules:
  -- other-extensions:
  GHC-Options:         -Wall
  build-depends:       base >=4.7 && <4.12
                     , bytestring >= 0.10.6
                     , containers >= 0.5
                     , directory >= 1.2
                     , filepath  >= 1.4
                     , ghc       >= 7.10.2
                     , ghc-paths >= 0.1
                     , mtl       >= 2.2.1
                     , syb       >= 0.5
                     , free      >= 4.12
  if impl (ghc >= 7.11)
      build-depends: ghc-boot
  hs-source-dirs:      src

  if impl (ghc > 8.2.2)
      hs-source-dirs: src-ghc84
  else
    if impl (ghc > 8.0.3)
        hs-source-dirs: src-ghc82
    else
      if impl (ghc > 7.10.3)
          hs-source-dirs: src-ghc80
      else
          hs-source-dirs: src-ghc710

  default-language:    Haskell2010
  if impl (ghc < 7.10.2)
      buildable: False

Test-Suite test
  type:                exitcode-stdio-1.0
  if flag (dev)
    hs-source-dirs:      tests
                         src
  else
    hs-source-dirs:      tests

  if impl (ghc > 8.2.2)
      hs-source-dirs: src-ghc84
  else
    if impl (ghc > 8.0.3)
        hs-source-dirs: src-ghc82
    else
      if impl (ghc > 7.10.3)
          hs-source-dirs: src-ghc80
      else
          hs-source-dirs: src-ghc710

  main-is:             Test.hs
  other-modules:       Test.Common
                     , Test.Consistency
                     , Test.NoAnnotations
                     , Test.Transform
  GHC-Options:         -threaded -Wall
  Default-language:    Haskell2010
  if impl (ghc < 7.10.2)
      buildable: False
  Build-depends:       HUnit >= 1.2
                     , base < 4.12
                     , bytestring
                     , containers >= 0.5
                     , Diff
                     , directory >= 1.2
                     , filepath  >= 1.4
                     , ghc  >= 7.10.2
                     , ghc-paths  >= 0.1
                     , mtl        >= 2.2.1
                     , syb        >= 0.5
                     , silently   >= 1.2
                     , filemanip  >= 0.3
                     -- for the lib only
  if flag (dev)
      build-depends: free
  else
      build-depends: ghc-exactprint >= 0.5.4

  if impl (ghc >= 7.11)
      build-depends: ghc-boot

executable roundtrip
  main-is: Roundtrip.hs
  hs-source-dirs: tests
  other-modules: Test.Common
  default-language:    Haskell2010
  if impl (ghc >= 7.10.2) && flag (roundtrip)
    build-depends:
                 HUnit
               , base
               , containers
               , directory
               , filemanip
               , filepath
               , ghc
               , ghc-exactprint
               , ghc-paths
               , syb
               , temporary
               , time
    if impl (ghc >= 7.11)
        build-depends: ghc-boot
    buildable: True
  else
    buildable: False
  ghc-options:
    -threaded -Wall

executable static
  main-is: Static.hs
  hs-source-dirs: tests
  default-language:    Haskell2010
  if flag (roundtrip)
    build-depends: base
                 , directory
                 , filemanip
                 , filepath
                 , ghc
                 , Diff
    buildable: True
    if impl (ghc >= 7.11)
        build-depends: ghc-boot
  else
    buildable: False
  ghc-options:
    -threaded -Wall

executable prepare-hackage
  main-is: PrepareHackage.hs
  hs-source-dirs: tests
  default-language:    Haskell2010
  if flag (roundtrip)
    build-depends: base
                 , containers
                 , directory
                 , filemanip
                 , filepath
                 , ghc       >= 7.10.2
                 , ghc-paths >= 0.1
                 , HUnit
                 , text   >= 1.2.2
                 , turtle >= 1.3.0
    buildable: True
    if impl (ghc >= 7.11)
        build-depends: ghc-boot
  else
    buildable: False
  GHC-Options:         -threaded