summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Snoyman <michael@snoyman.com>2012-09-13 06:31:27 +0300
committerMichael Snoyman <michael@snoyman.com>2012-09-13 17:26:38 +0300
commit6611c400c312cfcaf89a8c90cd06b2f914ba2ad6 (patch)
treecb17721dfe87d9e4c834999b4bf5655ac165e6c6
parentbe69b14602dd75ef00c2dc86d12c4e2a4853e90d (diff)
downloadstylish-haskell-6611c400c312cfcaf89a8c90cd06b2f914ba2ad6.tar.gz
Initial library
-rw-r--r--app/Main.hs (renamed from src/Main.hs)6
-rw-r--r--src/Language/Haskell/Stylish.hs61
-rw-r--r--stylish-haskell.cabal22
3 files changed, 77 insertions, 12 deletions
diff --git a/src/Main.hs b/app/Main.hs
index f880f1d..f97d45d 100644
--- a/src/Main.hs
+++ b/app/Main.hs
@@ -16,11 +16,7 @@ import System.IO.Strict (readFile)
--------------------------------------------------------------------------------
-import Paths_stylish_haskell (version)
-import StylishHaskell
-import StylishHaskell.Config
-import StylishHaskell.Step
-import StylishHaskell.Verbose
+import Language.Haskell.Stylish
--------------------------------------------------------------------------------
diff --git a/src/Language/Haskell/Stylish.hs b/src/Language/Haskell/Stylish.hs
new file mode 100644
index 0000000..ccad070
--- /dev/null
+++ b/src/Language/Haskell/Stylish.hs
@@ -0,0 +1,61 @@
+module Language.Haskell.Stylish
+ ( -- * Run
+ runSteps
+ -- * Steps
+ , imports
+ , languagePragmas
+ , records
+ , tabs
+ , trailingWhitespace
+ , unicodeSyntax
+ -- ** Data types
+ , Imports.Align (..)
+ , LanguagePragmas.Style (..)
+ -- ** Helpers
+ , stepName
+ -- * Config
+ , module StylishHaskell.Config
+ -- * Misc
+ , module StylishHaskell.Verbose
+ , version
+ , Lines
+ , Step
+ ) where
+
+import StylishHaskell
+import StylishHaskell.Config
+import StylishHaskell.Step
+import StylishHaskell.Verbose
+import Paths_stylish_haskell (version)
+
+import qualified StylishHaskell.Step.Imports as Imports
+import qualified StylishHaskell.Step.LanguagePragmas as LanguagePragmas
+import qualified StylishHaskell.Step.Records as Records
+import qualified StylishHaskell.Step.Tabs as Tabs
+import qualified StylishHaskell.Step.TrailingWhitespace as TrailingWhitespace
+import qualified StylishHaskell.Step.UnicodeSyntax as UnicodeSyntax
+
+imports :: Int -- ^ columns
+ -> Imports.Align
+ -> Step
+imports = Imports.step
+
+languagePragmas :: Int -- ^ columns
+ -> LanguagePragmas.Style
+ -> Bool -- ^ remove redundant?
+ -> Step
+languagePragmas = LanguagePragmas.step
+
+records :: Step
+records = Records.step
+
+tabs :: Int -- ^ number of spaces
+ -> Step
+tabs = Tabs.step
+
+trailingWhitespace :: Step
+trailingWhitespace = TrailingWhitespace.step
+
+unicodeSyntax :: Bool -- ^ add language pragma?
+ -> Step
+unicodeSyntax = UnicodeSyntax.step
diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal
index dc84850..88ce3e3 100644
--- a/stylish-haskell.cabal
+++ b/stylish-haskell.cabal
@@ -21,12 +21,11 @@ Description:
Data-files:
.stylish-haskell.yaml
-Executable stylish-haskell
- Ghc-options: -Wall
+Library
+ Exposed-modules: Language.Haskell.Stylish
Hs-source-dirs: src
- Main-is: Main.hs
-
- Other-modules:
+ Ghc-options: -Wall
+ other-modules:
Paths_stylish_haskell
StylishHaskell
StylishHaskell.Block
@@ -47,16 +46,25 @@ Executable stylish-haskell
aeson >= 0.6 && < 0.7,
base >= 4 && < 5,
bytestring >= 0.9 && < 0.10,
- cmdargs >= 0.9 && < 0.11,
containers >= 0.3 && < 0.6,
directory >= 1.1 && < 1.2,
filepath >= 1.1 && < 1.4,
haskell-src-exts >= 1.13 && < 1.14,
mtl >= 2.0 && < 2.2,
- strict >= 0.3 && < 0.4,
syb >= 0.3 && < 0.4,
yaml >= 0.7 && < 0.9
+Executable stylish-haskell
+ Ghc-options: -Wall
+ Hs-source-dirs: app
+ Main-is: Main.hs
+
+ Build-depends:
+ base >= 4 && < 5,
+ cmdargs >= 0.9 && < 0.11,
+ strict >= 0.3 && < 0.4,
+ stylish-haskell
+
Test-suite stylish-haskell-tests
Ghc-options: -Wall
Hs-source-dirs: src tests