Skip to content

Instantly share code, notes, and snippets.

@warpr warpr/t.hs
Created Sep 1, 2013

Embed
What would you like to do?
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.Exception.Synchronous
import Data.Conduit
import qualified Control.Exception as E
import Network.HTTP.Types.Status
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import qualified Network (withSocketsDo)
import Control.Exception as E
import Control.Monad.Trans
noRedirect :: Request a -> Request a
noRedirect request = request { redirectCount = 0 }
noCheckStatus :: Request a -> Request a
noCheckStatus request = request { checkStatus = \_ _ _ -> Nothing }
resolveURL url = parseUrl url
>>= withManager . httpLbs . noRedirect . noCheckStatus
>>= return
resolvePrefix prefix = do
response <- resolveURL $ "http://prefix.cc/" ++ prefix ++ ".go"
return $ lookup "Location" $ responseHeaders response
main = resolvePrefix "rdfs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.