record-dot-preprocessor 0.2.4 → 0.2.5
raw patch · 5 files changed
+22/−5 lines, 5 files
Files
- CHANGES.txt +2/−0
- examples/Both.hs +12/−2
- preprocessor/Edit.hs +6/−1
- record-dot-preprocessor.cabal +1/−1
- test/PluginExample.hs +1/−1
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for record-dot-preprocessor +0.2.5, released 2020-05-06+ #28, deal with kind signatures on data types 0.2.4, released 2020-05-04 #3, emit more LINE declarations 0.2.3, released 2020-04-01
examples/Both.hs view
@@ -1,14 +1,14 @@ -- Test for everything that is supported by both the plugin and the preprocessor {-# OPTIONS_GHC -Werror -Wall -Wno-type-defaults -Wno-partial-type-signatures #-} -- can we produce -Wall clean code-{-# LANGUAGE PartialTypeSignatures, GADTs, StandaloneDeriving, DataKinds #-} -- also tests we put language extensions before imports+{-# LANGUAGE PartialTypeSignatures, GADTs, StandaloneDeriving, DataKinds, KindSignatures #-} -- also tests we put language extensions before imports import Control.Exception import Data.Version import Data.Proxy main :: IO ()-main = test1 >> test2 >> test3 >> test4 >> test5 >> test6 >> putStrLn "All worked"+main = test1 >> test2 >> test3 >> test4 >> test5 >> test6 >> test7 >> putStrLn "All worked" (===) :: (Show a, Eq a) => a -> a -> IO () a === b = if a == b then pure () else fail $ "Mismatch, " ++ show a ++ " /= " ++ show b@@ -172,3 +172,13 @@ test6 = do _ <- evaluate typeProxy return ()+++-- ---------------------------------------------------------------------+-- Deal with kind signatures++data UserF (f :: * -> *) = UserF { userf_name :: String }++test7 :: IO ()+test7 = do+ (UserF "test").userf_name === "test"
preprocessor/Edit.hs view
@@ -188,8 +188,13 @@ whole xs | PL typeName : xs <- xs , (typeArgs, _:xs) <- break (isPL "=" ||^ isPL "where") xs- = Just $ Record typeName [x | PL x <- typeArgs] $ nubOrd $ ctor xs+ = Just $ Record typeName (mapMaybe typeArg typeArgs) $ nubOrd $ ctor xs whole _ = Nothing++ -- some types are raw, some are in brackets (with a kind signature)+ typeArg (PL x) = Just x+ typeArg (Paren _ (x:_) _) = typeArg x+ typeArg _ = Nothing ctor xs | xs <- dropContext xs
record-dot-preprocessor.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: record-dot-preprocessor-version: 0.2.4+version: 0.2.5 license: BSD3 x-license: BSD-3-Clause OR Apache-2.0 license-file: LICENSE
test/PluginExample.hs view
@@ -17,7 +17,7 @@ {-# OPTIONS_GHC -fplugin=RecordDotPreprocessor -w #-} {-# LANGUAGE DuplicateRecordFields, TypeApplications, FlexibleContexts, DataKinds, MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}-{-# LANGUAGE PartialTypeSignatures, GADTs, StandaloneDeriving #-} -- because it's now treated as a comment+{-# LANGUAGE PartialTypeSignatures, GADTs, StandaloneDeriving, KindSignatures #-} -- because it's now treated as a comment module PluginExample where #include "../examples/Both.hs"