Skip to content

Commit

Permalink
Backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abrar committed Nov 18, 2020
1 parent 4f2a06f commit b442eeb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
10 changes: 5 additions & 5 deletions aeson-gadt-th.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.0
cabal-version: 1.24
name: aeson-gadt-th
version: 0.2.4
synopsis: Derivation of Aeson instances for GADTs
Expand All @@ -21,12 +21,12 @@ flag build-readme
library
exposed-modules: Data.Aeson.GADT.TH
build-depends: base >= 4.8 && < 4.15
, aeson >= 1.4 && < 1.5
, aeson >= 1.3 && < 1.5
, containers >= 0.5 && < 0.7
, dependent-sum >= 0.6.1 && < 0.8
, dependent-sum >= 0.4 && < 0.8
, transformers >= 0.5 && < 0.6
, template-haskell >= 2.11.0 && < 2.17
, th-abstraction >= 0.3.1.0 && < 0.4
, template-haskell >= 2.11.0 && < 2.16
, th-abstraction >= 0.2.8.0 && < 0.4
, th-extras >= 0.0.0.4 && < 0.1
if impl(ghc < 8.2)
build-depends: dependent-sum < 0.6.2.2
Expand Down
7 changes: 7 additions & 0 deletions src/Data/Aeson/GADT/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -51,6 +52,12 @@ import Language.Haskell.TH.Datatype

import System.IO (hFlush, stdout)

#if MIN_VERSION_dependent_sum(0,5,0)
#else
pattern Some :: tag a -> Some tag
pattern Some x = This x
#endif

-- Do not export this type family, it must remain empty. It's used as a way to trick GHC into not unifying certain type variables.
type family Skolem :: k -> k

Expand Down
8 changes: 8 additions & 0 deletions test/Test.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
Expand All @@ -15,6 +17,12 @@ import Data.Aeson.GADT.TH
import Expectations
import Test.Hspec

#if MIN_VERSION_dependent_sum(0,5,0)
#else
pattern Some :: tag a -> Some tag
pattern Some x = This x
#endif

main :: IO ()
main = hspec $ do
describe "aeson-gadt-th" $ do
Expand Down

0 comments on commit b442eeb

Please sign in to comment.