MagicHaskeller-0.9.7.1: Automatic inductive functional programmer by systematic search
Safe HaskellNone
LanguageHaskell2010

MagicHaskeller.Analytical

Synopsis

Analytical synthesizer

This module provides with analytical synthesis, that only generates expressions without testing. (So this alone may not be very useful, and for this reason this is not very well-documented.) In order to generate-and-test over the result of this module, use MagicHaskeller.RunAnalytical.

Synthesizers which can be used with any types.

get1 Source #

Arguments

:: SplicedPrims

target function definition by example

-> SplicedPrims

background knowledge function definitions by example

-> Exp 

get1 can be used to synthesize one expression. For example,

>>> 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

getMany Source #

Arguments

:: SplicedPrims

target function definition by example

-> SplicedPrims

background knowledge function definitions by example

-> [[Exp]] 

getMany does what you expect from its name.

getManyM Source #

Arguments

:: Search m 
=> SplicedPrims

target function definition by example

-> SplicedPrims

background knowledge function definitions by example

-> m Exp 

getManyTyped Source #

Arguments

:: SplicedPrims

target function definition by example

-> SplicedPrims

background knowledge function definitions by example

-> [[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.

c :: Q [Dec] -> ExpQ Source #

Also, $(c [d| ... |]) :: SplicedPrims c is a helper function for extracting some info from the quoted declarations.

Synthesizers which are easier to use that can be used only with types appearing defaultPrimitives

getOne :: [Dec] -> [Dec] -> Exp Source #

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

synth :: [Dec] -> [Dec] -> [[Exp]] Source #

synthM :: Search m => [Dec] -> [Dec] -> m Exp Source #

synthTyped :: [Dec] -> [Dec] -> [[Exp]] Source #

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.