]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - tests/WikiParserTest.hs
Resurrection from bitrot
[Rakka.git] / tests / WikiParserTest.hs
index 856707244b527a24356e048bd1c43f0e5211e3a1..d3ee81682c8eb5a21b1ea222779250e0f8a7dc52 100644 (file)
@@ -1,30 +1,32 @@
+{-# LANGUAGE
+    OverloadedStrings
+  , UnicodeSyntax
+  #-}
 module WikiParserTest
     ( testData
     )
     where
-
+import Control.Applicative
 import           Data.Maybe
+import Data.Text (Text)
 import           Network.URI
 import           Rakka.Wiki
 import           Rakka.Wiki.Parser
 import           Test.HUnit
 import           Text.ParserCombinators.Parsec
 
+cmdTypeOf ∷ Alternative f ⇒ Text → f CommandType
+cmdTypeOf "br"   = pure InlineCommandType
+cmdTypeOf "i"    = pure InlineCommandType
+cmdTypeOf "b"    = pure InlineCommandType
+cmdTypeOf "span" = pure InlineCommandType
+cmdTypeOf "div"  = pure BlockCommandType
+cmdTypeOf _      = empty
 
-cmdTypeOf :: String -> Maybe CommandType
-cmdTypeOf "br"   = Just InlineCommandType
-cmdTypeOf "i"    = Just InlineCommandType
-cmdTypeOf "b"    = Just InlineCommandType
-cmdTypeOf "span" = Just InlineCommandType
-cmdTypeOf "div"  = Just BlockCommandType
-cmdTypeOf _      = Nothing
-
-
-parseWiki :: String -> Either String WikiPage
+parseWiki ∷ String → Either String WikiPage
 parseWiki src = case parse (wikiPage cmdTypeOf) "" src of
-                  Left  err  -> Left (show err)
-                  Right page -> Right page
-
+                  Left  err  → Left (show err)
+                  Right page → Right page
 
 testData :: [Test]
 testData = [ (parseWiki ""