-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Automatic inductive functional programmer by systematic search -- -- MagicHaskeller is an inductive functional programming system for -- Haskell. This package contains the MagicHaskeller library, which can -- be used within GHCi or as an API for inductive program synthesis. It -- also contains the MagicHaskeller executable that is a standalone -- synthesis program which can be used interactively or as a backend -- server, and the MagicHaskeller.cgi executable that is a CGI frontend -- for providing the Web interface. @package MagicHaskeller @version 0.9.6.7 module MagicHaskeller.PolyDynamic data Dynamic Dynamic :: Type -> (forall a. a) -> Exp -> Dynamic [dynType] :: Dynamic -> Type [unsafeFromDyn] :: Dynamic -> forall a. a [dynExp] :: Dynamic -> Exp fromDyn :: Typeable a => TyConLib -> Dynamic -> a -> a fromDynamic :: MonadPlus m => Type -> Dynamic -> m a dynApply :: Dynamic -> Dynamic -> Maybe Dynamic dynApp :: Dynamic -> Dynamic -> Dynamic infixl 9 `dynApp` dynAppErr :: String -> Dynamic -> Dynamic -> Dynamic unsafeToDyn :: TyConLib -> Type -> a -> Exp -> Dynamic aLittleSafeFromDyn :: Type -> Dynamic -> a fromPD :: a -> a dynamic :: ExpQ -> ExpQ -> ExpQ dynamicH :: ExpQ -> Name -> TypeQ -> ExpQ instance GHC.Show.Show MagicHaskeller.PolyDynamic.Dynamic module MagicHaskeller.GetTime batchWrite :: FilePath -> [IO a] -> IO () batchRun :: [IO a] -> IO [Integer] time :: IO a -> IO (a, Integer) showZero :: [Char] -> [Char] showCPUTime :: Integer -> String lenPrec :: Int module MagicHaskeller.FastRatio data Ratio a (:%) :: !Integer -> !Integer -> Ratio a type Rational = Ratio Integer (%) :: Integral a => a -> a -> Ratio a numerator :: Integral a => Ratio a -> a denominator :: Integral a => Ratio a -> a notANumber :: Ratio a reduce :: Integer -> Integer -> Ratio a choose :: Ratio a -> Ratio a instance GHC.Classes.Ord (MagicHaskeller.FastRatio.Ratio a) instance GHC.Classes.Eq (MagicHaskeller.FastRatio.Ratio a) instance GHC.Real.Integral a => GHC.Num.Num (MagicHaskeller.FastRatio.Ratio a) instance GHC.Real.Integral a => GHC.Real.Fractional (MagicHaskeller.FastRatio.Ratio a) instance GHC.Real.Integral a => GHC.Real.RealFrac (MagicHaskeller.FastRatio.Ratio a) instance (GHC.Show.Show a, GHC.Real.Integral a) => GHC.Show.Show (MagicHaskeller.FastRatio.Ratio a) instance GHC.Real.Integral a => GHC.Real.Real (MagicHaskeller.FastRatio.Ratio a) instance GHC.Real.Integral a => GHC.Enum.Enum (MagicHaskeller.FastRatio.Ratio a) module MagicHaskeller.CoreLang type Var = Int16 data CoreExpr S :: CoreExpr K :: CoreExpr I :: CoreExpr B :: CoreExpr C :: CoreExpr S' :: CoreExpr B' :: CoreExpr C' :: CoreExpr Y :: CoreExpr Lambda :: CoreExpr -> CoreExpr X :: {-# UNPACK #-} !Int8 -> CoreExpr FunLambda :: CoreExpr -> CoreExpr FunX :: Int8 -> CoreExpr Tuple :: {-# UNPACK #-} !Int8 -> CoreExpr Primitive :: {-# UNPACK #-} !Var -> CoreExpr [primId] :: CoreExpr -> {-# UNPACK #-} !Var PrimCon :: {-# UNPACK #-} !Var -> CoreExpr [primId] :: CoreExpr -> {-# UNPACK #-} !Var Context :: Dictionary -> CoreExpr (:$) :: CoreExpr -> CoreExpr -> CoreExpr Case :: CoreExpr -> [(Var, Int8, CoreExpr)] -> CoreExpr Fix :: CoreExpr -> Int8 -> [Int8] -> CoreExpr VarName :: String -> CoreExpr newtype Dictionary Dict :: Dynamic -> Dictionary [undict] :: Dictionary -> Dynamic arityCE :: CoreExpr -> Int isAbsent :: Int -> CoreExpr -> Bool isa :: Integer -> CoreExpr -> Integer type VarLib = Array Var Dynamic type VarPriorityLib = Array Var Int actualVarName :: String -> Exp stripByd_ :: [Char] -> [Char] headIsX :: CoreExpr -> Bool isAPrimitiveCombinator :: CoreExpr -> Bool removeAbsents :: CoreExpr -> CoreExpr adjustXs :: (Num a, Bits a) => a -> Int8 -> CoreExpr -> CoreExpr unboundXs :: (Num a, Bits a) => Int8 -> CoreExpr -> a subexprs :: CoreExpr -> [CoreExpr] sub :: Integral i => i -> CoreExpr -> [CoreExpr] branches :: CoreExpr -> [CoreExpr] bra :: Integral i => i -> CoreExpr -> [CoreExpr] -- | parentsOfLeaves collects branch nodes whose children are leaf -- nodes. This can be used for incremental learning. parentsOfLeaves :: CoreExpr -> [CoreExpr] pol :: Integral i => i -> CoreExpr -> [CoreExpr] args :: CoreExpr -> [CoreExpr] isALeaf :: CoreExpr -> Bool ceToPriority :: VarPriorityLib -> CoreExpr -> Int exprToTHExp :: VarLib -> CoreExpr -> Exp exprToTHExpLite :: VarLib -> CoreExpr -> Exp exprToTHExp' :: Bool -> Array Var Dynamic -> CoreExpr -> Exp funOccursIn :: Int8 -> CoreExpr -> Bool lightBeta :: CoreExpr -> CoreExpr replace :: Int8 -> Int8 -> CoreExpr -> CoreExpr liftFun :: Int8 -> CoreExpr -> CoreExpr nlift :: Int8 -> Int8 -> CoreExpr -> CoreExpr nliftInt :: Int8 -> Int8 -> Int8 -> Int8 napply :: Integral i => i -> (a -> a) -> a -> a type Primitive = (HValue, Exp, Type) newtype HValue HV :: (forall a. a) -> HValue primitivesToTCL :: [Primitive] -> TyConLib primitivesToVL :: TyConLib -> [Primitive] -> VarLib -- | dynamicsToVL is useful for incremental learning. dynamicsToVL :: [Dynamic] -> VarLib prioritiesToVPL :: [Int] -> VarPriorityLib listToArray :: (Integral i, Ix i) => [a] -> Array i a primitiveToDynamic :: TyConLib -> Primitive -> Dynamic -- | defaultVarLib can be used as a VarLib for testing and -- debugging. Currently this is used only by the analytical synthesizer. defaultVarLib :: VarLib lenDefaultPrimitives :: Integer -- | defaultPrimitives is the set of primitives that we want to -- make sure to appear in VarLib but may not appear in the primitive set -- with which to synthesize. In other words, it is the set of primitives -- we want to make sure to assign IDs to. defaultPrimitives :: [Dynamic] instance GHC.Classes.Ord MagicHaskeller.CoreLang.CoreExpr instance GHC.Show.Show MagicHaskeller.CoreLang.CoreExpr instance GHC.Classes.Eq MagicHaskeller.CoreLang.CoreExpr instance GHC.Show.Show MagicHaskeller.CoreLang.Dictionary instance GHC.Classes.Ord MagicHaskeller.CoreLang.Dictionary instance GHC.Classes.Eq MagicHaskeller.CoreLang.Dictionary instance GHC.Read.Read Language.Haskell.TH.Syntax.Exp module MagicHaskeller.ExecuteAPI610 pathToGHC :: FilePath loadObj :: [String] -> IO (VarLib -> CoreExpr -> Dynamic) prepareAPI :: [FilePath] -> [FilePath] -> IO HscEnv packageNameToFlag :: String -> PackageFlag unsafeExecuteAPI :: HscEnv -> VarLib -> CoreExpr -> Dynamic executeAPI :: HscEnv -> VarLib -> CoreExpr -> IO a executeTHExp :: HscEnv -> Exp -> IO a compileCoreExpr :: HscEnv -> Exp -> IO CoreExpr unwrapCore :: HscEnv -> CoreExpr -> IO a ce2b :: HscEnv -> CoreExpr -> IO UnlinkedBCO runCoreExpr :: HscEnv -> CoreExpr -> IO a runPrepedCoreExpr :: HscEnv -> CoreExpr -> IO a stmtToCore :: HscEnv -> GhciLStmt RdrName -> IO (Maybe ([Id], CoreExpr)) perror :: DynFlags -> (Bag ErrMsg, Bag ErrMsg) -> IO (Maybe a) thExpToStmt :: HscEnv -> Exp -> Located (StmtLR RdrName RdrName body) wrapLHsExpr :: LHsExpr RdrName -> Located (StmtLR RdrName RdrName body) thExpToLHsExpr :: HscEnv -> Exp -> LHsExpr RdrName compileExprHscMain :: HscEnv -> CoreExpr -> IO HValue repeatN :: Int -> (a1 -> a) -> a1 -> a repeatIO :: Monad f => Int -> f b -> f b force :: [a] -> a instance GHC.Classes.Eq (CoreSyn.Expr a) module Control.Monad.Search.Combinatorial newtype Matrix a Mx :: Stream (Bag a) -> Matrix a [unMx] :: Matrix a -> Stream (Bag a) (/\) :: Monad m => (a -> m b) -> (t -> m a) -> t -> m b (\/) :: MonadPlus m => (t -> m a) -> (t -> m a) -> t -> m a newtype Recomp a Rc :: (Int -> Bag a) -> Recomp a [unRc] :: Recomp a -> Int -> Bag a newtype RecompT m a RcT :: (Int -> m (Bag a)) -> RecompT m a [unRcT] :: RecompT m a -> Int -> m (Bag a) rcToMx :: Recomp a -> Matrix a mxToRc :: Matrix a -> Recomp a class (Delay m, MonadPlus m, Functor m) => Search m where catBags = mapDepth concat mergesortDepthWithBy combiner comp = mapDepth (mergesortWithBy combiner comp) fromRc :: Search m => Recomp a -> m a toRc :: Search m => m a -> Recomp a fromMx :: Search m => Matrix a -> m a toMx :: Search m => m a -> Matrix a fromDB :: Search m => DBound a -> m a fromDF :: Search m => [a] -> m a toDF :: Search m => m a -> [a] -- | mapDepth applies a function to the bag at each depth. mapDepth :: Search m => (Bag a -> Bag b) -> m a -> m b -- | catBags flattens each bag. catBags :: Search m => m (Bag a) -> m a -- | mergesortDepthWithBy converts bags to sets, by (possibly -- sorting each bag and) removing duplicates. Efficiency on lists with -- lots of duplicates is required. mergesortDepthWithBy :: Search m => (k -> k -> k) -> (k -> k -> Ordering) -> m k -> m k ifDepth :: Search m => (Int -> Bool) -> m a -> m a -> m a diag :: Stream (Stream a) -> Stream (Bag a) class Delay m where delay = ndelay 1 ndelay n x = iterate delay x !! n delay :: Delay m => m a -> m a ndelay :: Delay m => Int -> m a -> m a getDepth :: Delay m => m Int msumMx :: Bag a -> Matrix a msumRc :: Bag a -> Recomp a listToRc :: Bag a -> Recomp a consMx :: Bag a -> Matrix a -> Matrix a consRc :: Bag a -> Recomp a -> Recomp a zipWithBF :: Monad m => (a -> b -> m c) -> m a -> m b -> m c printMx :: Show a => Matrix a -> IO () printNMx :: Show a => Int -> Matrix a -> IO () mapDepthDB :: DB m => (Bag (a, Int) -> Bag (b, Int)) -> m a -> m b type Bag a = [a] type Stream a = [a] cat :: [[a]] -> [a] toList :: a -> a getDepth :: Delay m => m Int scanl1BF :: Search m => m x -> m x zipDepthMx :: (Int -> Bag a -> Bag b) -> Matrix a -> Matrix b zipDepthRc :: (Int -> Bag a -> Bag b) -> Recomp a -> Recomp b zipDepth3Mx :: (Int -> Bag a -> Bag b -> Bag c) -> Matrix a -> Matrix b -> Matrix c zipDepth3Rc :: (Int -> Bag a -> Bag b -> Bag c) -> Recomp a -> Recomp b -> Recomp c scanlRc :: (Bag a -> Bag b -> Bag a) -> Bag a -> Recomp b -> Recomp a newtype DBound a DB :: (Int -> Bag (a, Int)) -> DBound a [unDB] :: DBound a -> Int -> Bag (a, Int) newtype DBoundT m a DBT :: (Int -> m (Bag (a, Int))) -> DBoundT m a [unDBT] :: DBoundT m a -> Int -> m (Bag (a, Int)) zipDepthDB :: DB m => (Int -> Bag (a, Int) -> Bag (b, Int)) -> m a -> m b newtype DBMemo a DBM :: Stream (Bag (a, Int)) -> DBMemo a [unDBM] :: DBMemo a -> Stream (Bag (a, Int)) class (Search n) => Memoable m n tabulate :: Memoable m n => n a -> m a applyMemo :: Memoable m n => m a -> n a shrink :: (Num t, Ix t) => (t1 -> t1 -> t1) -> (t1 -> t1 -> Maybe Ordering) -> t -> [(t1, t)] -> [(t1, t)] class Search m => DB m mapDepthDB :: DB m => (Bag (a, Int) -> Bag (b, Int)) -> m a -> m b zipDepthDB :: DB m => (Int -> Bag (a, Int) -> Bag (b, Int)) -> m a -> m b dbtToRcT :: Monad m => DBoundT m a -> RecompT m a instance GHC.Show.Show a => GHC.Show.Show (Control.Monad.Search.Combinatorial.Matrix a) instance GHC.Base.Monoid (Control.Monad.Search.Combinatorial.Matrix a) instance GHC.Base.Monoid (Control.Monad.Search.Combinatorial.Recomp a) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Monoid (Control.Monad.Search.Combinatorial.RecompT m a) instance GHC.Base.Applicative Control.Monad.Search.Combinatorial.Matrix instance GHC.Base.Monad Control.Monad.Search.Combinatorial.Matrix instance GHC.Base.Alternative Control.Monad.Search.Combinatorial.Matrix instance GHC.Base.MonadPlus Control.Monad.Search.Combinatorial.Matrix instance GHC.Base.Functor Control.Monad.Search.Combinatorial.Matrix instance GHC.Base.Functor Control.Monad.Search.Combinatorial.Recomp instance GHC.Base.Functor Control.Monad.Search.Combinatorial.DBound instance GHC.Base.Functor f => GHC.Base.Functor (Control.Monad.Search.Combinatorial.RecompT f) instance GHC.Base.Functor f => GHC.Base.Functor (Control.Monad.Search.Combinatorial.DBoundT f) instance GHC.Base.Applicative Control.Monad.Search.Combinatorial.Recomp instance GHC.Base.Monad Control.Monad.Search.Combinatorial.Recomp instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Search.Combinatorial.RecompT m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Search.Combinatorial.RecompT m) instance GHC.Base.Alternative Control.Monad.Search.Combinatorial.Recomp instance GHC.Base.MonadPlus Control.Monad.Search.Combinatorial.Recomp instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Alternative (Control.Monad.Search.Combinatorial.RecompT m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.MonadPlus (Control.Monad.Search.Combinatorial.RecompT m) instance Control.Monad.Search.Combinatorial.DB Control.Monad.Search.Combinatorial.DBound instance (GHC.Base.Functor m, GHC.Base.Monad m) => Control.Monad.Search.Combinatorial.DB (Control.Monad.Search.Combinatorial.DBoundT m) instance Control.Monad.Search.Combinatorial.Delay Control.Monad.Search.Combinatorial.DepthFst instance Control.Monad.Search.Combinatorial.Delay Control.Monad.Search.Combinatorial.Recomp instance Control.Monad.Search.Combinatorial.Delay Control.Monad.Search.Combinatorial.Matrix instance GHC.Base.Monad m => Control.Monad.Search.Combinatorial.Delay (Control.Monad.Search.Combinatorial.RecompT m) instance (GHC.Base.Monad m, Control.Monad.Search.Combinatorial.Delay m) => Control.Monad.Search.Combinatorial.Delay (Control.Monad.Trans.State.Lazy.StateT s m) instance Control.Monad.Search.Combinatorial.Search Control.Monad.Search.Combinatorial.DepthFst instance Control.Monad.Search.Combinatorial.Search Control.Monad.Search.Combinatorial.Recomp instance (GHC.Base.Functor m, GHC.Base.Monad m) => Control.Monad.Search.Combinatorial.Search (Control.Monad.Search.Combinatorial.RecompT m) instance Control.Monad.Search.Combinatorial.Search Control.Monad.Search.Combinatorial.Matrix instance GHC.Show.Show (Control.Monad.Search.Combinatorial.Recomp a) instance GHC.Show.Show (Control.Monad.Search.Combinatorial.DBound a) instance GHC.Base.Applicative Control.Monad.Search.Combinatorial.DBound instance GHC.Base.Monad Control.Monad.Search.Combinatorial.DBound instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Search.Combinatorial.DBoundT m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Search.Combinatorial.DBoundT m) instance GHC.Base.Alternative Control.Monad.Search.Combinatorial.DBound instance GHC.Base.MonadPlus Control.Monad.Search.Combinatorial.DBound instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Alternative (Control.Monad.Search.Combinatorial.DBoundT m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.MonadPlus (Control.Monad.Search.Combinatorial.DBoundT m) instance Control.Monad.Search.Combinatorial.Delay Control.Monad.Search.Combinatorial.DBound instance GHC.Base.Monad m => Control.Monad.Search.Combinatorial.Delay (Control.Monad.Search.Combinatorial.DBoundT m) instance Control.Monad.Search.Combinatorial.Search Control.Monad.Search.Combinatorial.DBound instance (GHC.Base.Functor m, GHC.Base.Monad m) => Control.Monad.Search.Combinatorial.Search (Control.Monad.Search.Combinatorial.DBoundT m) instance Control.Monad.Search.Combinatorial.Memoable Control.Monad.Search.Combinatorial.Matrix Control.Monad.Search.Combinatorial.Recomp instance Control.Monad.Search.Combinatorial.Memoable Control.Monad.Search.Combinatorial.DBMemo Control.Monad.Search.Combinatorial.DBound module MagicHaskeller.Instantiate mkRandTrie :: [Int] -> TyConLib -> Generator -> RTrie type RTrie = (CmpMap, Maps, MemoMap, Tries, MapType (Dynamic, Dynamic)) uncurryDyn :: Dynamic -> Type -> Dynamic -> Dynamic -- | uncurryTy converts a->b->c->d->e->r -- into ((((a,b),c),d),e)->r Note that Arbitrary -- (a,b,c,d,e) is not defined in Test.QuickCheck. uncurryTy :: TyConLib -> Type -> Type mkUncurry :: TyConLib -> Dynamic typeToOrd :: CmpMap -> Type -> Maybe Dynamic typeToRandomsOrd :: TyConLib -> RTrie -> Type -> Order typeToRandomsOrdDM :: [Int] -> TyConLib -> RTrie -> Type -> Maybe ([[Dynamic]], PackedOrd) mkCurry :: TyConLib -> Dynamic curryDyn :: Dynamic -> Type -> Dynamic -> Dynamic argTypeToRandoms :: TyConLib -> CmpMap -> Maps -> Type -> Maybe [Dynamic] typeToArb :: ArbMap -> CoarbMap -> Type -> Maybe Dynamic type PackedOrd = Dynamic -> Dynamic -> Ordering typeToCompare :: TyConLib -> CmpMap -> Type -> Maybe (Dynamic -> Dynamic -> Ordering) compareRealFloat :: (NearEq a, RealFloat a) => a -> a -> Ordering module MagicHaskeller.Expression data AnnExpr AE :: CoreExpr -> Dynamic -> AnnExpr data MemoExpr ME :: CoreExpr -> Dynamic -> Dynamic -> MemoExpr aeToME :: TyConLib -> RTrie -> Type -> AnnExpr -> MemoExpr meToAE :: MemoExpr -> AnnExpr class (Ord e, Show e) => Expression e where reorganizeId' fun avail = case cvtAvails' avail of { (args, newavail) -> fmap (\ e -> replaceVars' 0 e args) $ fun newavail } mkHead :: (Expression e, Integral i, Integral j) => (CoreExpr -> Dynamic) -> i -> j -> j -> CoreExpr -> e toCE :: Expression e => e -> CoreExpr fromCE :: Expression e => (CoreExpr -> Dynamic) -> CoreExpr -> e mapCE :: Expression e => (CoreExpr -> CoreExpr) -> e -> e aeAppErr :: Expression e => String -> e -> e -> e appEnv :: Expression e => Int8 -> e -> e -> e toAnnExpr :: Expression e => (CoreExpr -> Dynamic) -> e -> AnnExpr toAnnExprWind :: Expression e => (CoreExpr -> Dynamic) -> Type -> e -> AnnExpr toAnnExprWindWind :: Expression e => (CoreExpr -> Dynamic) -> Type -> e -> AnnExpr fromAnnExpr :: Expression e => AnnExpr -> e reorganize :: (Expression e, Monad m) => ([Type] -> m [e]) -> [Type] -> m [e] reorganize' :: (Expression e, Monad m) => ([Type] -> m [e]) -> [Type] -> m [e] reorganizeId :: Expression e => ([Type] -> [e]) -> [Type] -> [e] replaceVars' :: Expression e => Int8 -> e -> [Int8] -> e reorganizeId' :: (Expression e, Functor m) => ([Type] -> m e) -> [Type] -> m e decodeVars :: Expression e => Int -> [Int8] -> e -> e mapFst3 :: (t3 -> t2) -> (t3, t1, t) -> (t2, t1, t) decodeVarsPos :: [Int8] -> ([CoreExpr], t1, t) -> ([CoreExpr], t1, t) decodeVarsCE :: [Int8] -> CoreExpr -> CoreExpr decodeVarsCE' :: Int8 -> Array Int8 Int8 -> CoreExpr -> CoreExpr decodeVarsAE :: Int -> [Int8] -> AnnExpr -> AnnExpr decodeVarsDyn :: Int -> [Int8] -> Dynamic -> Dynamic insAbsents :: Int8 -> [Int8] -> Dynamic (<$>) :: Expression e => e -> e -> e mkHeadAE :: (CoreExpr -> Dynamic) -> Int8 -> Int -> Int8 -> CoreExpr -> AnnExpr windType :: Type -> CoreExpr -> CoreExpr dynSn :: Int8 -> Dynamic getDyn :: Int8 -> Int8 -> Dynamic mkDyn :: Int8 -> Int8 -> Dynamic dynss :: [[Dynamic]] x :: Integral t => t -> Dynamic finiteDynar :: Array (Int8, Int8) Dynamic finiteDynarr :: Array (Int8, Int8, Int8) Dynamic finiteDynss :: [[Dynamic]] finiteDynsss :: [[[Dynamic]]] getDyn_LambdaBoundHead :: Int8 -> Int8 -> Int8 -> Dynamic mkDyn_LambdaBoundHead :: Int8 -> Int8 -> Int8 -> Dynamic dynsss :: [[[Dynamic]]] dynBK :: Dynamic reorganizer :: Monad m => ([Type] -> m [CoreExpr]) -> [Type] -> m [CoreExpr] reorganizerId :: ([Type] -> [CoreExpr]) -> [Type] -> [CoreExpr] replaceVars :: Int8 -> CoreExpr -> [[Int8]] -> [CoreExpr] cvtAvails :: [Type] -> ([Type], [[Int8]]) tkr10 :: [(Type, a)] -> [(Type, [a])] annotate :: [Type] -> [(Type, Int8)] reorganizeCE' :: Monad m => ([Type] -> m [CoreExpr]) -> [Type] -> m [CoreExpr] replaceVarsCE' :: Int8 -> CoreExpr -> [Int8] -> CoreExpr cvtAvails' :: [Type] -> ([Int8], [Type]) uniqSorter :: (Expression e) => [(e, Int)] -> [(e, Int)] uniqSortPatAVL :: (Expression e) => [(e, Int)] -> [(e, Int)] uniqSort :: Ord a => [a] -> [a] uniqSortAVL :: Ord a => [a] -> [a] swapUniqSort :: (Ord a, Ord b) => [(a, b)] -> [(a, b)] see :: Int8 -> Int8 -> String seeType :: Int8 -> Int8 -> CoreExpr sees :: Int8 -> Int8 -> Int8 -> String seesType :: Int8 -> Int8 -> Int8 -> CoreExpr e2THE :: CoreExpr -> Exp printTables :: IO () printTable :: IO () pprintType :: Type -> String mkVName :: Char -> Int -> Q Name mkVNames :: Char -> Int -> Q [Name] mkEs :: Int -> Q [Name] mkAs :: Int -> Q [Name] mkXs :: Int -> Q [Name] mkHd :: Q Name hdmnTHEQ :: Int8 -> Int8 -> ExpQ aimnTHEQ :: Int8 -> Int8 -> Int8 -> ExpQ hdmnTHE :: Int8 -> Int8 -> Exp aimnTHE :: Int8 -> Int8 -> Int8 -> Exp hdmnty :: Int8 -> Int8 -> Type aimnty :: Int8 -> Int8 -> Int8 -> Type mkTV :: TyVar -> Type tvrs :: [Type] tvas :: [Type] tvr :: Type maxArity :: Int8 maxLenavails :: Int8 maxDebindex :: Int8 mkCE :: Int8 -> Int8 -> CoreExpr mkCE_LambdaBoundHead :: Int8 -> Int8 -> Int8 -> CoreExpr data CoreExpr instance GHC.Show.Show MagicHaskeller.Expression.AnnExpr instance GHC.Classes.Eq MagicHaskeller.Expression.AnnExpr instance GHC.Classes.Ord MagicHaskeller.Expression.AnnExpr instance MagicHaskeller.Expression.Expression MagicHaskeller.CoreLang.CoreExpr instance MagicHaskeller.Expression.Expression MagicHaskeller.Expression.AnnExpr module MagicHaskeller.Options -- | options that limit the hypothesis space. data Opt a Opt :: Maybe a -> Int -> (Type -> Int -> Bool) -> MemoCond -> (VarLib -> CoreExpr -> Dynamic) -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> Bool -> TFGen -> [Int] -> (Int -> Int) -> Opt a -- | Use this option if you want to use a different component library for -- the stage of solving the inhabitation problem. Nothing means -- using the same one. This option makes sense only when using *SF style -- generators, because otherwise the program generation is not staged. -- Using a minimal set for solving the inhabitation and a redundant -- library for the real program generation can be a good bet. [primopt] :: Opt a -> Maybe a -- | memoization depth. (Sub)expressions within this size are memoized, -- while greater expressions will be recomputed (to save the heap space). -- Only effective when using ProgGen and unless using the -- everythingIO family. [memodepth] :: Opt a -> Int -- | This represents when to memoize. It takes the query type and the query -- depth, and returns True if the corresponding entry should be -- looked up from the lazy memo table. Currently this only works for -- ProgGenSF. [memoCondPure] :: Opt a -> Type -> Int -> Bool -- | This represents which memoization table to be used based on the query -- type and the search depth, when using the everythingIO -- family. [memoCond] :: Opt a -> MemoCond [execute] :: Opt a -> VarLib -> CoreExpr -> Dynamic -- | Just ms sets the timeout to ms microseconds. Also, -- my implementation of timeout also catches inevitable exceptions like -- stack space overflow. Note that setting timeout makes the library -- referentially untransparent. (But currently Just 20000 is the -- default!) Setting this option to Nothing disables both -- timeout and capturing exceptions. [timeout] :: Opt a -> Maybe Int -- | If this option is True, forkProcess instead of -- forkIO is used for timeout. The former is much heavier than the -- latter, but is more preemptive and thus is necessary for interrupting -- some infinite loops. This record is ignored if FORCIBLETO is not -- defined. [forcibleTimeout] :: Opt a -> Bool -- | If this option is True, the program guesses whether each -- function is a casecatamorphismparamorphism or not. This -- information is used to filter out some duplicate expressions. -- (History: I once abandoned this guessing strategy around the time I -- moved to the library implementation, because I could not formally -- prove the exhaustiveness of the resulting algorithm. For this reason, -- the old standalone version of MagicHaskeller uses this strategy, but -- almost the same effect can be obtained by setting this option to True, -- or using init075 instead of initialize. [guess] :: Opt a -> Bool -- | This option is now obsolete, and we always assume True now. If this -- option was False, data structures might not contain -- functions, and thus types like [Int->Int], -- (Int->Bool, Char), etc. were not permitted. (NB: recently -- I noticed that making this False might not improve the -- efficiency of generating lambda terms at all, though when I generated -- combinatory expressions it WAS necessary. In fact, I mistakenly turned -- this limitation off, and my code always regarded this as True, but I -- did not notice that, so this option can be obsoleted.) [contain] :: Opt a -> Bool -- | If this option is True, matching at the antecedent of -- induction rules may occur, which constrains generation of existential -- types. You need to use prefixed (->) to show that some -- parameter can be matched at the antecedent, e.g., p [| ( -- []::[a], (:)::a->[a]->[a], foldr :: (a->b->b) -> b -- -> (->) [a] b ) |] See LibTH.hs for examples. [constrL] :: Opt a -> Bool -- | Each time the type variable which appears in the return type of a -- function (e.g. b in -- foldr::(a->b->b)->b->[a]->b) is expanded to a -- function type, the search priority of the current computation is -- lowered by this number. It's default value is 1, which means there is -- nothing special, and the priority for each expression corresponds to -- the number of function applications in the expression. -- -- Example: when tvndelay = 1, -- -- The priority of -- --
-- \xs -> foldr (\x y -> x+y) 0 xs ---- -- is 5, because there are five $'s in -- --
-- \xs -> ((foldr $ (\x y -> ((+) $ x) $ y)) $ 0) xs ---- -- The priority of -- --
-- \xs ys -> foldr (\x y zs -> x : y zs) (\ws->ws) xs ys ---- -- is 7, because there are seven $'s in -- --
-- \xs ys -> (((foldr $ (\x y zs -> (((:) $ x) $ y) $ zs)) $ (\ws->ws)) $ xs) $ ys ---- -- Example: when tvndelay = 2, -- -- The priority of -- --
-- \xs -> foldr (\x y -> x+y) 0 xs ---- -- is 5, because there are five $'s in -- --
-- \xs -> ((foldr $ (\x y -> ((+) $ x) $ y)) $ 0) xs ---- -- The priority of -- --
-- \xs ys -> foldr (\x y zs -> x : y zs) (\ws->ws) xs ys ---- -- is 8, because there are eight $'s in -- --
-- \xs ys -> (((foldr $ (\x y zs -> (((:) $ x) $ y) $ zs)) $ (\ws->ws)) $ xs) $$ ys ---- -- where $$ denotes the function application caused by expanding -- a type variable into a function type. [tvndelay] :: Opt a -> Int -- | If this option is True, the return type of functions -- returning a type variable (e.g. b in -- foldr::(a->b->b)->b->[a]->b) can only be -- replaced with Eval t => t and Eval t => u -> -- t, while if False with Eval t => t, Eval -- t => u->t, Eval t => u->v->t, etc., where -- Eval t means t cannot be replaced with a function. The -- restriction can be amended if the tuple constructor and destructors -- are available. [tv1] :: Opt a -> Bool [tv0] :: Opt a -> Bool -- | The random seed. [stdgen] :: Opt a -> TFGen -- | number of random samples at each depth, for each type, for the filter -- applied during synthesis (used by ProgGenSF, &c.). [nrands] :: Opt a -> [Int] -- | number of random samples at each depth, for each type, for the filter -- applied after synthesis (used by filterThenF, &c.). [fcnrand] :: Opt a -> Int -> Int -- | default options -- --
-- options = Opt{ primopt = Nothing
-- , memodepth = 10
-- , memoCondPure = \ _type depth -> 0<depth
-- , memoCond = \ _type depth -> return $ if depth < 10 then Ram else Recompute
-- , execute = unsafeExecute
-- , timeout = Just 20000
-- , forcibleTimeout = False
-- , guess = False
-- , contain = True
-- , constrL = False
-- , tv1 = False
--
options :: Opt a
forget :: Opt a -> Opt ()
nrnds :: [Int]
chopRnds :: [[a]] -> [[a]]
fnrnds :: Num t => t1 -> t
module MagicHaskeller.Classification
class (Search m) => SStrategy m
sfilter :: (SStrategy m, Relation r) => (k -> k -> r) -> (Int -> Int) -> m ([k], e) -> m ([k], e)
ofilter :: (SStrategy m, Relation r) => (k -> k -> r) -> m (k, e) -> m (k, e)
arbitraries :: Arbitrary a => [a]
arbs :: Arbitrary a => Int -> TFGen -> [a]
(/~) :: [a] -> (a -> a -> Bool) -> [[a]]
nubSortBy :: (a -> a -> Ordering) -> [a] -> [a]
nubSortByBot :: (a -> a -> Maybe Ordering) -> [a] -> [a]
(/<) :: [a] -> (a -> a -> Ordering) -> [[a]]
(/) :: [a] -> (a -> a -> Maybe Ordering) -> [[a]]
class Eq rel => Relation rel where fromListBy cmp = map head . (/ cmp) fromListByDB rel ts = map (minimumBy (\ x y -> compare (snd y) (snd x))) (ts / (\ x y -> rel (fst x) (fst y)))
fromListBy :: Relation rel => (k -> k -> rel) -> [k] -> [k]
fromListByDB :: Relation rel => (k -> k -> rel) -> [(k, Int)] -> [(k, Int)]
(/) :: Relation rel => [k] -> (k -> k -> rel) -> [[k]]
appendWithBy :: Relation rel => (k -> k -> k) -> (k -> k -> rel) -> [k] -> [k] -> [k]
diffBy :: Relation rel => (k -> k -> rel) -> [k] -> [k] -> [k]
cEQ :: Relation rel => rel
appendQuotientsBy :: (Relation rel) => (k -> k -> rel) -> [[k]] -> [[k]] -> [[k]]
appendRepresentativesBy :: (Relation rel) => (k -> k -> rel) -> [k] -> [k] -> [k]
unionWithBy :: (a -> a -> a) -> (a -> a -> Bool) -> [a] -> [a] -> [a]
randomTestFilter :: (SStrategy m, Filtrable a) => (Int -> Int) -> m (e, a) -> m (e, a)
unsafeRandomTestFilter :: (SStrategy m, Filtrable a) => Maybe Int -> (Int -> Int) -> m (e, a) -> m (e, a)
mapFst :: (t2 -> t1) -> (t2, t) -> (t1, t)
class Filtrable a
filt :: (Filtrable a, SStrategy m) => (Int -> Int) -> m (a, e) -> m e
filtFun :: (Filtrable a, SStrategy m, Arbitrary b) => (Int -> Int) -> m (b -> a, e) -> m e
unsafeFilt :: (Filtrable a, SStrategy m) => Maybe Int -> (Int -> Int) -> m (a, e) -> m e
unsafeFiltFun :: (Filtrable a, SStrategy m, Arbitrary b) => Maybe Int -> (Int -> Int) -> m (b -> a, e) -> m e
filtNullary :: (SStrategy m, Relation r) => (k -> k -> r) -> (Int -> Int) -> m (k, e) -> m e
filtUnary :: (Arbitrary a, Relation r, SStrategy f) => (k -> k -> r) -> (Int -> Int) -> f (a -> k, b) -> f b
compareCx :: (RealFloat a, Ord a) => Complex a -> Complex a -> Ordering
ofilterMx :: Relation r => (k -> k -> r) -> Matrix (k, e) -> Matrix (k, e)
ofilterDB :: Relation rel => (k -> k -> rel) -> DBound (k, e) -> DBound (k, e)
cumulativeRepresentatives :: Relation rel => [a -> a -> rel] -> Matrix a -> Matrix a
representatives :: Relation rel => [a -> a -> rel] -> Matrix a -> Matrix a
unscanlByList :: Relation r => [k -> k -> r] -> Matrix k -> Matrix k
sfilterMx :: Relation r => (k -> k -> r) -> (Int -> Int) -> Matrix ([k], e) -> Matrix ([k], e)
liftRelation :: Relation r => (k -> k -> r) -> Int -> ([k], e) -> ([k], e) -> r
liftRel :: (Eq t, Relation t1, Num t) => (t3 -> t2 -> t1) -> t -> [t3] -> [t2] -> t1
sfilterDB :: Relation rel => (k -> k -> rel) -> (Int -> Int) -> DBound ([k], e) -> DBound ([k], e)
cumulativeQuotients :: Relation rel => [k -> k -> rel] -> Matrix k -> Matrix [k]
ns :: [Integer]
instance MagicHaskeller.Classification.SStrategy Control.Monad.Search.Combinatorial.Matrix
instance MagicHaskeller.Classification.SStrategy Control.Monad.Search.Combinatorial.DBound
instance MagicHaskeller.Classification.Relation GHC.Types.Bool
instance MagicHaskeller.Classification.Relation GHC.Types.Ordering
instance MagicHaskeller.Classification.Relation (GHC.Base.Maybe GHC.Types.Ordering)
instance (MagicHaskeller.MyCheck.Arbitrary a, MagicHaskeller.Classification.Filtrable r) => MagicHaskeller.Classification.Filtrable (a -> r)
instance GHC.Classes.Ord a => MagicHaskeller.Classification.Filtrable a
instance MagicHaskeller.Classification.Filtrable GHC.Types.Double
instance (GHC.Float.RealFloat a, GHC.Classes.Ord a) => MagicHaskeller.Classification.Filtrable (Data.Complex.Complex a)
module MagicHaskeller.TICE
type TI = PriorSubsts Maybe
ceToDynamic :: TyConLib -> VarLib -> CoreExpr -> Dynamic
tiCE :: (Functor m, MonadPlus m) => TyConLib -> VarLib -> CoreExpr -> m Type
tiEx :: (MonadPlus m, IArray a Dynamic) => t -> a Var Dynamic -> CoreExpr -> PriorSubsts m Type
module MagicHaskeller.ProgramGenerator
-- | annotated 'Typed [CoreExpr]'
type Prim = (Int, Int, Type, TyVar, Typed [CoreExpr])
class WithCommon a
extractCommon :: WithCommon a => a -> Common
-- | ProgramGenerator is a generalization of the old Memo type.
class WithCommon a => ProgramGenerator a where mkTrie cmn c t = mkTrieOpt cmn c t t mkTrieOpt cmn c _ t = mkTrie cmn c t matchingPrograms ty memodeb = unifyingPrograms (quantify ty) memodeb matchingProgramsWOAbsents ty memodeb = mapDepth (filter (not . isAbsent (getArity ty) . toCE)) $ matchingPrograms ty memodeb
-- | |mkTrie| creates the generator with the default parameters.
mkTrie :: ProgramGenerator a => Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> a
mkTrieOpt :: ProgramGenerator a => Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> [[Typed [CoreExpr]]] -> a
matchingPrograms, matchingProgramsWOAbsents, unifyingPrograms :: (ProgramGenerator a, Search m) => Type -> a -> m AnnExpr
matchingPrograms, matchingProgramsWOAbsents, unifyingPrograms :: (ProgramGenerator a, Search m) => Type -> a -> m AnnExpr
matchingPrograms, matchingProgramsWOAbsents, unifyingPrograms :: (ProgramGenerator a, Search m) => Type -> a -> m AnnExpr
class WithCommon a => ProgramGeneratorIO a where mkTrieIO cmn c t = mkTrieOptIO cmn c t t mkTrieOptIO cmn c _ t = mkTrieIO cmn c t matchingProgramsIO ty memodeb = unifyingProgramsIO (quantify ty) memodeb
-- | |mkTrie| creates the generator with the default parameters.
mkTrieIO :: ProgramGeneratorIO a => Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> IO a
mkTrieOptIO :: ProgramGeneratorIO a => Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> [[Typed [CoreExpr]]] -> IO a
-- | Use memoization requiring IO
matchingProgramsIO, unifyingProgramsIO :: ProgramGeneratorIO a => Type -> a -> RecompT IO AnnExpr
-- | Use memoization requiring IO
matchingProgramsIO, unifyingProgramsIO :: ProgramGeneratorIO a => Type -> a -> RecompT IO AnnExpr
extractTCL :: WithCommon a => a -> TyConLib
extractVL :: WithCommon a => a -> VarLib
extractRTrie :: WithCommon a => a -> RTrie
reducer :: Common -> CoreExpr -> Dynamic
data Common
Cmn :: Opt () -> TyConLib -> VarLib -> VarLib -> VarPriorityLib -> RTrie -> Common
[opt] :: Common -> Opt ()
[tcl] :: Common -> TyConLib
[vl] :: Common -> VarLib
[pvl] :: Common -> VarLib
[vpl] :: Common -> VarPriorityLib
[rt] :: Common -> RTrie
mkCommon :: Options -> [Primitive] -> [Primitive] -> [Int] -> Common
initCommon :: Options -> [Primitive] -> Common
-- | updateCommon can be used for incremetal learning
updateCommon :: [Dynamic] -> [Dynamic] -> [Int] -> Common -> Common
-- | options for limiting the hypothesis space.
type Options = Opt [[Primitive]]
retsTVar :: (t3, t2, Type, t1, t) -> Bool
annotateTCEs :: Typed [CoreExpr] -> Prim
splitPrims :: [Typed [CoreExpr]] -> ([Prim], [Prim])
splitPrimss :: [[Typed [CoreExpr]]] -> ([[Prim]], [[Prim]])
mapSum :: (MonadPlus m, Delay m) => (a -> m b) -> [[a]] -> m b
applyDo :: (Functor m, Monad m) => ([Type] -> Type -> PriorSubsts m a) -> [Type] -> Type -> PriorSubsts m a
wind :: (a -> a) -> ([Type] -> Type -> a) -> [Type] -> Type -> a
wind_ :: ([Type] -> Type -> a) -> [Type] -> Type -> a
fromAssumptions :: (Search m, Expression e) => Common -> Int -> (Type -> PriorSubsts m [e]) -> (Type -> Type -> PriorSubsts m ()) -> Type -> [Type] -> PriorSubsts m [e]
retMono :: (Search m, Expression e) => Common -> Int -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m ()) -> (Int8, (Int, [Type], Type)) -> PriorSubsts m [e]
fromAvail :: [Type] -> [(Int8, (Int, [Type], Type))]
mguAssumptions :: (Functor m, MonadPlus m) => Type -> [Type] -> PriorSubsts m [CoreExpr]
mguAssumptions' :: MonadPlus m => [Type] -> Type -> PriorSubsts m [CoreExpr]
matchAssumptions :: (Functor m, MonadPlus m, Expression e) => Common -> Int -> Type -> [Type] -> PriorSubsts m [e]
mguAssumptions_ :: (Functor m, MonadPlus m) => Type -> [Type] -> PriorSubsts m ()
mguAssumptions_' :: MonadPlus m => [Type] -> Type -> PriorSubsts m ()
retPrimMono :: (Search m, Expression e) => Common -> Int -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> Type -> PriorSubsts m ()) -> Type -> Prim -> PriorSubsts m [e]
funApSub :: (Search m, Expression e) => (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> Type -> [e] -> PriorSubsts m [e]
funApSubOp :: (Monad m, Monad m1) => (r -> a2 -> r) -> (Type -> m1 (m a2)) -> (Type -> m1 (m a2)) -> (Type -> m1 (m a2)) -> Type -> m r -> m1 (m r)
fap :: (Expression r, Monad m, Monad m1, Foldable t) => (t1 -> m1 (m r)) -> t t1 -> m r -> m1 (m r)
mapAndFoldM :: Monad m => (t2 -> t1 -> t2) -> t2 -> (t -> m t1) -> [t] -> m t2
retGen :: (Search m, Expression e) => Common -> Int -> (Type -> Type -> [e] -> [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> Type -> Prim -> PriorSubsts m [e]
retGenOrd :: (Search m, Expression e) => Common -> Int -> (Type -> Type -> [e] -> [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> Type -> Prim -> PriorSubsts m [e]
retGenTV1 :: (Search m, Expression e) => Common -> Int -> (Type -> Type -> [e] -> [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> (Type -> PriorSubsts m [e]) -> Type -> Prim -> PriorSubsts m [e]
retGen' :: (Integral i, Expression e, Search n) => (Type -> t1 -> PriorSubsts n b) -> Common -> i -> (Type -> Type -> [e] -> t1) -> (Type -> PriorSubsts n [e]) -> (Type -> PriorSubsts n [e]) -> (Type -> PriorSubsts n [e]) -> Type -> (Int, Int, t, TyVar, Typed [CoreExpr]) -> PriorSubsts n b
orderedAndUsedArgs :: Type -> Bool
usedArg :: TyVar -> Type -> Bool
retGenTV0 :: (Integral i, Integral j, Expression e, Search n) => Common -> i -> (Type -> Type -> [e] -> b) -> (Type -> PriorSubsts n [e]) -> (Type -> PriorSubsts n [e]) -> (Type -> PriorSubsts n [e]) -> Type -> (j, j, t, TyVar, Typed [CoreExpr]) -> PriorSubsts n b
filtExprs :: Expression e => Bool -> Type -> Type -> [e] -> [e]
filterExprs :: Expression e => Type -> Type -> [e] -> [e]
getArgExprs :: CoreExpr -> [CoreExpr]
gae :: CoreExpr -> [CoreExpr] -> [CoreExpr]
constEq :: Type -> [CoreExpr] -> Bool
ceq :: CoreExpr -> Type -> [CoreExpr] -> Bool
recHead :: Type -> CoreExpr -> Bool
retSameVal :: Type -> [CoreExpr] -> Bool
rsv :: Type -> [CoreExpr] -> Bool
rsv' :: CoreExpr -> Type -> [CoreExpr] -> Bool
returnsAtoA :: Type -> Bool
returnsId :: Type -> CoreExpr -> Bool
isId :: CoreExpr -> Bool
isId' :: Int8 -> CoreExpr -> Bool
isId'' :: Int8 -> Int8 -> CoreExpr -> Bool
retVal :: Type -> CoreExpr -> CoreExpr
rv :: Type -> Int8 -> CoreExpr -> CoreExpr
mapsub :: Int8 -> CoreExpr -> CoreExpr
isConstrExpr :: CoreExpr -> Bool
isClosed :: CoreExpr -> Bool
isClosed' :: Int8 -> CoreExpr -> Bool
includesStrictArg :: [CoreExpr] -> Bool
anyRec :: Type -> [CoreExpr] -> Bool
recursive :: Type -> CoreExpr -> Bool
constRec :: Int8 -> CoreExpr -> Bool
belowIsUsed :: Int8 -> CoreExpr -> Bool
isUsed :: Int8 -> CoreExpr -> Bool
mkSubsts :: Search m => Int -> TyVar -> Type -> PriorSubsts m Int
mkSubst :: Search m => Int -> TyVar -> Type -> PriorSubsts m Int
mkRetty :: Type -> (Type, Type)
reorganizer_ :: ([Type] -> a) -> [Type] -> a
hit :: Type -> [Type] -> Bool
combs :: (Num t1, Eq t1) => t1 -> [t] -> [[t]]
tails :: [t] -> [[t]]
module MagicHaskeller.ProgGen
-- | The vanilla program generator corresponding to Version 0.7.*
newtype ProgGen
-- | internal data representation
PG :: (MemoDeb (ClassLib CoreExpr) CoreExpr) -> ProgGen
mkCL :: Common -> [Typed [CoreExpr]] -> ClassLib CoreExpr
newtype ClassLib e
CL :: (MemoDeb (ClassLib e) e) -> ClassLib e
mguPrograms :: (Search m) => Generator m CoreExpr
instance MagicHaskeller.ProgramGenerator.WithCommon MagicHaskeller.ProgGen.ProgGen
instance MagicHaskeller.ProgramGenerator.ProgramGenerator MagicHaskeller.ProgGen.ProgGen
instance MagicHaskeller.ProgramGenerator.ProgramGeneratorIO MagicHaskeller.ProgGen.ProgGen
module MagicHaskeller.ProgGenSF
type ProgGenSF = PGSF CoreExpr
-- | Program generator with synergetic filtration. This program generator
-- employs filtration by random testing, and rarely generate semantically
-- equivalent expressions more than once, while different expressions
-- will eventually appear (for most of the types, represented with
-- Prelude types, whose arguments are instance of Arbitrary and which
-- return instance of Ord). The idea is to apply random numbers to the
-- generated expressions, compute the quotient set of the resulting
-- values at each depth of the search tree, and adopt the complete system
-- of representatives for the depth and push the remaining expressions to
-- one step deeper in the search tree. (Thus, adoption of expressions
-- that may be equivalent to another already-generated-expression will be
-- postponed until their "uniqueness" is proved.) As a result, (unlike
-- ProgGen,) expressions with size N may not appear at depth N but
-- some deeper place.
--
-- ProgGenSF is more efficient along with a middle-sized primitive
-- set (like reallyall found in LibTH.hs), but is slower than
-- ProgGen for a small-sized one.
--
-- Also note that ProgGenSF depends on hard use of unsafe* stuff,
-- so if there is a bug, it may segfault....
data PGSF e
PGSF :: (MemoDeb e) -> TypeTrie -> (ExpTrie e) -> PGSF e
freezePS :: Type -> PriorSubsts Recomp Type -> Matrix (Type, Subst, TyVar)
funApSub_ :: (Search m, Monoid a) => (Type -> PriorSubsts m ()) -> (Type -> PriorSubsts m a) -> (Type -> PriorSubsts m a) -> Type -> PriorSubsts m a
funApSub_spec :: (Monoid a, Search m) => (Type -> PriorSubsts m ()) -> (Type -> PriorSubsts m a) -> Type -> PriorSubsts m a
lookupNormalized :: (Functor m, MonadPlus m) => (Type -> m (e, Subst, TyVar)) -> [Type] -> Type -> PriorSubsts m e
tokoro10fst :: (Eq k, Ord k) => [(k, s, i)] -> [(k, s, i)]
mkTrieOptSFIO :: Expression e => Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> [[Typed [CoreExpr]]] -> IO (PGSF e)
instance MagicHaskeller.Expression.Expression e => MagicHaskeller.ProgramGenerator.ProgramGenerator (MagicHaskeller.ProgGenSF.PGSF e)
instance MagicHaskeller.Expression.Expression e => MagicHaskeller.ProgramGenerator.WithCommon (MagicHaskeller.ProgGenSF.PGSF e)
instance GHC.Base.Monoid MagicHaskeller.ProgGenSF.BitSet
module MagicHaskeller.ProgGenSFIORef
type ProgGenSFIORef = PGSFIOR CoreExpr
-- | Program generator with synergetic filtration. This program generator
-- employs filtration by random testing, and rarely generate semantically
-- equivalent expressions more than once, while different expressions
-- will eventually appear (for most of the types, represented with
-- Prelude types, whose arguments are instance of Arbitrary and which
-- return instance of Ord). The idea is to apply random numbers to the
-- generated expressions, compute the quotient set of the resulting
-- values at each depth of the search tree, and adopt the complete system
-- of representatives for the depth and push the remaining expressions to
-- one step deeper in the search tree. (Thus, adoption of expressions
-- that may be equivalent to another already-generated-expression will be
-- postponed until their "uniqueness" is proved.) As a result, (unlike
-- ProgGen,) expressions with size N may not appear at depth N but
-- some deeper place.
--
-- ProgGenSF is more efficient along with a middle-sized primitive
-- set (like reallyall found in LibTH.hs), but is slower than
-- ProgGen for a small-sized one.
--
-- Also note that ProgGenSF depends on hard use of unsafe* stuff,
-- so if there is a bug, it may segfault....
data PGSFIOR e
instance MagicHaskeller.ProgramGenerator.ProgramGeneratorIO (MagicHaskeller.ProgGenSFIORef.PGSFIOR MagicHaskeller.CoreLang.CoreExpr)
instance MagicHaskeller.Expression.Expression e => MagicHaskeller.ProgramGenerator.WithCommon (MagicHaskeller.ProgGenSFIORef.PGSFIOR e)
module MagicHaskeller
-- | ProgramGenerator is a generalization of the old Memo type.
class WithCommon a => ProgramGenerator a where mkTrie cmn c t = mkTrieOpt cmn c t t mkTrieOpt cmn c _ t = mkTrie cmn c t matchingPrograms ty memodeb = unifyingPrograms (quantify ty) memodeb matchingProgramsWOAbsents ty memodeb = mapDepth (filter (not . isAbsent (getArity ty) . toCE)) $ matchingPrograms ty memodeb
-- | The vanilla program generator corresponding to Version 0.7.*
data ProgGen
type ProgGenSF = PGSF CoreExpr
type ProgGenSFIORef = PGSFIOR CoreExpr
-- | p is used to convert your primitive component set into the
-- internal form.
p :: ExpQ -> ExpQ
-- | setPrimitives creates a ProgGen from the given set
-- of primitives using the current set of options, and sets it as the
-- current program generator. It used to be equivalent to setPG .
-- mkPG which overwrites the options with the default, but it is not
-- now.
setPrimitives :: [Primitive] -> [Primitive] -> IO ()
mkPG :: ProgramGenerator pg => [Primitive] -> pg
-- | mkPGSF and mkMemoSF are provided mainly for backward
-- compatibility. These functions are defined only for the
-- ProgramGenerators whose names end with SF (i.e.,
-- generators with synergetic filtration). For such generators, they are
-- defined as:
--
--
-- mkPGSF gen nrnds optups tups = mkPGOpt (options{primopt = Just optups, contain = True, stdgen = gen, nrands = nrnds}) tups
-- mkMemoSF gen nrnds optups tups = mkPGOpt (options{primopt = Just optups, contain = False, stdgen = gen, nrands = nrnds}) tups
--
mkPGSF :: ProgramGenerator pg => TFGen -> [Int] -> [Primitive] -> [Primitive] -> [Primitive] -> pg
setPG :: ProgGen -> IO ()
mkMemo :: ProgramGenerator pg => [Primitive] -> pg
-- | mkPGSF and mkMemoSF are provided mainly for backward
-- compatibility. These functions are defined only for the
-- ProgramGenerators whose names end with SF (i.e.,
-- generators with synergetic filtration). For such generators, they are
-- defined as:
--
--
-- mkPGSF gen nrnds optups tups = mkPGOpt (options{primopt = Just optups, contain = True, stdgen = gen, nrands = nrnds}) tups
-- mkMemoSF gen nrnds optups tups = mkPGOpt (options{primopt = Just optups, contain = False, stdgen = gen, nrands = nrnds}) tups
--
mkMemoSF :: ProgramGenerator pg => TFGen -> [Int] -> [Primitive] -> [Primitive] -> [Primitive] -> pg
mkPG075 :: ProgramGenerator pg => [Primitive] -> [Primitive] -> pg
mkMemo075 :: ProgramGenerator pg => [Primitive] -> [Primitive] -> pg
mkPGOpt :: ProgramGenerator pg => Options -> [Primitive] -> [Primitive] -> pg
-- | mkPG is defined as:
--
-- -- mkPG prims = mkPGSF (mkStdGen 123456) (repeat 5) prims prims --mkPGX :: ProgramGenerator pg => [Primitive] -> [[Primitive]] -> pg mkPGXOpt :: ProgramGenerator pg => Options -> [Primitive] -> [(Primitive, Primitive)] -> [[Primitive]] -> [[(Primitive, Primitive)]] -> pg mkPGXOpts :: (Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> [[Typed [CoreExpr]]] -> a) -> Options -> [Primitive] -> [(Primitive, Primitive)] -> [[Primitive]] -> [[(Primitive, Primitive)]] -> a updatePGXOpts :: (Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> [[Typed [CoreExpr]]] -> a) -> Maybe [[Primitive]] -> [Dynamic] -> [(Dynamic, Dynamic)] -> [[Dynamic]] -> [[(Dynamic, Dynamic)]] -> Common -> a updatePGXOptsFilt :: Int -> (Common -> [Typed [CoreExpr]] -> [[Typed [CoreExpr]]] -> [[Typed [CoreExpr]]] -> a) -> Maybe [[Primitive]] -> [Dynamic] -> [(Dynamic, Dynamic)] -> [[Dynamic]] -> [[(Dynamic, Dynamic)]] -> Common -> a -- | options for limiting the hypothesis space. type Options = Opt [[Primitive]] -- | options that limit the hypothesis space. data Opt a Opt :: Maybe a -> Int -> (Type -> Int -> Bool) -> MemoCond -> (VarLib -> CoreExpr -> Dynamic) -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> Bool -> TFGen -> [Int] -> (Int -> Int) -> Opt a -- | Use this option if you want to use a different component library for -- the stage of solving the inhabitation problem. Nothing means -- using the same one. This option makes sense only when using *SF style -- generators, because otherwise the program generation is not staged. -- Using a minimal set for solving the inhabitation and a redundant -- library for the real program generation can be a good bet. [primopt] :: Opt a -> Maybe a -- | memoization depth. (Sub)expressions within this size are memoized, -- while greater expressions will be recomputed (to save the heap space). -- Only effective when using ProgGen and unless using the -- everythingIO family. [memodepth] :: Opt a -> Int -- | This represents when to memoize. It takes the query type and the query -- depth, and returns True if the corresponding entry should be -- looked up from the lazy memo table. Currently this only works for -- ProgGenSF. [memoCondPure] :: Opt a -> Type -> Int -> Bool -- | This represents which memoization table to be used based on the query -- type and the search depth, when using the everythingIO -- family. [memoCond] :: Opt a -> MemoCond [execute] :: Opt a -> VarLib -> CoreExpr -> Dynamic -- | Just ms sets the timeout to ms microseconds. Also, -- my implementation of timeout also catches inevitable exceptions like -- stack space overflow. Note that setting timeout makes the library -- referentially untransparent. (But currently Just 20000 is the -- default!) Setting this option to Nothing disables both -- timeout and capturing exceptions. [timeout] :: Opt a -> Maybe Int -- | If this option is True, forkProcess instead of -- forkIO is used for timeout. The former is much heavier than the -- latter, but is more preemptive and thus is necessary for interrupting -- some infinite loops. This record is ignored if FORCIBLETO is not -- defined. [forcibleTimeout] :: Opt a -> Bool -- | If this option is True, the program guesses whether each -- function is a casecatamorphismparamorphism or not. This -- information is used to filter out some duplicate expressions. -- (History: I once abandoned this guessing strategy around the time I -- moved to the library implementation, because I could not formally -- prove the exhaustiveness of the resulting algorithm. For this reason, -- the old standalone version of MagicHaskeller uses this strategy, but -- almost the same effect can be obtained by setting this option to True, -- or using init075 instead of initialize. [guess] :: Opt a -> Bool -- | This option is now obsolete, and we always assume True now. If this -- option was False, data structures might not contain -- functions, and thus types like [Int->Int], -- (Int->Bool, Char), etc. were not permitted. (NB: recently -- I noticed that making this False might not improve the -- efficiency of generating lambda terms at all, though when I generated -- combinatory expressions it WAS necessary. In fact, I mistakenly turned -- this limitation off, and my code always regarded this as True, but I -- did not notice that, so this option can be obsoleted.) [contain] :: Opt a -> Bool -- | If this option is True, matching at the antecedent of -- induction rules may occur, which constrains generation of existential -- types. You need to use prefixed (->) to show that some -- parameter can be matched at the antecedent, e.g., p [| ( -- []::[a], (:)::a->[a]->[a], foldr :: (a->b->b) -> b -- -> (->) [a] b ) |] See LibTH.hs for examples. [constrL] :: Opt a -> Bool -- | Each time the type variable which appears in the return type of a -- function (e.g. b in -- foldr::(a->b->b)->b->[a]->b) is expanded to a -- function type, the search priority of the current computation is -- lowered by this number. It's default value is 1, which means there is -- nothing special, and the priority for each expression corresponds to -- the number of function applications in the expression. -- -- Example: when tvndelay = 1, -- -- The priority of -- --
-- \xs -> foldr (\x y -> x+y) 0 xs ---- -- is 5, because there are five $'s in -- --
-- \xs -> ((foldr $ (\x y -> ((+) $ x) $ y)) $ 0) xs ---- -- The priority of -- --
-- \xs ys -> foldr (\x y zs -> x : y zs) (\ws->ws) xs ys ---- -- is 7, because there are seven $'s in -- --
-- \xs ys -> (((foldr $ (\x y zs -> (((:) $ x) $ y) $ zs)) $ (\ws->ws)) $ xs) $ ys ---- -- Example: when tvndelay = 2, -- -- The priority of -- --
-- \xs -> foldr (\x y -> x+y) 0 xs ---- -- is 5, because there are five $'s in -- --
-- \xs -> ((foldr $ (\x y -> ((+) $ x) $ y)) $ 0) xs ---- -- The priority of -- --
-- \xs ys -> foldr (\x y zs -> x : y zs) (\ws->ws) xs ys ---- -- is 8, because there are eight $'s in -- --
-- \xs ys -> (((foldr $ (\x y zs -> (((:) $ x) $ y) $ zs)) $ (\ws->ws)) $ xs) $$ ys ---- -- where $$ denotes the function application caused by expanding -- a type variable into a function type. [tvndelay] :: Opt a -> Int -- | If this option is True, the return type of functions -- returning a type variable (e.g. b in -- foldr::(a->b->b)->b->[a]->b) can only be -- replaced with Eval t => t and Eval t => u -> -- t, while if False with Eval t => t, Eval -- t => u->t, Eval t => u->v->t, etc., where -- Eval t means t cannot be replaced with a function. The -- restriction can be amended if the tuple constructor and destructors -- are available. [tv1] :: Opt a -> Bool [tv0] :: Opt a -> Bool -- | The random seed. [stdgen] :: Opt a -> TFGen -- | number of random samples at each depth, for each type, for the filter -- applied during synthesis (used by ProgGenSF, &c.). [nrands] :: Opt a -> [Int] -- | number of random samples at each depth, for each type, for the filter -- applied after synthesis (used by filterThenF, &c.). [fcnrand] :: Opt a -> Int -> Int -- | default options -- --
-- options = Opt{ primopt = Nothing
-- , memodepth = 10
-- , memoCondPure = \ _type depth -> 0<depth
-- , memoCond = \ _type depth -> return $ if depth < 10 then Ram else Recompute
-- , execute = unsafeExecute
-- , timeout = Just 20000
-- , forcibleTimeout = False
-- , guess = False
-- , contain = True
-- , constrL = False
-- , tv1 = False
--
options :: Opt a
data MemoType
-- | Recompute instead of memoizing.
Recompute :: MemoType
-- | Use the memoization table based on lazy evaluation, like in older
-- versions.
Ram :: MemoType
-- | Use the directory specified by FilePath as the persistent
-- memoization table.
Disk :: FilePath -> MemoType
mkPGIO :: ProgramGeneratorIO pg => [Primitive] -> [Primitive] -> IO pg
mkPGXOptIO :: ProgramGeneratorIO pg => Options -> [Primitive] -> [(Primitive, Primitive)] -> [[Primitive]] -> [[(Primitive, Primitive)]] -> IO pg
-- | load loads a component library file.
load :: FilePath -> ExpQ
-- | f is supposed to be used by load, but not hidden.
f :: String -> ExpQ
-- | Currently the default depth is 10. You may want to lower the value if
-- your computer often swaps, or increase it if you have a lot of memory.
setDepth :: Int -> IO ()
-- | setTimeout sets the timeout in microseconds. Also, my
-- implementation of timeout also catches inevitable exceptions like
-- stack space overflow. Note that setting timeout makes the library
-- referentially untransparent. (But currently setTimeout 20000
-- is the default!)
setTimeout :: Int -> IO ()
-- | unsetTimeout disables timeout. This is the safe choice.
unsetTimeout :: IO ()
-- | define eases use of this library by automating some function
-- definitions. For example,
--
-- -- $( define ''ProgGen "Foo" (p [| (1 :: Int, (+) :: Int -> Int -> Int) |]) ) ---- -- is equivalent to -- --
-- memoFoo :: ProgGen -- memoFoo = mkPG (p [| (1 :: Int, (+) :: Int -> Int -> Int) |]) -- everyFoo :: Everything -- everyFoo = everything memoFoo -- filterFoo :: Filter -- filterFoo pred = filterThen pred everyFoo ---- -- If you do not think this function reduces the number of your -- keystrokes a lot, you can do without it. define :: Name -> String -> ExpQ -> Q [Dec] type Everything = forall a. Typeable a => Every a type Filter = forall a. Typeable a => (a -> Bool) -> IO (Every a) type Every a = [[(Exp, a)]] type EveryIO a = Int -> IO [(Exp, a)] -- | findOne pred finds an expression e that -- satisfies pred e == True, and returns it in Exp. findOne :: Typeable a => Bool -> (a -> Bool) -> Exp -- | printOne prints the expression found first. printOne :: Typeable a => Bool -> (a -> Bool) -> IO Exp -- | printAll prints all the expressions satisfying the given -- predicate. printAll :: Typeable a => Bool -> (a -> Bool) -> IO () printAllF :: (Typeable a, Filtrable a) => Bool -> (a -> Bool) -> IO () -- | io2pred converts a specification given as a set of I/O pairs -- to the predicate form which other functions accept. io2pred :: Eq b => [(a, b)] -> ((a -> b) -> Bool) -- | filterFirst is like printAll, but by itself it does not -- print anything. Instead, it creates a stream of expressions -- represented in tuples of Exp and the expressions themselves. filterFirst :: Typeable a => Bool -> (a -> Bool) -> IO (Every a) filterFirstF :: (Typeable a, Filtrable a) => Bool -> (a -> Bool) -> IO (Every a) -- | filterThen may be used to further filter the results. filterThen :: Typeable a => (a -> Bool) -> Every a -> IO (Every a) filterThenF :: (Filtrable a, Typeable * a) => (a -> Bool) -> Every a -> IO [[(Exp, a)]] fp :: Typeable a => Maybe Int -> (a -> Bool) -> [(Exp, a)] -> [(Exp, a)] -- | getEverything uses the 'global' values set with set* -- functions. getEverythingF is its filtered version getEverything :: Typeable a => Bool -> IO (Every a) -- | everything generates all the expressions that fit the inferred -- type, and their representations in the Exp form. It returns a -- stream of lists, which is equivalent to Spivey's Matrix data -- type, i.e., that contains expressions consisted of n primitive -- components at the n-th element (n = 1,2,...). everythingF is -- its filtered version everything :: (ProgramGenerator pg, Typeable a) => pg -> Bool -> Every a everythingM :: (ProgramGenerator pg, Typeable a, Monad m, Functor m) => pg -> Bool -> Int -> m [(Exp, a)] everythingIO :: (ProgramGeneratorIO pg, Typeable a) => pg -> EveryIO a -- | Those functions are like everything, but take Type as an -- argument, which may be polymorphic. For example, printQ -- ([t| forall a. a->a->a |] >>= return . unifyable -- True 10 memo) will print all the expressions using memo -- whose types unify with forall a. a->a->a. (At first I -- (Susumu) could not find usefulness in finding unifyable expressions, -- but seemingly Hoogle does something alike, and these functions might -- enhance it.) unifyable :: ProgramGenerator pg => pg -> Type -> [[Exp]] -- | Those functions are like everything, but take Type as an -- argument, which may be polymorphic. For example, printQ -- ([t| forall a. a->a->a |] >>= return . unifyable -- True 10 memo) will print all the expressions using memo -- whose types unify with forall a. a->a->a. (At first I -- (Susumu) could not find usefulness in finding unifyable expressions, -- but seemingly Hoogle does something alike, and these functions might -- enhance it.) matching :: ProgramGenerator pg => pg -> Type -> [[Exp]] getEverythingF :: Typeable a => Bool -> IO (Every a) -- | everything generates all the expressions that fit the inferred -- type, and their representations in the Exp form. It returns a -- stream of lists, which is equivalent to Spivey's Matrix data -- type, i.e., that contains expressions consisted of n primitive -- components at the n-th element (n = 1,2,...). everythingF is -- its filtered version everythingF :: (ProgramGenerator pg, Typeable a) => pg -> Bool -> Every a -- | Those functions are like everything, but take Type as an -- argument, which may be polymorphic. For example, printQ -- ([t| forall a. a->a->a |] >>= return . unifyable -- True 10 memo) will print all the expressions using memo -- whose types unify with forall a. a->a->a. (At first I -- (Susumu) could not find usefulness in finding unifyable expressions, -- but seemingly Hoogle does something alike, and these functions might -- enhance it.) unifyableF :: ProgramGenerator pg => pg -> Type -> [[Exp]] -- | Those functions are like everything, but take Type as an -- argument, which may be polymorphic. For example, printQ -- ([t| forall a. a->a->a |] >>= return . unifyable -- True 10 memo) will print all the expressions using memo -- whose types unify with forall a. a->a->a. (At first I -- (Susumu) could not find usefulness in finding unifyable expressions, -- but seemingly Hoogle does something alike, and these functions might -- enhance it.) matchingF :: ProgramGenerator pg => pg -> Type -> [[Exp]] everyACE :: (ProgramGenerator pg, Typeable a) => pg -> Bool -> [[(CoreExpr, a)]] everyF :: (Typeable a, Filtrable a) => Opt b -> [[(e, a)]] -> [[(e, a)]] stripEvery :: Every a -> a -- | pprs pretty prints the results to the console, using -- pprintUC pprs :: Every a -> IO () -- | pprsIO is the EveryIO version of pprs pprsIO :: EveryIO a -> IO () -- | pprsIOn depth eio is the counterpart of pprs (take depth -- eio), while pprsIO eio is the counterpart of pprs -- eio. Example: pprsIOn 5 (everythingIO (mlist::ProgGen) :: -- EveryIO ([Char]->[Char])) pprsIOn :: Int -> EveryIO a -> IO () lengths :: Every a -> IO () lengthsIO :: EveryIO a -> IO () lengthsIOn :: Int -> EveryIO a -> IO () lengthsIOnLn :: Int -> EveryIO a -> IO () printQ :: (Ppr a, Data a) => Q a -> IO () type Primitive = (HValue, Exp, Type) newtype HValue HV :: (forall a. a) -> HValue -- | The function unsafeCoerce# allows you to side-step the -- typechecker entirely. That is, it allows you to coerce any type into -- any other type. If you use this function, you had better get it right, -- otherwise segmentation faults await. It is generally used when you -- want to write a program that you know is well-typed, but where -- Haskell's type system is not expressive enough to prove that it is -- well typed. -- -- The following uses of unsafeCoerce# are supposed to work -- (i.e. not lead to spurious compile-time or run-time crashes): -- --
-- >>> putStrLn $ pprint $ get1 $(c [d| f [] = 0; f [a] = 1; f [a,b] = 2 |]) noBK -- > \a -> let fa (b@([])) = 0 -- > fa (b@(_ : d)) = succ (fa d) -- > in fa a --get1 :: SplicedPrims -> SplicedPrims -> Exp -- | getMany does what you expect from its name. getMany :: SplicedPrims -> SplicedPrims -> [[Exp]] getManyM :: (Search m) => SplicedPrims -> SplicedPrims -> m Exp -- | getManyTyped is a variant of getMany that generates typed -- expressions. This alone is not very useful, but the type info is -- required when compiling the expression and is used in -- MagicHaskeller.RunAnalytical. getManyTyped :: SplicedPrims -> SplicedPrims -> [[Exp]] noBK :: SplicedPrims -- | Also, $(c [d| ... |]) :: SplicedPrims c is a helper -- function for extracting some info from the quoted declarations. c :: Q [Dec] -> ExpQ type SplicedPrims = ([Dec], [Primitive]) -- | Example: -- --
-- >>> runQ [d| f [] = 0; f [a] = 1; f [a,b] = 2 |] >>= \iops -> putStrLn $ pprint $ getOne iops [] -- > \a -> let fa (b@([])) = 0 -- > fa (b@(_ : d)) = succ (fa d) -- > in fa a --getOne :: [Dec] -> [Dec] -> Exp synth :: [Dec] -> [Dec] -> [[Exp]] synthM :: Search m => [Dec] -> [Dec] -> m Exp -- | synthTyped is like synth, but adds the infered type signature -- to each expression. This is useful for executing the expression at -- runtime using GHC API. synthTyped :: [Dec] -> [Dec] -> [[Exp]] module MagicHaskeller.RunAnalytical -- | Example of quickStart -- --
-- >>> quickStart [d| f [] = 0; f [a] = 1 |] noBKQ (\f -> f "12345" == 5) -- > \a -> let fa (b@([])) = 0 -- > fa (b@(c : d)) = succ (fa d) -- > in fa a :: forall t2 . [t2] -> Int -- > ^CInterrupted. --quickStart :: (Typeable a) => Q [Dec] -> Q [Dec] -> (a -> Bool) -> IO () quickStartF :: (Filtrable a, Typeable a) => Q [Dec] -> Q [Dec] -> (a -> Bool) -> IO () filterGetOne_ :: Typeable * a => HscEnv -> Q [Dec] -> (a -> Bool) -> IO () filterGetOne :: (Typeable a) => HscEnv -> Q [Dec] -> (a -> Bool) -> IO (Every a) filterGetOneBK :: (Typeable a) => HscEnv -> Q [Dec] -> Q [Dec] -> (a -> Bool) -> IO (Every a) synthFilt :: (Typeable a) => HscEnv -> Q [Dec] -> Q [Dec] -> (a -> Bool) -> IO (Every a) synthFiltF :: (Filtrable a, Typeable a) => HscEnv -> Q [Dec] -> Q [Dec] -> (a -> Bool) -> IO (Every a) synthAll :: (Typeable a) => HscEnv -> Q [Dec] -> Q [Dec] -> IO (Every a) noBKQ :: Q [Dec]