-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Interface to the Online Encyclopedia of Integer Sequences (OEIS)
--   
--   Interface to the <a>Online Encyclopedia of Integer Sequences
--   (OEIS)</a>.
@package oeis
@version 0.3.10.1


-- | This module exists just to facilitate testing. <i>Nothing here is part
--   of the OEIS API.</i>
module Math.OEIS.Internal
baseSearchURI :: String
idSearchURI :: String -> String
seqSearchURI :: SequenceData -> String
getOEIS :: (a -> String) -> a -> IO [OEISSequence]
get :: URI -> IO (Maybe String)
readKeyword :: String -> Keyword
capitalize :: String -> String
emptyOEIS :: OEISSequence
addElement :: (Char, String) -> OEISSequence -> OEISSequence
parseOEIS :: String -> [OEISSequence]
parseRawOEIS :: [String] -> [(Char, String)]
parseKeywords :: String -> [Keyword]
csvItems :: String -> [String]
del :: Char -> String -> String
parseItem :: String -> (Char, String)
combineConts :: [String] -> [String]
splitWord :: String -> (String, String)
isItem :: String -> Bool
joinConts :: String -> [String] -> String
trimLeft :: String -> String

module Math.OEIS

-- | Look up a sequence in the OEIS by its catalog number. Generally this
--   would be its A-number, but M-numbers (from the /Encyclopedia of
--   Integer Sequences<i>) and N-numbers (from the </i>Handbook of Integer
--   Sequences/) can be used as well.
--   
--   Note that the result is not in the <a>IO</a> monad, even though the
--   implementation requires looking up information via the Internet. There
--   are no side effects to speak of, and from a practical point of view
--   the function is referentially transparent (OEIS A-numbers could change
--   in theory, but it's extremely unlikely).
--   
--   Examples:
--   
--   <pre>
--   Prelude Math.OEIS&gt; getSequenceByID "A000040"    -- the prime numbers
--   Just [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47...
--   
--   Prelude Math.OEIS&gt; getSequenceByID "nosuch"     -- no such sequence!
--   Nothing
--   </pre>
getSequenceByID :: String -> Maybe SequenceData

-- | Look up a sequence by ID number, returning a data structure containing
--   the entirety of the information the OEIS has on the sequence.
--   
--   The standard disclaimer about not being in the <a>IO</a> monad
--   applies.
--   
--   Examples:
--   
--   <pre>
--   Prelude Math.OEIS&gt; description `fmap` lookupSequenceByID "A000040"
--   Just "The prime numbers."
--   
--   Prelude Math.OEIS&gt; keywords `fmap` lookupSequenceByID "A000105"
--   Just [Nonn,Hard,Nice,Core]
--   </pre>
lookupSequenceByID :: String -> Maybe OEISSequence

-- | Extend a sequence by using it as a lookup to the OEIS, taking the
--   first sequence returned as a result, and using it to augment the
--   original sequence.
--   
--   Note that <tt>xs</tt> is guaranteed to be a prefix of
--   <tt>extendSequence xs</tt>. If the matched OEIS sequence contains any
--   elements prior to those matching <tt>xs</tt>, they will be dropped. In
--   addition, if no matching sequences are found, <tt>xs</tt> will be
--   returned unchanged.
--   
--   The result is not in the <a>IO</a> monad even though the
--   implementation requires looking up information via the Internet. There
--   are no side effects, and practically speaking this function is
--   referentially transparent (technically, results may change from time
--   to time when the OEIS database is updated; this is slightly more
--   likely than the results of <a>getSequenceByID</a> changing, but still
--   unlikely enough to be essentially a non-issue. Again, purists may use
--   <a>extendSequence_IO</a>).
--   
--   Examples:
--   
--   <pre>
--   Prelude Math.OEIS&gt; extendSequence [5,7,11,13,17]
--   [5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71...
--   </pre>
--   
--   <pre>
--   Prelude Math.OEIS&gt; extendSequence [2,4,8,16,32]
--   [2,4,8,16,32,64,128,256,512,1024,2048,4096,8192...
--   </pre>
--   
--   <pre>
--   Prelude Math.OEIS&gt; extendSequence [9,8,7,41,562]   -- nothing matches
--   [9,8,7,41,562]
--   </pre>
extendSequence :: SequenceData -> SequenceData

-- | Find a matching sequence in the OEIS database, returning a data
--   structure containing the entirety of the information the OEIS has on
--   the sequence.
--   
--   The standard disclaimer about not being in the <a>IO</a> monad
--   applies.
lookupSequence :: SequenceData -> Maybe OEISSequence

-- | The same as <a>getSequenceByID</a>, but with a result in the <a>IO</a>
--   monad.
getSequenceByID_IO :: String -> IO (Maybe SequenceData)

-- | The same as <a>lookupSequenceByID</a>, but in the <a>IO</a> monad.
lookupSequenceByID_IO :: String -> IO (Maybe OEISSequence)

-- | The same as <a>extendSequence</a>, but in the <a>IO</a> monad.
extendSequence_IO :: [Integer] -> IO [Integer]

-- | The same as <a>lookupSequence</a>, but in the <a>IO</a> monad.
lookupSequence_IO :: SequenceData -> IO (Maybe OEISSequence)

-- | Look up a sequence in the OEIS using its search function.
searchSequence_IO :: String -> IO (Maybe OEISSequence)

-- | Interpret a string as a OEIS request, and return the results as
--   Strings.
lookupOEIS :: String -> IO [String]

-- | Look up sequences in the OEIS using its search function (returns up to
--   10 results).
searchSequences_IO :: String -> IO [OEISSequence]

-- | Similar to <a>lookupSequence_IO</a>, but return up to 10 results.
lookupSequences_IO :: SequenceData -> IO [OEISSequence]
type SequenceData = [Integer]

-- | Programming language that some code to generate the sequence is
--   written in. The only languages indicated natively by the OEIS database
--   are Mathematica and Maple; any other languages will be listed (usually
--   in parentheses) at the beginning of the actual code snippet.
data Language
Mathematica :: Language
Maple :: Language
Other :: Language

-- | OEIS keywords. For more information on the meaning of each keyword,
--   see <a>http://oeis.org/eishelp2.html#RK</a>.
data Keyword
Base :: Keyword
Bref :: Keyword
Changed :: Keyword
Cofr :: Keyword
Cons :: Keyword
Core :: Keyword
Dead :: Keyword
Dumb :: Keyword
Dupe :: Keyword
Easy :: Keyword
Eigen :: Keyword
Fini :: Keyword
Frac :: Keyword
Full :: Keyword
Hard :: Keyword
More :: Keyword
Mult :: Keyword
New :: Keyword
Nice :: Keyword
Nonn :: Keyword
Obsc :: Keyword
Sign :: Keyword
Tabf :: Keyword
Tabl :: Keyword
Uned :: Keyword
Unkn :: Keyword
Walk :: Keyword
Word :: Keyword

-- | Data structure for storing an OEIS entry. For more information on the
--   various components, see <a>http://oeis.org/eishelp2.html</a>.
data OEISSequence
OEIS :: [String] -> SequenceData -> SequenceData -> String -> [String] -> [String] -> [String] -> [String] -> String -> Int -> Int -> [(Language, String)] -> [String] -> [String] -> [Keyword] -> [String] -> OEISSequence

-- | Catalog number(s), e.g. A000040, N1425. (%I)
[catalogNums] :: OEISSequence -> [String]

-- | The actual sequence data (or absolute values of the sequence data in
--   the case of signed sequences). (%S,T,U)
[sequenceData] :: OEISSequence -> SequenceData

-- | Signed sequence data (empty for sequences with all positive entries).
--   (%V,W,X)
[signedData] :: OEISSequence -> SequenceData

-- | Short description of the sequence. (%N)
[description] :: OEISSequence -> String

-- | List of academic references. (%D)
[references] :: OEISSequence -> [String]

-- | List of links to more information on the web. (%H)
[links] :: OEISSequence -> [String]

-- | Formulas or equations involving the sequence. (%F)
[formulas] :: OEISSequence -> [String]

-- | Cross-references to other sequences. (%Y)
[xrefs] :: OEISSequence -> [String]

-- | Author who input the sequence into the database. (%A)
[author] :: OEISSequence -> String

-- | Subscript/index of the first term. (%O)
[offset] :: OEISSequence -> Int

-- | Index of the first term &gt; 1. (%O)
[firstGT1] :: OEISSequence -> Int

-- | Code that can be used to generate the sequence. (%p,t,o)
[programs] :: OEISSequence -> [(Language, String)]

-- | Corrections, extensions, or edits. (%E)
[extensions] :: OEISSequence -> [String]

-- | Examples. (%e)
[examples] :: OEISSequence -> [String]

-- | Keywords. (%K)
[keywords] :: OEISSequence -> [Keyword]

-- | Comments. (%C)
[comments] :: OEISSequence -> [String]
