Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
Created July 11, 2013 09:59
Show Gist options
  • Save JakubOboza/5974175 to your computer and use it in GitHub Desktop.
Save JakubOboza/5974175 to your computer and use it in GitHub Desktop.
{-# 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!!"
@ivanperez-keera
Copy link

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

@JakubOboza
Copy link
Author

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