oeis2 1.0.1 → 1.0.2
raw patch · 6 files changed
+62/−73 lines, 6 filesdep ~aesondep ~http-conduitdep ~lensPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, http-conduit, lens
API changes (from Hackage documentation)
Files
- README.md +3/−0
- oeis2.cabal +9/−9
- src/Math/OEIS.hs +1/−0
- src/Math/OEIS/Internal.hs +3/−2
- src/Math/OEIS/Types.hs +43/−44
- test/Spec.hs +3/−18
README.md view
@@ -1,5 +1,8 @@ # oeis2 +[](https://travis-ci.org/23prime/oeis2)++ Haskell interface for [Online Encyclopedia of Integer Sequences](https://oeis.org/); homage to [oeis](http://hackage.haskell.org/package/oeis). ## Difference from [oeis](http://hackage.haskell.org/package/oeis)
oeis2.cabal view
@@ -4,17 +4,17 @@ -- -- see: https://github.com/sol/hpack ----- hash: 34d9968016b6527d432a5693a72564be6591109ce021dc22ece2b13083f75f00+-- hash: 622ea870f9adfbc723003417b655522c3b76680af7570ff1e1e4c2be8ba1ceca name: oeis2-version: 1.0.1+version: 1.0.2 synopsis: Interface for Online Encyclopedia of Integer Sequences (OEIS). description: Release notes are here https://github.com/23prime/oeis2/releases category: Math homepage: https://github.com/23prime/oeis2#readme bug-reports: https://github.com/23prime/oeis2/issues author: Taisuke Hikawa-maintainer: a23b23c23d23e@gmail.com+maintainer: 23.prime.37@gmail.com copyright: 2019 Taisuke Hikawa license: BSD3 license-file: LICENSE@@ -36,11 +36,11 @@ hs-source-dirs: src build-depends:- aeson >=1.3 && <1.5+ aeson >=1.1 && <1.5 , base >=4.7 && <5 , containers >=0.5 && <0.7- , http-conduit >=2.3 && <2.4- , lens >=4.16 && <4.18+ , http-conduit >=2.2 && <2.4+ , lens >=4.15 && <4.18 , lens-aeson >=1.0 && <1.1 , text >=1.2 && <1.3 , vector >=0.12 && <0.13@@ -56,12 +56,12 @@ ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: QuickCheck- , aeson >=1.3 && <1.5+ , aeson >=1.1 && <1.5 , base >=4.7 && <5 , containers >=0.5 && <0.7 , hspec- , http-conduit >=2.3 && <2.4- , lens >=4.16 && <4.18+ , http-conduit >=2.2 && <2.4+ , lens >=4.15 && <4.18 , lens-aeson >=1.0 && <1.1 , oeis2 , text >=1.2 && <1.3
src/Math/OEIS.hs view
@@ -14,6 +14,7 @@ OEISSeq(..) ) where +import Data.Functor import Data.List import Data.Maybe (fromMaybe, listToMaybe) import qualified Data.Vector as V
src/Math/OEIS/Internal.hs view
@@ -8,6 +8,7 @@ import Data.Aeson.Lens import Data.Aeson.Types import Data.Char+import Data.Functor import Data.List import Data.Maybe (fromJust, fromMaybe, isNothing) import qualified Data.Text as T@@ -88,7 +89,7 @@ results = case results' of Nothing -> return [] Just vs' ->- let len = length vs'+ let len = V.length vs' start' = start + 10 diff = case bound of 0 -> len@@ -140,7 +141,7 @@ in case ds of Nothing -> (k, Nothing) _ -> let ts = (\i -> result ^?! key k . nth i . _String) <$> [0..(len - 1)]- len = fromJust $ length <$> ds+ len = fromJust $ V.length <$> ds in case k of "program" -> let prgs = parsePrograms emptyProgram [] ts in (k, Just $ PRGS prgs)
src/Math/OEIS/Types.hs view
@@ -5,34 +5,34 @@ type SeqData = [Integer] type Texts = [T.Text] -data SearchStatus = ID T.Text- | SubSeq SeqData- | Signed T.Text- | Name T.Text- | Comment T.Text- | Ref T.Text- | Link T.Text- | Formula T.Text- | Example T.Text- | Maple T.Text+data SearchStatus = ID T.Text+ | SubSeq SeqData+ | Signed T.Text+ | Name T.Text+ | Comment T.Text+ | Ref T.Text+ | Link T.Text+ | Formula T.Text+ | Example T.Text+ | Maple T.Text | Mathematica T.Text- | Offset T.Text- | Program T.Text- | XRef T.Text- | KeyWord T.Text- | Author T.Text- | Extension T.Text- | Others T.Text+ | Offset T.Text+ | Program T.Text+ | XRef T.Text+ | KeyWord T.Text+ | Author T.Text+ | Extension T.Text+ | Others T.Text deriving (Show, Eq) --data Language = Haskell | PARI | L T.Text deriving (Show, Eq) type Language = T.Text type Program = (Language, [T.Text]) -data Keyword = Base | Bref | Changed | Cofr | Cons | Core | Dead | Dumb | Dupe |- Easy | Eigen | Fini | Frac | Full | Hard | More | Mult |- New | Nice | Nonn | Obsc | Sign | Tabf | Tabl | Uned |- Unkn | Walk | Word | Look | Other+data Keyword = Base | Bref | Changed | Cofr | Cons | Core | Dead | Dumb |+ Dupe | Easy | Eigen | Fini | Frac | Full | Hard | More |+ Mult | New | Nice | Nonn | Obsc | Sign | Tabf | Tabl |+ Uned | Unkn | Walk | Word | Look | Other deriving (Eq, Show, Read) data OEISData = INT Integer@@ -43,27 +43,26 @@ | PRGS [Program] deriving (Show) -data OEISSeq- = OEIS { number :: T.Text,- ids :: Texts,- seqData :: SeqData,- name :: T.Text,- comment :: Texts,- reference :: Texts,- link :: Texts,- formula :: Texts,- example :: Texts,- maple :: Texts,- mathematica :: Texts,- program :: [Program],- xref :: Texts,- keyword :: [Keyword],- offset :: Integer,- author :: T.Text,- ext :: Texts,- references :: Integer,- revision :: Integer,- time :: T.Text,- created :: T.Text- }+data OEISSeq = OEIS { number :: T.Text,+ ids :: Texts,+ seqData :: SeqData,+ name :: T.Text,+ comment :: Texts,+ reference :: Texts,+ link :: Texts,+ formula :: Texts,+ example :: Texts,+ maple :: Texts,+ mathematica :: Texts,+ program :: [Program],+ xref :: Texts,+ keyword :: [Keyword],+ offset :: Integer,+ author :: T.Text,+ ext :: Texts,+ references :: Integer,+ revision :: Integer,+ time :: T.Text,+ created :: T.Text+ } deriving (Show, Eq, Read)
test/Spec.hs view
@@ -2,6 +2,7 @@ import Data.Aeson.Lens import Data.Aeson.Types+import Data.Functor import Data.List import Data.Maybe (fromJust) import qualified Data.Text as T@@ -19,31 +20,15 @@ main :: IO () main = do- withFile "./test/docs/test.json" ReadMode $ \handle1 ->- withFile "./test/docs/result.txt" ReadMode $ \handle2 -> do- testJSON <- T.hGetContents handle1- testResult' <- hGetContents handle2- let testResult = read testResult' :: V.Vector OEISSeq- hspec $ specSearchSeq testJSON testResult hspec specLookupSeq hspec specGetSeqData hspec specExtendSeq -specSearchSeq :: T.Text -> V.Vector OEISSeq -> Spec-specSearchSeq jsn seq = describe "Test for searchSeq" $ do- it "Number of all search results" $- length (searchSeq (SubSeq [1,2,2,3,3,3,4,4,4,4]) 0) `shouldBe`- fromJust (unsafePerformIO $ resultLen (SubSeq [1,2,2,3,3,3,4,4,4,4]))- it "Get some of search results" $- searchSeq (Others jsn) 10 `shouldBe` seq- it "No search results" $- searchSeq (SubSeq [1, 2, 3, 6, 11, 23, 47, 106, 237]) 0 `shouldBe` V.empty- specLookupSeq :: Spec specLookupSeq = describe "Test for lookupSeq" $ do it "Compare lookup by ID with by SubSeq" $ lookupSeq (ID "A000027") `shouldBe` lookupSeq (SubSeq [1, 2, 3, 4, 5, 6, 7])- prop "Compare lookup by ID with by SubSeq -2" $+ modifyMaxSuccess (const 10) $ prop "Compare lookup by ID with by SubSeq -2" $ \x -> let rs = unsafePerformIO $ generate $ resize 5 $ vectorOf x $ choose (1, 10) seq1 = lookupSeq (SubSeq rs)@@ -65,7 +50,7 @@ specExtendSeq :: Spec specExtendSeq = describe "Test for extendSeq" $ do- prop "Extend Seq" $+ modifyMaxSuccess (const 10) $ prop "Extend Seq" $ \x -> let rs = unsafePerformIO $ generate $ resize 5 $ vectorOf x $ choose (1, 10) seq = extendSeq rs