Skip to content

Instantly share code, notes, and snippets.

@deepakjois
Created September 20, 2009 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakjois/189900 to your computer and use it in GitHub Desktop.
Save deepakjois/189900 to your computer and use it in GitHub Desktop.
twitter_user :: MVar (Maybe AuthUser)
twitter_user = unsafePerformIO (newMVar Nothing)
setTwitterUser :: IO ()
setTwitterUser = do
putStr "User name: "
u <- getLine
putStr "User password: "
p <- getLine
modifyMVar_ twitter_user (\ _ -> return $ Just (AuthUser u p))
tweet :: String -> IO ()
tweet s = do
r <- readMVar twitter_user
case r of
Nothing -> do
putStrLn "Unable to tweet, no user set - run 'setTwitterUser'" -- "
return ()
Just au -> do
runTM au (update s Nothing)
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment