Safe Haskell | None |
---|---|
Language | Haskell2010 |
Backtracking which uses lists internally. The basic idea is to convert
each Stream
into a list. The consumer consumes the stream lazily, but
allows for fusion to happen. The hope is that this improves total
performance in those cases, where backtracking has significant costs.
- class BacktrackingProduct sigF sigB where
- makeBacktrackingProductInstance :: Name -> Q [Dec]
- getMonadName :: [TyVarBndr] -> Maybe Name
- getObjectiveNames :: [VarStrictType] -> Maybe (Name, Name, Name, Name)
- buildLeftType :: Name -> (Name, Name, Name) -> (Name, Name) -> [TyVarBndr] -> Type
- buildRightType :: Name -> (Name, Name, Name) -> (Name, Name, Name) -> [TyVarBndr] -> Type
- buildSigRType :: Name -> (Name, Name, Name) -> Name -> (Name, Name, Name) -> [TyVarBndr] -> Type
- genClauseBacktrack :: Name -> [VarStrictType] -> [VarStrictType] -> [VarStrictType] -> Q Clause
- genChoiceFunction :: Name -> Name -> VarStrictType -> Q (Name, Exp)
- genAttributeFunction :: [Name] -> Name -> Name -> VarStrictType -> Q (Name, Exp)
- recBuildLamPat :: [Name] -> Name -> Name -> [Name] -> Q ([Pat], Exp, Exp)
- buildRns :: Exp -> [Pat] -> ExpQ
- buildBacktrackingChoice :: Name -> Name -> Q Exp
- streamToVector :: Monad m => Stream m x -> m (Vector x)
- vectorToStream :: Monad m => Vector x -> Stream m x
- getRuleSynVarNames :: Type -> [Name]
Documentation
class BacktrackingProduct sigF sigB where Source
The type class of algebra products. We have the forward signature
sigF
and the backtracking signature sigB
. Combined via (<||)
we
have a new signature SigR
.
makeBacktrackingProductInstance :: Name -> Q [Dec] Source
getObjectiveNames :: [VarStrictType] -> Maybe (Name, Name, Name, Name) Source
Returns the Name
s of the objective function variables, as well as
the name of the objective function itself.
buildSigRType :: Name -> (Name, Name, Name) -> Name -> (Name, Name, Name) -> [TyVarBndr] -> Type Source
genClauseBacktrack :: Name -> [VarStrictType] -> [VarStrictType] -> [VarStrictType] -> Q Clause Source
genChoiceFunction :: Name -> Name -> VarStrictType -> Q (Name, Exp) Source
genAttributeFunction :: [Name] -> Name -> Name -> VarStrictType -> Q (Name, Exp) Source
TODO need fun names from l
and r
buildRns :: Exp -> [Pat] -> ExpQ Source
NOTE
[ f x | x <- xs ] CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))]
buildBacktrackingChoice :: Name -> Name -> Q Exp Source
Build up the backtracking choice function. This choice function will backtrack based on the first result, then return only the second.
TODO it should be (only?) this function we will need to modify to build all algebra products.
ysM
can't be unboxed, as snd
of each element is a list, lazily
consumed. We build up ysM
as this makes fusion happen. Of course, this
is a boxed vector and not as efficient, but we gain the ability to have
lazily created backtracking from this!
This means strict optimization AND lazy backtracking
streamToVector :: Monad m => Stream m x -> m (Vector x) Source
Transform a monadic stream monadically into a vector.
vectorToStream :: Monad m => Vector x -> Stream m x Source
Transform a vector into a monadic stream.
getRuleSynVarNames :: Type -> [Name] Source
Gets the names used in the evaluation function. This returns one
Name
for each variable.
In case of TupleT 0
the type is ()
and there isn't a name to go with
it. We just mkName "()"
a name, but this might be slightly dangerous?
(Not really sure if it indeed is)
With AppT _ _
we have a multidim terminal and produce another hackish
name to be consumed above.
AppT (AppT ArrowT (AppT (AppT (ConT Data.Array.Repa.Index.:.) (AppT (AppT (ConT Data.Array.Repa.Index.:.) (ConT Data.Array.Repa.Index.Z)) (VarT c_1627675270))) (VarT c_1627675270))) (VarT x_1627675265)