Created
July 11, 2013 09:59
-
-
Save JakubOboza/5974175 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
{-# LANGUAGE OverloadedStrings #-} | |
import Database.Redis | |
import Network.CGI | |
import qualified Data.ByteString.Char8 as BL | |
setKey conn key value = do | |
runRedis conn $ do | |
set key value | |
getKey conn key = do | |
runRedis conn $ do | |
result <- get key | |
return result | |
getKey' key conn = do | |
runRedis conn $ do | |
result <- get key | |
return result | |
main = do | |
conn <- connect defaultConnectInfo | |
putStrLn "What?" | |
key <- getLine | |
--print key | |
result <- getKey conn (BL.pack key) | |
case result of | |
Right maybe_val -> | |
case maybe_val of | |
Just val -> putStrLn $ "Key value -> " ++ (BL.unpack val) | |
Nothing -> putStrLn "Nothing! Go away!" | |
Left err -> print "No!!" |
getKey' = flip getKey
is evil, flip is evil.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For simplicity:
getKey conn key = runResid conn $ get key
getKey' key conn = runResid conn $ get key
Or even:
getKey conn = runResid conn . get
getKey' = flip getKey