-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Handy Operations on Power Series -- -- HOPS is a DSL for power series and integer sequences. @package hops @version 0.7.0 -- | License : BSD-3 module HOPS.Utils.Parse bracket :: ByteString -> ByteString curly :: ByteString -> ByteString paren :: ByteString -> ByteString -- | Parse p enclosed in parenthesis. parens :: Parser a -> Parser a -- | Parse one of the words in the given ByteString. oneOf :: ByteString -> Parser ByteString -- | Parse one or more occurrences of p, separated by an operator. -- Returns a value obtained by a left associative application. chainl1 :: (Monad f, Alternative f) => f a -> f (a -> a -> a) -> f a -- | Run a parser. parse_ :: Parser t -> ByteString -> Maybe t -- | License : BSD-3 -- -- Bare-bones matrix library; just enough to compute determinants. module HOPS.Utils.Matrix -- | A Matrix is represented as a vector of vectors. type Matrix a = Vector (Vector a) -- | Construct a matrix from a list of rows. matrix :: [[a]] -> Matrix a -- | Matrix determinant. It is assumed that the matrix is square. det :: (Eq a, Fractional a) => Matrix a -> a -- | License : BSD-3 module HOPS.Pretty class Pretty a pretty :: Pretty a => a -> ByteString instance HOPS.Pretty.Pretty GHC.Types.Int instance HOPS.Pretty.Pretty GHC.Integer.Type.Integer instance (HOPS.Pretty.Pretty a, GHC.Real.Integral a) => HOPS.Pretty.Pretty (GHC.Real.Ratio a) -- | License : BSD-3 -- -- Command line options for hops. module HOPS.Options -- | Command line options: data Options Options :: String -> Int -> Maybe Int -> Bool -> Bool -> Bool -> [String] -> Options [script] :: Options -> String [prec] :: Options -> Int [tagSeqs] :: Options -> Maybe Int [forAll] :: Options -> Bool [update] :: Options -> Bool [version] :: Options -> Bool [program] :: Options -> [String] -- | Run the command line options parser (above). getOptions :: IO Options -- | License : BSD-3 module HOPS.OEIS -- | A URL is currently just a synonym for String. type URL = String -- | An A-number is the character 'A' followed by a six digit number. Here -- we represent that by an Int newtype ANum ANum :: Int -> ANum [unANum] :: ANum -> Int -- | A sequence of rational numbers. type Sequence = [Rational] packANum :: ANum -> ByteString -- | Parse a list of A-number-sequence pairs. It's purpose is to parse -- lines of the stripped file. A typical line of that file looks -- like this: -- --
--   A000108 ,1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,
--   
parseStripped :: ByteString -> [(ANum, Sequence)] -- | Parse a sequence of Integers. parseIntegerSeq :: ByteString -> Sequence -- | A parser for A-numbers as Ints. aNumInt :: Parser Int -- | A parser for tags (B-numbers) as Ints. tag :: Parser Int instance GHC.Show.Show HOPS.OEIS.ANum instance GHC.Classes.Ord HOPS.OEIS.ANum instance GHC.Classes.Eq HOPS.OEIS.ANum instance Data.Aeson.Types.ToJSON.ToJSON HOPS.OEIS.ANum instance Data.Aeson.Types.FromJSON.FromJSON HOPS.OEIS.ANum -- | License : BSD-3 -- -- Rational numbers extended with two elements representing a finite but -- indeterminate value and divison by zero, respectively. module HOPS.GF.Rat -- | Rationals extended with two elements: data Rat -- | A known rational value. Val :: {-# UNPACK #-} !Rational -> Rat -- | An unknown value. Indet :: Rat -- | Division by zero. DZ :: Rat -- | maybeRational of Val x is Just x, otherwise -- it is Nothing. maybeRational :: Rat -> Maybe Rational -- | maybeInteger of Val x is Just the numerator of -- x if the denominator of x is 1, otherwise it is -- Nothing. maybeInteger :: Rat -> Maybe Integer -- | Like maybeInteger but return Nothing when the integer is -- out of range for an Int. maybeInt :: Rat -> Maybe Int -- | Is the given element a rational? isRational :: Rat -> Bool -- | Is the given element an Integer? isInteger :: Rat -> Bool -- | Is the given element an Int? isInt :: Rat -> Bool -- | If the given value represents a nonnegative integer, then the -- factorial of that integer is returned. If given DZ, return -- DZ. In all other cases return Indet. factorial :: Rat -> Rat binomial :: Int -> Int -> Integer choose :: (Integral a, Num b) => a -> a -> b multinomial :: (Integral b, Fractional a) => [b] -> a instance GHC.Read.Read HOPS.GF.Rat.Rat instance GHC.Show.Show HOPS.GF.Rat.Rat instance GHC.Classes.Ord HOPS.GF.Rat.Rat instance GHC.Classes.Eq HOPS.GF.Rat.Rat instance GHC.Num.Num HOPS.GF.Rat.Rat instance GHC.Real.Fractional HOPS.GF.Rat.Rat instance GHC.Float.Floating HOPS.GF.Rat.Rat instance HOPS.Pretty.Pretty HOPS.GF.Rat.Rat -- | License : BSD-3 -- -- Truncated power series with rational coefficients. -- -- When writing this module I benefited from ideas and inspiration from -- the following sources: -- -- module HOPS.GF.Series -- | A truncated power series is represented as a (dense) vector of -- coefficients. The precision (maximum number of coefficients) is -- statically checked. For instance, adding two series of different -- precision would result in a type error. newtype Series (n :: Nat) Series :: (Vector Rat) -> Series -- | Create a polynomial with the given list of coefficients. E.g. -- --
--   >>> (polynomial (Proxy :: Proxy 4) [1,1])^2
--   series (Proxy :: Proxy 4) [Val (1 % 1),Val (2 % 1),Val (1 % 1),Val (0 % 1)]
--   
polynomial :: KnownNat n => Proxy n -> [Rat] -> Series n -- | Create a power series with the given list of initial coefficients. -- E.g. -- --
--   >>> (series (Proxy :: Proxy 4) [1,1])^2
--   series (Proxy :: Proxy 4) [Val (1 % 1),Val (2 % 1),Indet,Indet]
--   
series :: KnownNat n => Proxy n -> [Rat] -> Series n -- | Create the power series x^k. xpow :: KnownNat n => Int -> Series n -- | Create an empty power series. All its coefficients are Indet. nil :: KnownNat n => Series n -- | A series whose constant term is DZ. infty :: KnownNat n => Series n -- | If f :: Series n, then precision f = n. precision :: Series n -> Int -- | The underlying vector of coefficients. E.g. -- --
--   >>> coeffVector $ polynomial (Proxy :: Proxy 3) [1,2]
--   fromList [Val (1 % 1),Val (2 % 1),Val (0 % 1)]
--   
coeffVector :: Series n -> Vector Rat -- | The list of coefficients of the given series. E.g. -- --
--   >>> coeffList $ series (Proxy :: Proxy 3) [9]
--   [Val (9 % 1),Indet,Indet]
--   
coeffList :: Series n -> [Rat] -- | Constant term of the given series. constant :: Series n -> Rat -- | The first nonzero coefficient when read from smaller to larger powers -- of x. If no such coefficient exists then return 0. leadingCoeff :: Series n -> Rat -- | The longest initial segment of coefficients that are rational (i.e. -- not Indet or DZ). rationalPrefix :: Series n -> [Rational] -- | The longest initial segment of coefficients that are integral integerPrefix :: Series n -> [Integer] -- | The longest initial segment of coefficients that are Ints intPrefix :: Series n -> [Int] -- | Evaluate the polynomial p at x using Horner's -- method. -- --
--   >>> let x = polynomial (Proxy :: Proxy 5) [0,1]
--   
--   >>> eval (1-x+x^2) 2
--   Val (3 % 1)
--   
eval :: Series n -> Rat -> Rat -- | Coefficient wise multiplication of two power series. Also called the -- Hadamard product. (.*) :: Series n -> Series n -> Series n -- | Coefficient wise division of two power series. (./) :: Series n -> Series n -> Series n -- | The power operator for Rats. E.g. -- --
--   >>> (1/4) !^! (3/2)
--   Val (1 % 8)
--   
(!^!) :: Rat -> Rat -> Rat -- | A power series raised to a rational power. -- --
--   >>> series (Proxy :: Proxy 4) [1,2,3,4] ^! (1/2)
--   series (Proxy :: Proxy 4) [Val (1 % 1),Val (1 % 1),Val (1 % 1),Val (1 % 1)]
--   
(^!) :: KnownNat n => Series n -> Rat -> Series n -- | Select certain coefficients of the first series, based on indices from -- the second series, returning the selection as a series. Elements of -- the second series that are not nonnegative integers or not less than -- the precision are ignored; trailing zeros are also ignored. (?) :: KnownNat n => Series n -> Series n -> Series n infixr 7 ? -- | The composition of two power series. -- --
--   >>> let x = polynomial (Proxy :: Proxy 4) [0,1]
--   
--   >>> (1/(1-x)) `o` (2*x)
--   series (Proxy :: Proxy 4) [Val (1 % 1),Val (2 % 1),Val (4 % 1),Val (8 % 1)]
--   
o :: Series n -> Series n -> Series n infixr 7 `o` blackDiamond :: Series n -> Series n -> Series n -- | The (formal) derivative of a power series. derivative :: Series n -> Series n -- | The (formal) integral of a power series. integral :: Series n -> Series n -- | Reversion (compositional inverse) of a power series. Unless the -- constant of the power series is zero the result is indeterminate. -- --
--   >>> revert $ series (Proxy :: Proxy 4) [0,1,2,3]
--   series (Proxy :: Proxy 4) [Val (0 % 1),Val (1 % 1),Val ((-2) % 1),Val (5 % 1)]
--   
-- --
--   >>> revert $ series (Proxy :: Proxy 4) [1,1,1,1]
--   series (Proxy :: Proxy 4) [Indet,Indet,Indet,Indet]
--   
revert :: Series n -> Series n -- | The secant function: sec f = 1 / cos f sec :: KnownNat n => Series n -> Series n -- | The factorial of a constant power series. If the the power series -- isn't constant, then the result is indeterminate (represented using -- Indet). -- --
--   >>> fac (polynomial (Proxy :: Proxy 4) [3])
--   series (Proxy :: Proxy 4) [Val (6 % 1),Val (0 % 1),Val (0 % 1),Val (0 % 1)]
--   
fac :: KnownNat n => Series n -> Series n -- | Construct a series that has coefficient 1 for each term whose power is -- some coefficient of the input series and 0 elsewhere. Elements of the -- input series that are not nonnegative integers or not less than the -- precision are ignored; trailing zeros are also ignored. -- --
--   >>> rseq $ series (Proxy :: Proxy 4) [1,3]
--   series (Proxy :: Proxy 4) [Val (0 % 1),Val (1 % 1),Val (0 % 1),Val (1 % 1)]
--   
rseq :: Series n -> Series n -- | The "complement" of rseq, i.e., the series generated by -- rseq, with 0 replaced by 1, and 1 replaced by 0. rseq' :: Series n -> Series n instance GHC.Show.Show (HOPS.GF.Series.Series n) instance GHC.Classes.Eq (HOPS.GF.Series.Series n) instance GHC.TypeLits.KnownNat n => GHC.Num.Num (HOPS.GF.Series.Series n) instance GHC.TypeLits.KnownNat n => GHC.Real.Fractional (HOPS.GF.Series.Series n) instance GHC.TypeLits.KnownNat n => GHC.Float.Floating (HOPS.GF.Series.Series n) instance HOPS.Pretty.Pretty (HOPS.GF.Series.Series n) -- | License : BSD-3 module HOPS.GF.Transform -- | A Transform takes zero or more Series to another -- Series. data Transform n Transform1 :: (Series n -> Series n) -> Transform n TransformAny :: ([Series n] -> Series n) -> Transform n TransformK :: Int -> ([Series n] -> Series n) -> Transform n -- | Lookup a transform by name. lookupTransform :: KnownNat n => ByteString -> Maybe (Transform n) -- | The list of all names of transforms. transforms :: [ByteString] -- | License : BSD-3 module HOPS.GF.Const -- | An expression for a constant. Supports addition, subtraction, -- multiplication, division, exponentials and factorials. type Expr = Expr0 data Expr0 EAdd :: Expr0 -> Expr0 -> Expr0 ESub :: Expr0 -> Expr0 -> Expr0 Expr1 :: Expr1 -> Expr0 data Expr1 EMul :: Expr1 -> Expr1 -> Expr1 EDiv :: Expr1 -> Expr1 -> Expr1 Expr2 :: Expr2 -> Expr1 data Expr2 ENeg :: Expr2 -> Expr2 EPos :: Expr2 -> Expr2 EFac :: Expr3 -> Expr2 EPow :: Expr3 -> Expr3 -> Expr2 Expr3 :: Expr3 -> Expr2 data Expr3 ELit :: Integer -> Expr3 EN :: Expr3 EDZ :: Expr3 EIndet :: Expr3 Expr0 :: Expr0 -> Expr3 data Core App1 :: Fun1 -> Core -> Core App2 :: Fun2 -> Core -> Core -> Core Binom :: Int -> Core Lit :: Rat -> Core N :: Core indet :: Core zero :: Core core :: Expr -> Core simplify :: Core -> Core isConstant :: Expr -> Bool -- | The value of the given expression. evalExpr :: Int -> Expr -> Rat -- | The value of the given (core) expression. evalCore :: Int -> Core -> Rat -- | Parser for an Expr. expr :: Parser Expr instance GHC.Classes.Ord HOPS.GF.Const.Core instance GHC.Classes.Eq HOPS.GF.Const.Core instance GHC.Show.Show HOPS.GF.Const.Core instance GHC.Classes.Ord HOPS.GF.Const.Fun2 instance GHC.Classes.Eq HOPS.GF.Const.Fun2 instance GHC.Show.Show HOPS.GF.Const.Fun2 instance GHC.Classes.Ord HOPS.GF.Const.Fun1 instance GHC.Classes.Eq HOPS.GF.Const.Fun1 instance GHC.Show.Show HOPS.GF.Const.Fun1 instance GHC.Classes.Eq HOPS.GF.Const.Expr2 instance GHC.Show.Show HOPS.GF.Const.Expr2 instance GHC.Classes.Eq HOPS.GF.Const.Expr1 instance GHC.Show.Show HOPS.GF.Const.Expr1 instance GHC.Classes.Eq HOPS.GF.Const.Expr0 instance GHC.Show.Show HOPS.GF.Const.Expr0 instance GHC.Classes.Eq HOPS.GF.Const.Expr3 instance GHC.Show.Show HOPS.GF.Const.Expr3 instance HOPS.Pretty.Pretty HOPS.GF.Const.Fun1 instance HOPS.Pretty.Pretty HOPS.GF.Const.Fun2 instance HOPS.Pretty.Pretty HOPS.GF.Const.Core instance GHC.Num.Num HOPS.GF.Const.Core instance HOPS.Pretty.Pretty HOPS.GF.Const.Expr0 instance HOPS.Pretty.Pretty HOPS.GF.Const.Expr1 instance HOPS.Pretty.Pretty HOPS.GF.Const.Expr2 instance HOPS.Pretty.Pretty HOPS.GF.Const.Expr3 -- | License : BSD-3 -- -- Expressions defining sequences of rational numbers. module HOPS.GF.Rats data Term Ellipsis :: Term Constant :: Expr -> Term Fun :: Expr -> Term -- | An expression defining a sequence. type Rats = ([Expr], Term, SequenceType) type Core = ([Core], Core, SequenceType) data SequenceType Poly :: SequenceType Ser :: SequenceType core :: Rats -> Core evalCore :: KnownNat n => Core -> Series n -- | Parser for Rats. rats :: Parser Rats instance GHC.Classes.Ord HOPS.GF.Rats.SequenceType instance GHC.Classes.Eq HOPS.GF.Rats.SequenceType instance GHC.Show.Show HOPS.GF.Rats.SequenceType instance GHC.Classes.Eq HOPS.GF.Rats.Term instance GHC.Show.Show HOPS.GF.Rats.Term instance HOPS.Pretty.Pretty HOPS.GF.Rats.Term instance HOPS.Pretty.Pretty HOPS.GF.Rats.Rats instance HOPS.Pretty.Pretty HOPS.GF.Rats.Core -- | License : BSD-3 module HOPS.GF data Expr0 EAdd :: Expr0 -> Expr0 -> Expr0 ESub :: Expr0 -> Expr0 -> Expr0 Expr1 :: Expr1 -> Expr0 data Expr1 EMul :: Expr1 -> Expr1 -> Expr1 EDiv :: Expr1 -> Expr1 -> Expr1 EBDP :: Expr1 -> Expr1 -> Expr1 EPtMul :: Expr1 -> Expr1 -> Expr1 EPtDiv :: Expr1 -> Expr1 -> Expr1 Expr2 :: Expr2 -> Expr1 data Expr2 ENeg :: Expr2 -> Expr2 EPos :: Expr2 -> Expr2 EFac :: Expr3 -> Expr2 EPow :: Expr3 -> Expr3 -> Expr2 EComp :: Expr3 -> Expr3 -> Expr2 ECoef :: Expr3 -> Expr3 -> Expr2 Expr3 :: Expr3 -> Expr2 data Expr3 EX :: Expr3 EDZ :: Expr3 EIndet :: Expr3 EA :: Int -> Expr3 ETag :: Int -> Expr3 EVar :: Name -> Expr3 ELit :: Integer -> Expr3 EApp :: Name -> [Expr0] -> Expr3 ERats :: Rats -> Expr3 Expr0 :: Expr0 -> Expr3 data Cmd Expr :: Expr0 -> Cmd Asgmt :: Name -> Expr0 -> Cmd -- | A compact ByteString representation of a Prg. newtype PackedPrg PPrg :: ByteString -> PackedPrg -- | A program is a list of commands, where a command is either a power -- series expression or an assignment. newtype Prg Prg :: [Cmd] -> Prg [commands] :: Prg -> [Cmd] type Name = ByteString nameSupply :: [Name] -- | A compact representation of a Prg as a wrapped -- ByteString. packPrg :: Prg -> PackedPrg -- | The list of variables in a program. vars :: CorePrg -> [Name] -- | The list of A-numbers in a program. anums :: CorePrg -> [Int] -- | Insert a variable binding into the given environment. insertVar :: ByteString -> Series n -> Env n -> Env n aNumPrg :: Int -> Prg tagPrg :: Int -> Prg data Core App :: !Name -> ![Core] -> Core X :: Core A :: {-# UNPACK #-} !Int -> Core Tag :: {-# UNPACK #-} !Int -> Core Var :: {-# UNPACK #-} !Name -> Core Lit :: !Rat -> Core Rats :: !Core -> Core Let :: {-# UNPACK #-} !Name -> !Core -> Core type CorePrg = [Core] core :: Prg -> CorePrg -- | An environment holds a mapping from A-numbers to series, and a mapping -- from names to series (assignments). data Env (n :: Nat) Env :: Vector (Series n) -> Map Name (Series n) -> Env [aNumEnv] :: Env -> Vector (Series n) [varEnv] :: Env -> Map Name (Series n) emptyEnv :: Env n -- | Evaluate a program in a given environment. E.g. -- --
--   evalCorePrg (emptyEnv :: Env 4) [ log (1/(1-X)) ]
--   
-- -- series (Proxy :: Proxy 4) [Val (0 % 1),Val (1 % 1),Val (1 % 2),Val (1 -- % 3)] evalCorePrg :: KnownNat n => Env n -> CorePrg -> Series n -- | Evaluate a list of programs in a given environment. evalCorePrgs :: KnownNat n => Env n -> [CorePrg] -> [Series n] -- | Parse a program. parsePrg :: ByteString -> Maybe Prg -- | Parse a program and possibly fail with an error. parsePrgErr :: ByteString -> Prg instance GHC.Classes.Eq HOPS.GF.Prg instance GHC.Show.Show HOPS.GF.Prg instance GHC.Classes.Ord HOPS.GF.Core instance GHC.Classes.Eq HOPS.GF.Core instance GHC.Show.Show HOPS.GF.Core instance GHC.Classes.Eq HOPS.GF.Cmd instance GHC.Show.Show HOPS.GF.Cmd instance GHC.Classes.Eq HOPS.GF.Expr2 instance GHC.Show.Show HOPS.GF.Expr2 instance GHC.Classes.Eq HOPS.GF.Expr1 instance GHC.Show.Show HOPS.GF.Expr1 instance GHC.Classes.Eq HOPS.GF.Expr0 instance GHC.Show.Show HOPS.GF.Expr0 instance GHC.Classes.Eq HOPS.GF.Expr3 instance GHC.Show.Show HOPS.GF.Expr3 instance GHC.Show.Show HOPS.GF.PackedPrg instance GHC.Classes.Eq HOPS.GF.PackedPrg instance Data.Aeson.Types.ToJSON.ToJSON HOPS.GF.PackedPrg instance Data.Aeson.Types.FromJSON.FromJSON HOPS.GF.PackedPrg instance HOPS.Pretty.Pretty HOPS.GF.Core instance GHC.Num.Num HOPS.GF.Core instance GHC.Real.Fractional HOPS.GF.Core instance GHC.Float.Floating HOPS.GF.Core instance Data.Aeson.Types.ToJSON.ToJSON HOPS.GF.Prg instance Data.Aeson.Types.FromJSON.FromJSON HOPS.GF.Prg instance GHC.Base.Monoid HOPS.GF.Prg instance HOPS.Pretty.Pretty HOPS.GF.Expr0 instance HOPS.Pretty.Pretty HOPS.GF.Expr1 instance HOPS.Pretty.Pretty HOPS.GF.Expr2 instance HOPS.Pretty.Pretty HOPS.GF.Expr3 instance HOPS.Pretty.Pretty HOPS.GF.Cmd instance HOPS.Pretty.Pretty HOPS.GF.Prg -- | License : BSD-3 module HOPS.Entry -- | A sequence of rational numbers. type Sequence = [Rational] -- | An entry consists of a program together with a list of rational -- numbers. data Entry Entry :: Prg -> Sequence -> [PackedPrg] -> Entry [getPrg] :: Entry -> Prg [getSeq] :: Entry -> Sequence [getTrail] :: Entry -> [PackedPrg] instance GHC.Show.Show HOPS.Entry.Entry instance GHC.Classes.Eq HOPS.Entry.Entry instance Data.Aeson.Types.ToJSON.ToJSON HOPS.Entry.Entry instance Data.Aeson.Types.FromJSON.FromJSON HOPS.Entry.Entry -- | License : BSD-3 module HOPS.Download -- | 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 () -- | License : BSD-3 -- -- Constants determined at runtime such as the home directory. module HOPS.Config -- | A data type holding "constants" determined at runtime. data Config Config :: FilePath -> FilePath -> FilePath -> Config -- | The home directory [home] :: Config -> FilePath -- | Path to the '.hops' directory. [hopsDir] :: Config -> FilePath -- | Path to stripped file. [seqDBPath] :: Config -> FilePath -- | Get configuration. getConfig :: IO Config -- | License : BSD-3 module HOPS.DB -- | A data base (DB) is just a wrapped ByteString. newtype DB DB :: ByteString -> DB [unDB] :: DB -> ByteString -- | Read the sequence DB (derived from "stripped.gz"). readSeqDB :: Config -> IO DB -- | Create a vector that at index n contains the sequence with -- A-number n. readANumDB :: KnownNat n => Config -> IO (Vector (Series n)) -- | An empty A-number database emptyANumDB :: Vector (Series n) instance GHC.Show.Show HOPS.DB.DB