mirror of
https://github.com/ocharles/weeder.git
synced 2024-11-29 10:15:33 +03:00
Compare commits
8 Commits
ed3bdb1697
...
3da1bc492a
Author | SHA1 | Date | |
---|---|---|---|
|
3da1bc492a | ||
|
27ff3674a5 | ||
|
6aa54d64b5 | ||
|
b8006fe0c8 | ||
|
0a5be87c88 | ||
|
057799f054 | ||
|
3fc3f7a1d1 | ||
|
a43ecc61a3 |
6
test/Spec/TemplateHaskell.failing
Normal file
6
test/Spec/TemplateHaskell.failing
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
main: test/Spec/TemplateHaskell/TH.hs:22:1: threeQ
|
||||||
|
main: test/Spec/TemplateHaskell/TH.hs:25:1: intQQ
|
||||||
|
main: test/Spec/TemplateHaskell/TH.hs:33:1: zero1
|
||||||
|
main: test/Spec/TemplateHaskell/TH.hs:36:1: zero2
|
||||||
|
main: test/Spec/TemplateHaskell/TH.hs:39:1: zero3
|
||||||
|
main: test/Spec/TemplateHaskell/TH.hs:42:1: zero4
|
0
test/Spec/TemplateHaskell.stdout
Normal file
0
test/Spec/TemplateHaskell.stdout
Normal file
7
test/Spec/TemplateHaskell.toml
Normal file
7
test/Spec/TemplateHaskell.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
roots = [ "Spec.TemplateHaskell.User.root" ]
|
||||||
|
|
||||||
|
type-class-roots = false
|
||||||
|
|
||||||
|
unused-types = false
|
||||||
|
|
||||||
|
root-instances = []
|
42
test/Spec/TemplateHaskell/TH.hs
Normal file
42
test/Spec/TemplateHaskell/TH.hs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
module Spec.TemplateHaskell.TH (intQQ, oneQ, twoQ, two, three, threeQ) where
|
||||||
|
|
||||||
|
import Language.Haskell.TH
|
||||||
|
import Language.Haskell.TH.Quote
|
||||||
|
|
||||||
|
oneQ :: Q Exp
|
||||||
|
oneQ = pure . LitE $ IntegerL one
|
||||||
|
|
||||||
|
one :: Integer
|
||||||
|
one = 1
|
||||||
|
|
||||||
|
two :: Int
|
||||||
|
two = 2
|
||||||
|
|
||||||
|
twoQ :: Q Exp
|
||||||
|
twoQ = pure . VarE $ mkName "two"
|
||||||
|
|
||||||
|
three :: Int
|
||||||
|
three = 3
|
||||||
|
|
||||||
|
threeQ :: Q [Dec]
|
||||||
|
threeQ = pure [ValD (VarP $ mkName "three'") (NormalB . VarE $ mkName "three") []]
|
||||||
|
|
||||||
|
intQQ :: QuasiQuoter
|
||||||
|
intQQ = QuasiQuoter
|
||||||
|
{ quoteExp = pure . LitE . IntegerL . (zero1 +) . read
|
||||||
|
, quotePat = pure . LitP . IntegerL . (zero2 +) . read
|
||||||
|
, quoteType = pure . LitT . NumTyLit . (zero3 +) . read
|
||||||
|
, quoteDec = pure . pure . (\i -> ValD (VarP $ mkName "quote") (NormalB $ LitE $ IntegerL i) []) . (zero4 +) . read
|
||||||
|
}
|
||||||
|
|
||||||
|
zero1 :: Integer
|
||||||
|
zero1 = 0
|
||||||
|
|
||||||
|
zero2 :: Integer
|
||||||
|
zero2 = 0
|
||||||
|
|
||||||
|
zero3 :: Integer
|
||||||
|
zero3 = 0
|
||||||
|
|
||||||
|
zero4 :: Integer
|
||||||
|
zero4 = 0
|
22
test/Spec/TemplateHaskell/User.hs
Normal file
22
test/Spec/TemplateHaskell/User.hs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
{-# LANGUAGE DataKinds #-}
|
||||||
|
{-# LANGUAGE KindSignatures #-}
|
||||||
|
|
||||||
|
module Spec.TemplateHaskell.User where
|
||||||
|
|
||||||
|
import Spec.TemplateHaskell.TH
|
||||||
|
import GHC.TypeLits (Nat)
|
||||||
|
|
||||||
|
$(threeQ)
|
||||||
|
|
||||||
|
newtype T (a :: Nat) = T Int
|
||||||
|
|
||||||
|
root :: T [intQQ|1|]
|
||||||
|
root = T $ $(oneQ) + [intQQ|1|] + quote + f (1 :: Int) + $(twoQ) + three'
|
||||||
|
where
|
||||||
|
f [intQQ|1|] = 1
|
||||||
|
f _ = 1
|
||||||
|
|
||||||
|
quote :: Int
|
||||||
|
[intQQ|2|]
|
@ -77,6 +77,7 @@ test-suite weeder-test
|
|||||||
, tasty
|
, tasty
|
||||||
, tasty-hunit-compat
|
, tasty-hunit-compat
|
||||||
, tasty-golden
|
, tasty-golden
|
||||||
|
, template-haskell
|
||||||
, text
|
, text
|
||||||
, toml-reader
|
, toml-reader
|
||||||
, weeder
|
, weeder
|
||||||
@ -110,6 +111,8 @@ test-suite weeder-test
|
|||||||
Spec.RangeEnum.RangeEnum
|
Spec.RangeEnum.RangeEnum
|
||||||
Spec.RootClasses.RootClasses
|
Spec.RootClasses.RootClasses
|
||||||
Spec.StandaloneDeriving.StandaloneDeriving
|
Spec.StandaloneDeriving.StandaloneDeriving
|
||||||
|
Spec.TemplateHaskell.TH
|
||||||
|
Spec.TemplateHaskell.User
|
||||||
Spec.TypeAliasGADT.TypeAliasGADT
|
Spec.TypeAliasGADT.TypeAliasGADT
|
||||||
Spec.TypeDataDecl.TypeDataDecl
|
Spec.TypeDataDecl.TypeDataDecl
|
||||||
Spec.Types.Types
|
Spec.Types.Types
|
||||||
|
Loading…
Reference in New Issue
Block a user