summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-08-09 15:21:19 +0900
committerJasper Van der Jeugt <m@jaspervdj.be>2012-08-09 15:21:19 +0900
commitd61a5e0a7e90c130a3b1d5af40c5bc02f4b61f61 (patch)
tree63d63ec9b0c11566c0466352166c593ecd27222e /src
parent6a0fe4adb9d2f1b57a742fe0e90c76903c8d7914 (diff)
downloadstylish-haskell-d61a5e0a7e90c130a3b1d5af40c5bc02f4b61f61.tar.gz
Records drafting
Diffstat (limited to 'src')
-rw-r--r--src/StylishHaskell/Step/Records.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/StylishHaskell/Step/Records.hs b/src/StylishHaskell/Step/Records.hs
new file mode 100644
index 0000000..6b25ee4
--- /dev/null
+++ b/src/StylishHaskell/Step/Records.hs
@@ -0,0 +1,30 @@
+--------------------------------------------------------------------------------
+module StylishHaskell.Step.Records where
+
+
+--------------------------------------------------------------------------------
+import qualified Language.Haskell.Exts.Annotated as H
+
+
+--------------------------------------------------------------------------------
+import StylishHaskell.Block
+
+
+--------------------------------------------------------------------------------
+records :: H.Module l -> [[H.FieldDecl l]]
+records modu =
+ [ fields
+ | H.Module _ _ _ _ decls <- [modu]
+ , H.DataDecl _ _ _ _ cons _ <- decls
+ , H.QualConDecl _ _ _ (H.RecDecl _ _ fields) <- cons
+ ]
+
+
+--------------------------------------------------------------------------------
+fieldLines :: [H.FieldDecl H.SrcSpanInfo] -> Maybe [Int]
+fieldLines rec
+ | all singleLine blocks = Just $ map blockStart blocks
+ | otherwise = Nothing
+ where
+ blocks = map (linesFromSrcSpan . H.ann) rec
+ singleLine b = blockStart b == blockEnd b