Skip to content

Commit

Permalink
Provide Functor & Applicative instances for Partial
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hvr committed Oct 15, 2013
1 parent 9b8eede commit 4021941
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cabal-install/Distribution/Client/Tar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 4021941

@hvr
Copy link
Member Author

@hvr hvr commented on 4021941 Oct 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tibbe: please merge to 1.18 branch

Please sign in to comment.