Skip to content

Commit

Permalink
Add Semigroup instance for YamlParser
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed Jan 12, 2018
1 parent e834e65 commit 35af541
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Data/Yaml/Parser.hs
Expand Up @@ -18,6 +18,9 @@ import qualified Data.Map as Map
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (Monoid (..))
#endif
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup(..))
#endif
import Data.Text (Text, pack, unpack)
import Data.Text.Encoding (decodeUtf8)
import Data.Text.Read (signed, decimal)
Expand All @@ -36,9 +39,13 @@ instance Applicative YamlParser where
instance Alternative YamlParser where
empty = fail "empty"
(<|>) = mplus
instance Semigroup (YamlParser a) where
(<>) = mplus
instance Monoid (YamlParser a) where
mempty = fail "mempty"
mappend = mplus
#if !MIN_VERSION_base(4,11,0)
mappend = (<>)
#endif
instance Monad YamlParser where
return = pure
YamlParser f >>= g = YamlParser $ \am ->
Expand Down

0 comments on commit 35af541

Please sign in to comment.