Created
February 15, 2015 03:47
-
-
Save bohde/8cd9f933a33101c93b49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foo where | |
import Control.Applicative | |
import Data.Set (Set) | |
import Data.Map (Map) | |
import qualified Data.Map as M | |
import qualified Data.Set as S | |
get :: String -> IO (Maybe String) | |
get = undefined | |
multiGet :: Set String -> IO (Map String String) | |
multiGet = undefined | |
test :: IO (Maybe String, Maybe String, Maybe String) | |
test = (,,) <$> get "foo" <*> get "bar" <*> get "baz" | |
unbatch :: Map String a -> (Maybe a, Maybe a, Maybe a) | |
unbatch = (,,) <$> M.lookup "foo" <*> M.lookup "bar" <*> M.lookup "baz" | |
fetch :: IO (Map String String) | |
fetch = multiGet $ S.fromList ["foo", "bar", "baz"] | |
testBatch :: IO (Maybe String, Maybe String, Maybe String) | |
testBatch = unbatch <$> fetch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment