Skip to content

Commit 1e7efb5

Browse files
committed
base provide stripPrefix since at least 4.9
1 parent c42e544 commit 1e7efb5

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

vector/tests/Boilerplater.hs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Boilerplater where
22

3+
import Data.List (stripPrefix)
34
import Test.Tasty.QuickCheck
45

56
import Language.Haskell.TH
@@ -8,20 +9,4 @@ import Language.Haskell.TH
89
testProperties :: [Name] -> Q Exp
910
testProperties nms = fmap ListE $ sequence [[| testProperty $(stringE prop_name) $(varE nm) |]
1011
| nm <- nms
11-
, Just prop_name <- [stripPrefix_maybe "prop_" (nameBase nm)]]
12-
13-
-- This nice clean solution doesn't quite work since I need to use lexically-scoped type
14-
-- variables, which aren't supported by Template Haskell. Argh!
15-
-- testProperties :: Q [Dec] -> Q Exp
16-
-- testProperties mdecs = do
17-
-- decs <- mdecs
18-
-- property_exprs <- sequence [[| testProperty "$prop_name" $(return $ VarE nm) |]
19-
-- | FunD nm _clauses <- decs
20-
-- , Just prop_name <- [stripPrefix_maybe "prop_" (nameBase nm)]]
21-
-- return $ LetE decs (ListE property_exprs)
22-
23-
stripPrefix_maybe :: String -> String -> Maybe String
24-
stripPrefix_maybe prefix what
25-
| what_start == prefix = Just what_end
26-
| otherwise = Nothing
27-
where (what_start, what_end) = splitAt (length prefix) what
12+
, Just prop_name <- [stripPrefix "prop_" (nameBase nm)]]

0 commit comments

Comments
 (0)