module Haste.PasteProviders.Pastebin ( Pastebin (Pastebin) ) where import Data.Char (isSpace) import Haste.Post import Haste.Types import Haste.Monad data Pastebin = Pastebin deriving Show instance PasteProvider Pastebin where paste _ text = do resp <- post "http://pastebin.com/pastebin.php" [ "poster" :=> "" , "format" :=> "text" , "code2" :=> text , "expiry" :=> "m" , "remember" :=> "0" , "parent_pid" :=> "" , "paste" :=> "Send" ] return $ case lookup "Location" (headers resp) of Nothing -> error . statusLine $ resp Just loc -> strip loc strip :: String -> String strip = reverse . dropWhile isSpace . reverse . dropWhile isSpace