Permalink
Browse files

added a Haskell type alias and haskell and haskell98 combinators to r…

…un a parser with an appropriate whitespace style to make it easier to test layout
  • Loading branch information...
ekmett committed Sep 11, 2011
1 parent d36dae2 commit 1ece45a1968bd5a04747a7fd1a7068397fb13230
Showing with 24 additions and 1 deletion.
  1. +3 −0 Text/Trifecta/Parser.hs
  2. +18 −0 Text/Trifecta/Parser/Haskell.hs
  3. +1 −0 Text/Trifecta/Parser/Language.hs
  4. +2 −1 trifecta.cabal
View
@@ -19,6 +19,7 @@ module Text.Trifecta.Parser
, module Text.Trifecta.Parser.Result
, module Text.Trifecta.Parser.Language
, module Text.Trifecta.Parser.Layout
+ , module Text.Trifecta.Parser.Haskell
-- * Expressive Diagnostics
-- ** Text.Trifecta.Diagnostic.Rendering.Caret
, caret
@@ -28,6 +29,7 @@ module Text.Trifecta.Parser
, spanned
-- ** Text.Trifecta.Diagnostic.Rendering.Fixit
, fixit
+
) where
import Text.Trifecta.Parser.Prim
@@ -39,6 +41,7 @@ import Text.Trifecta.Parser.Token
import Text.Trifecta.Parser.Result
import Text.Trifecta.Parser.Language
import Text.Trifecta.Parser.Layout
+import Text.Trifecta.Parser.Haskell
import Text.Trifecta.Diagnostic.Rendering.Caret (caret, careted)
import Text.Trifecta.Diagnostic.Rendering.Span (span, spanned)
@@ -0,0 +1,18 @@
+module Text.Trifecta.Parser.Haskell
+ ( Haskell
+ , haskell
+ , haskell98
+ ) where
+
+import Data.Functor
+import Text.Trifecta.Parser.Class
+import Text.Trifecta.Parser.Layout
+import Text.Trifecta.Parser.Language
+
+type Haskell m = Layout (Language m)
+
+haskell :: MonadParser m => Haskell m a -> m a
+haskell p = runLanguage (fst <$> runLayout p defaultLayoutState) haskellLanguageDef
+
+haskell98 :: MonadParser m => Haskell m a -> m a
+haskell98 p = runLanguage (fst <$> runLayout p defaultLayoutState) haskell98LanguageDef
@@ -31,3 +31,4 @@ import Text.Trifecta.Parser.Language.Combinators
import Text.Trifecta.Parser.Language.Def
import Text.Trifecta.Parser.Language.Monad
import Text.Trifecta.Parser.Language.Style
+
View
@@ -1,6 +1,6 @@
name: trifecta
category: Text, Parsing, Diagnostics, Pretty Printer, Logging
-version: 0.43
+version: 0.44
license: BSD3
cabal-version: >= 1.6
license-file: LICENSE
@@ -65,6 +65,7 @@ library
Text.Trifecta.Parser.Combinators
Text.Trifecta.Parser.Expr
Text.Trifecta.Parser.It
+ Text.Trifecta.Parser.Haskell
Text.Trifecta.Parser.Language
Text.Trifecta.Parser.Language.Class
Text.Trifecta.Parser.Language.Combinators

0 comments on commit 1ece45a

Please sign in to comment.