Skip to content

Instantly share code, notes, and snippets.

@supernullset
Created August 24, 2012 00:35
Show Gist options
  • Save supernullset/3444016 to your computer and use it in GitHub Desktop.
Save supernullset/3444016 to your computer and use it in GitHub Desktop.
Wrapper to connect to my riak instance
{-# LANGUAGE DeriveGeneric, OverloadedStrings #-}
import Network.Riak
import Network.Riak.Connection as C
import Network.Socket as S
import System.IO.Unsafe (unsafePerformIO)
import Data.ByteString.Lazy.Char8 as BSL
import Network.Riak.JSON.Resolvable as RR
import Network.Riak.Types
import Data.Aeson
import GHC.Generics
import Network.Riak.JSON as J
data Tweet = Tweet {
user :: String,
tweet :: String,
tweeted_at :: String
} deriving (Generic, Show)
instance FromJSON Tweet
instance ToJSON Tweet
get_tweet :: Int -> IO (Maybe ([Tweet], VClock))
get_tweet t = do
let client = C.defaultClient
a = C.connect client
conn = unsafePerformIO a
(J.get conn ( BSL.pack ("tweets") :: Bucket) (BSL.pack (show t) :: Key) Quorum) :: IO (Maybe ([Tweet], VClock))
--main = do
-- let client = C.defaultClient
-- a = C.connect client
-- conn = unsafePerformIO a
-- (J.get conn ( BSL.pack ("tweets") :: Bucket) (BSL.pack ("236347359573995520") :: Key) Quorum) :: IO (Maybe ([Tweet], VClock))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment