sloane 4.1.0 → 4.1.2
raw patch · 5 files changed
+20/−62 lines, 5 filesdep +resourcet
Dependencies added: resourcet
Files
- README.md +3/−49
- Sloane/Download.hs +12/−9
- sloane.1 +1/−1
- sloane.cabal +3/−2
- sloane.hs +1/−1
README.md view
@@ -1,51 +1,5 @@ # sloane [](https://travis-ci.org/akc/sloane) -A command line interface to the-[On-Line Encyclopedia of Integer Sequences](http://oeis.org).----## Install--The easiest way to get started is to download a prebuilt binary. Such-binaries can be found on the-[releases page](https://github.com/akc/sloane/releases).-The binaries are statically linked and should work on any Linux system.--Alternative ways of installing `sloane` include-using the [nix](https://nixos.org/nix/) package manager:--```-$ nix-env -f "<nixpkgs>" -iA haskellPackages.sloane-```--Or using [cabal](https://www.haskell.org/cabal/):--```-$ cabal install sloane-```--## Usage--See the [man page](https://github.com/akc/sloane/blob/master/sloane.md).--## Issues--Have you found a bug? Want to contribute to `sloane`? Please open an issue-at <https://github.com/akc/sloane/issues>.--## How to cite--```-@misc{sloane,- author = "Anders Claesson",- title = "sloane: A command line interface to the OEIS",- year = 2015,- howpublished = "\url{http://akc.is/sloane}"-}-```--## License--BSD-3: see the-[LICENSE](https://github.com/akc/sloane/blob/master/LICENSE) file.+A command line interface to the On-Line Encyclopedia of Integer Sequences.+For installation and usage instructions please visit the `sloane` website at+<http://akc.is/sloane>.
Sloane/Download.hs view
@@ -16,6 +16,7 @@ import Network.HTTP.Conduit hiding (Proxy) import Network.HTTP.Types (hContentLength) import Control.Monad.IO.Class (liftIO)+import Control.Monad.Trans.Resource (runResourceT) #if __GLASGOW_HASKELL__ < 710 import Control.Applicative #endif@@ -27,19 +28,21 @@ -- string). requestPage :: URL -> [(ByteString, ByteString)] -> IO ByteString requestPage url kvs = do- req <- setQueryString [(k, Just v) | (k,v) <- kvs] <$> parseUrl url- res <- withManager (httpLbs req)- return $ BL.toStrict (responseBody res)+ req <- liftIO $ setQueryString [(k, Just v) | (k,v) <- kvs] <$> parseUrl url+ man <- newManager tlsManagerSettings+ BL.toStrict . responseBody <$> httpLbs req man -- | Download a file at a given URL showing a progress indicator at the -- given column, and save it at a specified path. download :: Int -> URL -> FilePath -> IO ()-download col url fpath = withManager $ \manager -> do- req <- parseUrl url- res <- http req manager- let Just cl = lookup hContentLength (responseHeaders res)- let n = read (B.unpack cl) :: Int- responseBody res $$+- progress n 0 =$ ungzip =$ CB.sinkFile fpath+download col url fpath = do+ req <- liftIO $ parseUrl url+ man <- newManager tlsManagerSettings+ runResourceT $ do+ response <- http req man+ let Just cl = lookup hContentLength (responseHeaders response)+ let n = read (B.unpack cl) :: Int+ responseBody response $$+- progress n 0 =$ ungzip =$ CB.sinkFile fpath where progress total acc = await >>= maybe (return ()) (\chunk -> do let acc' = acc + B.length chunk
sloane.1 view
@@ -1,4 +1,4 @@-.TH "SLOANE" "1" "4 Sep 2015" "User Manual" "Version 4.1.0"+.TH "SLOANE" "1" "4 Sep 2015" "User Manual" "Version 4.1.1" .SH NAME .PP sloane \- lookup integer sequences, OEIS A\-numbers, etc.
sloane.cabal view
@@ -1,5 +1,5 @@ Name: sloane-Version: 4.1.0+Version: 4.1.2 Synopsis: A command line interface to Sloane's OEIS. Description: A command line interface to Sloane's On-Line Encyclopedia of@@ -51,4 +51,5 @@ stringsearch >=0.3, terminal-size >=0.2, text >=0.11,- transformers >=0.3+ transformers >=0.3,+ resourcet >=1.1
sloane.hs view
@@ -36,7 +36,7 @@ import Sloane.Bloom import Sloane.DB -nameVer = "sloane 4.1.0" :: String+nameVer = "sloane 4.1.2" :: String oeisURL = "https://oeis.org/search" :: URL strpdURL = "https://oeis.org/stripped.gz" :: URL namesURL = "https://oeis.org/names.gz" :: URL