oeis2 1.0.2 → 1.0.3
raw patch · 5 files changed
+36/−23 lines, 5 filesdep ~lensdep ~lens-aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: lens, lens-aeson
API changes (from Hackage documentation)
+ Math.OEIS.Internal: getIntData :: Value -> Text -> (Text, Maybe OEISData)
+ Math.OEIS.Internal: getTextData :: Value -> Text -> (Text, Maybe OEISData)
+ Math.OEIS.Internal: getTextsData :: Value -> Text -> (Text, Maybe OEISData)
Files
- LICENSE +1/−1
- README.md +6/−3
- oeis2.cabal +7/−7
- src/Math/OEIS/Internal.hs +22/−11
- test/Spec.hs +0/−1
LICENSE view
@@ -1,4 +1,4 @@-Copyright Taisuke Hikawa (c) 2018+Copyright Taisuke Hikawa (c) 2019 All rights reserved.
README.md view
@@ -1,9 +1,12 @@ # oeis2 -[](https://travis-ci.org/23prime/oeis2)-+[](https://travis-ci.org/23prime/oeis2)+[](https://www.haskell.org)+[](https://hackage.haskell.org/package/oeis2)+[](https://www.stackage.org/package/oeis2)+[](https://en.wikipedia.org/wiki/BSD_License) -Haskell interface for [Online Encyclopedia of Integer Sequences](https://oeis.org/); homage to [oeis](http://hackage.haskell.org/package/oeis).+Haskell interface for [Online Encyclopedia of Integer Sequences](https://oeis.org/); homage to [oeis](http://hackage.haskell.org/package/oeis2). ## Difference from [oeis](http://hackage.haskell.org/package/oeis)
oeis2.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 622ea870f9adfbc723003417b655522c3b76680af7570ff1e1e4c2be8ba1ceca+-- hash: 4d6c16b6d6f8d31c5e4f8a743728c45f3a6f160bc1fc5600e38ab8fd6abd3863 name: oeis2-version: 1.0.2+version: 1.0.3 synopsis: Interface for Online Encyclopedia of Integer Sequences (OEIS). description: Release notes are here https://github.com/23prime/oeis2/releases category: Math@@ -40,8 +40,8 @@ , base >=4.7 && <5 , containers >=0.5 && <0.7 , http-conduit >=2.2 && <2.4- , lens >=4.15 && <4.18- , lens-aeson >=1.0 && <1.1+ , lens >=4.15 && <5+ , lens-aeson >=1.0 && <1.2 , text >=1.2 && <1.3 , vector >=0.12 && <0.13 default-language: Haskell2010@@ -61,8 +61,8 @@ , containers >=0.5 && <0.7 , hspec , http-conduit >=2.2 && <2.4- , lens >=4.15 && <4.18- , lens-aeson >=1.0 && <1.1+ , lens >=4.15 && <5+ , lens-aeson >=1.0 && <1.2 , oeis2 , text >=1.2 && <1.3 , vector >=0.12 && <0.13
src/Math/OEIS/Internal.hs view
@@ -114,7 +114,13 @@ -- Get each data in result -- getData :: Value -> T.Text -> (T.Text, Maybe OEISData) getData result k- | k `elem` intKeys+ | k `elem` intKeys = getIntData result k+ | k `elem` textKeys = getTextData result k+ | k `elem` textsKeys = getTextsData result k+ | otherwise = (k, Nothing)++getIntData :: Value -> T.Text -> (T.Text, Maybe OEISData)+getIntData result k = let d = result ^? key k ._Integer in case d of Nothing -> (k, Nothing)@@ -124,7 +130,9 @@ len = T.length d' in (k, Just $ TXT $ 'A' .+ T.replicate (6 - len) "0" +.+ d') _ -> (k, INT <$> d)- | k `elem` textKeys++getTextData :: Value -> T.Text -> (T.Text, Maybe OEISData)+getTextData result k = let d = result ^? key k ._String in case d of Nothing -> (k, Nothing)@@ -136,17 +144,20 @@ "id" -> (k, TXTS . T.splitOn " " <$> d) "offset" -> (k, INT . read . T.unpack . T.take 1 <$> d) _ -> (k, TXT <$> d)- | k `elem` textsKeys++getTextsData :: Value -> T.Text -> (T.Text, Maybe OEISData)+getTextsData result k = let ds = result ^? key k . _Array in case ds of- Nothing -> (k, Nothing)- _ -> let ts = (\i -> result ^?! key k . nth i . _String) <$> [0..(len - 1)]- len = fromJust $ V.length <$> ds- in case k of- "program" -> let prgs = parsePrograms emptyProgram [] ts- in (k, Just $ PRGS prgs)- _ -> (k, Just $ TXTS ts)- | otherwise = (k, Nothing)+ Nothing -> (k, Nothing)+ _ ->+ let ts = (\i -> result ^?! key k . nth i . _String) <$> [0..(len - 1)]+ len = fromJust $ V.length <$> ds+ in case k of+ "program" -> let prgs = parsePrograms emptyProgram [] ts+ in (k, Just $ PRGS prgs)+ _ -> (k, Just $ TXTS ts)+ resultLen :: SearchStatus -> IO (Maybe Int) resultLen ss = do
test/Spec.hs view
@@ -2,7 +2,6 @@ import Data.Aeson.Lens import Data.Aeson.Types-import Data.Functor import Data.List import Data.Maybe (fromJust) import qualified Data.Text as T