Safe Haskell | None |
---|---|
Language | Haskell2010 |
Deep representation for SRep
Synopsis
- data HolesAnn kappa fam ann h a where
- type SFix kappa fam = HolesAnn kappa fam U1 V1
- pattern SFix :: () => CompoundCnstr kappa fam a => SRep (SFix kappa fam) (Rep a) -> SFix kappa fam a
- pattern Prim :: () => PrimCnstr kappa fam a => a -> Holes kappa fam h a
- type SFixAnn kappa fam ann = HolesAnn kappa fam ann V1
- pattern SFixAnn :: () => CompoundCnstr kappa fam a => ann a -> SRep (SFixAnn kappa fam ann) (Rep a) -> SFixAnn kappa fam ann a
- pattern PrimAnn :: () => PrimCnstr kappa fam a => ann a -> a -> SFixAnn kappa fam ann a
- type Holes kappa fam = HolesAnn kappa fam U1
- pattern Roll :: () => CompoundCnstr kappa fam a => SRep (Holes kappa fam h) (Rep a) -> Holes kappa fam h a
- pattern Hole :: h a -> Holes kappa fam h a
- type CompoundCnstr kappa fam a = (Elem a fam, NotElem a kappa, Generic a)
- type PrimCnstr kappa fam b = (Elem b kappa, NotElem b fam)
- holesToSFix :: Holes kappa fam V1 at -> SFix kappa fam at
- sfixToHoles :: SFix kappa fam at -> Holes kappa fam h at
- holesMapAnn :: (forall x. f x -> g x) -> (forall x. ann x -> phi x) -> HolesAnn kappa fam ann f a -> HolesAnn kappa fam phi g a
- holesMap :: (forall x. f x -> g x) -> HolesAnn kappa fam ann f a -> HolesAnn kappa fam ann g a
- holesMapM :: Monad m => (forall x. f x -> m (g x)) -> HolesAnn kappa fam ann f a -> m (HolesAnn kappa fam ann g a)
- holesMapAnnM :: Monad m => (forall x. f x -> m (g x)) -> (forall x. ann x -> m (psi x)) -> HolesAnn kappa fam ann f a -> m (HolesAnn kappa fam psi g a)
- getAnn :: HolesAnn kappa fam ann h a -> ann a
- holesJoin :: HolesAnn kappa fam ann (HolesAnn kappa fam ann f) a -> HolesAnn kappa fam ann f a
- holesSize :: HolesAnn kappa fam ann h a -> Int
- holesHolesList :: HolesAnn kappa fam ann f a -> [Exists f]
- holesRefineM :: Monad m => (forall b. f b -> m (Holes kappa fam g b)) -> (forall b. PrimCnstr kappa fam b => b -> m (Holes kappa fam g b)) -> Holes kappa fam f a -> m (Holes kappa fam g a)
- holesRefineHoles :: (forall b. f b -> Holes kappa fam g b) -> Holes kappa fam f a -> Holes kappa fam g a
- holesRefineHolesM :: Monad m => (forall b. f b -> m (Holes kappa fam g b)) -> Holes kappa fam f a -> m (Holes kappa fam g a)
- synthesize :: (forall b. CompoundCnstr kappa fam b => ann b -> SRep phi (Rep b) -> phi b) -> (forall b. PrimCnstr kappa fam b => ann b -> b -> phi b) -> (forall b. ann b -> h b -> phi b) -> HolesAnn kappa fam ann h a -> HolesAnn kappa fam phi h a
- synthesizeM :: Monad m => (forall b. CompoundCnstr kappa fam b => ann b -> SRep phi (Rep b) -> m (phi b)) -> (forall b. PrimCnstr kappa fam b => ann b -> b -> m (phi b)) -> (forall b. ann b -> h b -> m (phi b)) -> HolesAnn kappa fam ann h a -> m (HolesAnn kappa fam phi h a)
- cataM :: Monad m => (forall b. CompoundCnstr kappa fam b => ann b -> SRep phi (Rep b) -> m (phi b)) -> (forall b. PrimCnstr kappa fam b => ann b -> b -> m (phi b)) -> (forall b. ann b -> h b -> m (phi b)) -> HolesAnn kappa fam ann h a -> m (phi a)
- lgg :: forall kappa fam h i a. All Eq kappa => Holes kappa fam h a -> Holes kappa fam i a -> Holes kappa fam (Holes kappa fam h :*: Holes kappa fam i) a
- class CompoundCnstr kappa fam a => Deep kappa fam a where
- class GDeep kappa fam f where
(Co)Free (Co)Monad and its cousins
data HolesAnn kappa fam ann h a where Source #
The cofree comonad and free monad on the same type; this allows us to use the same recursion operator for everything.
Hole' | |
| |
Prim' | |
Roll' | |
|
type SFix kappa fam = HolesAnn kappa fam U1 V1 Source #
Deep representations are easily achieved by forbiding
the Hole'
constructor and providing unit annotations.
pattern SFix :: () => CompoundCnstr kappa fam a => SRep (SFix kappa fam) (Rep a) -> SFix kappa fam a Source #
pattern SFixAnn :: () => CompoundCnstr kappa fam a => ann a -> SRep (SFixAnn kappa fam ann) (Rep a) -> SFixAnn kappa fam ann a Source #
pattern Roll :: () => CompoundCnstr kappa fam a => SRep (Holes kappa fam h) (Rep a) -> Holes kappa fam h a Source #
Constraints
Coercions
sfixToHoles :: SFix kappa fam at -> Holes kappa fam h at Source #
Maps, zips and folds
holesMapAnn :: (forall x. f x -> g x) -> (forall x. ann x -> phi x) -> HolesAnn kappa fam ann f a -> HolesAnn kappa fam phi g a Source #
Maps over holes and annotations in a HolesAnn
holesMap :: (forall x. f x -> g x) -> HolesAnn kappa fam ann f a -> HolesAnn kappa fam ann g a Source #
Maps over the holes in a HolesAnn
holesMapM :: Monad m => (forall x. f x -> m (g x)) -> HolesAnn kappa fam ann f a -> m (HolesAnn kappa fam ann g a) Source #
Maps over HolesAnn
maintaining annotations intact.
:: Monad m | |
=> (forall x. f x -> m (g x)) | Function to transform holes |
-> (forall x. ann x -> m (psi x)) | Function to transform annotations |
-> HolesAnn kappa fam ann f a | |
-> m (HolesAnn kappa fam psi g a) |
Maps over a HolesAnn
treating annotations and holes
independently.
getAnn :: HolesAnn kappa fam ann h a -> ann a Source #
Retrieves the annotation inside a HolesAnn
;
this is the counit of the comonad.
holesJoin :: HolesAnn kappa fam ann (HolesAnn kappa fam ann f) a -> HolesAnn kappa fam ann f a Source #
Monadic multiplication
holesHolesList :: HolesAnn kappa fam ann f a -> [Exists f] Source #
Computes the list of holes in a HolesAnn
holesRefineM :: Monad m => (forall b. f b -> m (Holes kappa fam g b)) -> (forall b. PrimCnstr kappa fam b => b -> m (Holes kappa fam g b)) -> Holes kappa fam f a -> m (Holes kappa fam g a) Source #
Refine holes and primitives
holesRefineHoles :: (forall b. f b -> Holes kappa fam g b) -> Holes kappa fam f a -> Holes kappa fam g a Source #
Refine holes with a simple action
holesRefineHolesM :: Monad m => (forall b. f b -> m (Holes kappa fam g b)) -> Holes kappa fam f a -> m (Holes kappa fam g a) Source #
Refines holes using a monadic action
synthesize :: (forall b. CompoundCnstr kappa fam b => ann b -> SRep phi (Rep b) -> phi b) -> (forall b. PrimCnstr kappa fam b => ann b -> b -> phi b) -> (forall b. ann b -> h b -> phi b) -> HolesAnn kappa fam ann h a -> HolesAnn kappa fam phi h a Source #
Simpler version of synthesizeM
working over the Identity monad.
:: Monad m | |
=> (forall b. CompoundCnstr kappa fam b => ann b -> SRep phi (Rep b) -> m (phi b)) | How to handle recursion |
-> (forall b. PrimCnstr kappa fam b => ann b -> b -> m (phi b)) | How to handle primitives |
-> (forall b. ann b -> h b -> m (phi b)) | How to handle holes |
-> HolesAnn kappa fam ann h a | |
-> m (HolesAnn kappa fam phi h a) |
Synthetization of attributes
:: Monad m | |
=> (forall b. CompoundCnstr kappa fam b => ann b -> SRep phi (Rep b) -> m (phi b)) | How to handle recursion |
-> (forall b. PrimCnstr kappa fam b => ann b -> b -> m (phi b)) | How to handle primitivies |
-> (forall b. ann b -> h b -> m (phi b)) | How to handle holes |
-> HolesAnn kappa fam ann h a | |
-> m (phi a) |
Catamorphism over HolesAnn
Anti-Unification
lgg :: forall kappa fam h i a. All Eq kappa => Holes kappa fam h a -> Holes kappa fam i a -> Holes kappa fam (Holes kappa fam h :*: Holes kappa fam i) a Source #
Computes the least general generalization of two trees.
Conversion
class CompoundCnstr kappa fam a => Deep kappa fam a where Source #
Nothing
class GDeep kappa fam f where Source #
Instances
GDeep kappa fam (U1 :: k -> Type) Source # | |
(GDeep kappa fam f, GDeep kappa fam g) => GDeep kappa fam (f :+: g :: k -> Type) Source # | |
(GDeep kappa fam f, GDeep kappa fam g) => GDeep kappa fam (f :*: g :: k -> Type) Source # | |
GDeepAtom kappa fam (IsElem a kappa) a => GDeep kappa fam (K1 R a :: k -> Type) Source # | |
(GMeta i c, GDeep kappa fam f) => GDeep kappa fam (M1 i c f :: k -> Type) Source # | |