Commit 40219410 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Provide Functor & Applicative instances for Partial

This follows the advice from

 http://www.haskell.org/haskellwiki/Functor-Applicative-Monad_Proposal#Missing_superclasses

and silences the single compile warning currently occuring with GHC HEAD.
parent 9b8eede5
......@@ -71,7 +71,8 @@ import Data.Int (Int64)
import Data.Bits (Bits, shiftL, testBit)
import Data.List (foldl')
import Numeric (readOct, showOct)
import Control.Monad (MonadPlus(mplus), when)
import Control.Applicative (Applicative(..))
import Control.Monad (MonadPlus(mplus), when, ap, liftM)
import qualified Data.Map as Map
import qualified Data.ByteString.Lazy as BS
import qualified Data.ByteString.Lazy.Char8 as BS.Char8
......@@ -676,6 +677,13 @@ partial :: Partial a -> Either String a
partial (Error msg) = Left msg
partial (Ok x) = Right x
instance Functor Partial where
fmap = liftM
instance Applicative Partial where
pure = return
(<*>) = ap
instance Monad Partial where
return = Ok
Error m >>= _ = Error m
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment