diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-08-09 15:21:19 +0900 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-08-09 15:21:19 +0900 |
commit | d61a5e0a7e90c130a3b1d5af40c5bc02f4b61f61 (patch) | |
tree | 63d63ec9b0c11566c0466352166c593ecd27222e | |
parent | 6a0fe4adb9d2f1b57a742fe0e90c76903c8d7914 (diff) | |
download | stylish-haskell-d61a5e0a7e90c130a3b1d5af40c5bc02f4b61f61.tar.gz |
Records drafting
-rw-r--r-- | src/StylishHaskell/Step/Records.hs | 30 |
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 |