syntax-tree-0.1.0.0: Typed ASTs

Safe HaskellSafe
LanguageHaskell2010

AST.Knot

Description

Knot is the Kind for nested higher-kinded data.

This library revolves around Knots, which enable encoding many rich recursive structures.

For more information see the README.

Synopsis

Documentation

newtype Knot Source #

A Kind for nested higher-kinded data.

Constructors

Knot (Knot -> Type) 
Instances
c (Const a :: Knot -> Type) => Recursively c (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Recursive

Methods

recursively :: Proxy (c (Const a)) -> Dict (c (Const a), KNodesConstraint (Const a) (Recursively c)) Source #

(InferOf a ~ InferOf b, Infer m a, Infer m b) => Infer m (Sum a b) Source # 
Instance details

Defined in AST.Class.Infer

Methods

inferBody :: Tree (Sum a b) (InferChild m k) -> m (Tree (Sum a b) k, Tree (InferOf (Sum a b)) (UVarOf m)) Source #

inferContext :: Proxy m -> Proxy (Sum a b) -> Dict (KNodesConstraint (Sum a b) (Infer m), KNodesConstraint (InferOf (Sum a b)) (Unify m)) Source #

KNodes (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Nodes

Associated Types

type KNodesConstraint (Const a) c :: Constraint Source #

data KWitness (Const a) a :: Type Source #

Methods

kLiftConstraint :: KNodesConstraint (Const a) c => KWitness (Const a) n -> Proxy c -> (c n -> r) -> r Source #

Monoid a => KPointed (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Pointed

Methods

pureK :: (forall (n :: Knot -> Type). KWitness (Const a) n -> Tree p n) -> Tree (Const a) p Source #

KFunctor (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Functor

Methods

mapK :: (forall (n :: Knot -> Type). KWitness (Const a) n -> Tree p n -> Tree q n) -> Tree (Const a) p -> Tree (Const a) q Source #

Semigroup a => KApply (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Apply

Methods

zipK :: Tree (Const a) p -> Tree (Const a) q -> Tree (Const a) (Product p q) Source #

KFoldable (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Foldable

Methods

foldMapK :: Monoid a0 => (forall (n :: Knot -> Type). KWitness (Const a) n -> Tree p n -> a0) -> Tree (Const a) p -> a0 Source #

KTraversable (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Traversable

Methods

sequenceK :: Applicative f => Tree (Const a) (ContainedK f p) -> f (Tree (Const a) p) Source #

Eq a => ZipMatch (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.ZipMatch

Methods

zipMatch :: Tree (Const a) p -> Tree (Const a) q -> Maybe (Tree (Const a) (Product p q)) Source #

RTraversable (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Recursive

RNodes (Const a :: Knot -> Type) Source # 
Instance details

Defined in AST.Class.Recursive

(KNodes a, KNodes b) => KNodes (Product a b) Source # 
Instance details

Defined in AST.Class.Nodes

Associated Types

type KNodesConstraint (Product a b) c :: Constraint Source #

data KWitness (Product a b) a :: Type Source #

Methods

kLiftConstraint :: KNodesConstraint (Product a b) c => KWitness (Product a b) n -> Proxy c -> (c n -> r) -> r Source #

(KNodes a, KNodes b) => KNodes (Sum a b) Source # 
Instance details

Defined in AST.Class.Nodes

Associated Types

type KNodesConstraint (Sum a b) c :: Constraint Source #

data KWitness (Sum a b) a :: Type Source #

Methods

kLiftConstraint :: KNodesConstraint (Sum a b) c => KWitness (Sum a b) n -> Proxy c -> (c n -> r) -> r Source #

(KPointed a, KPointed b) => KPointed (Product a b) Source # 
Instance details

Defined in AST.Class.Pointed

Methods

pureK :: (forall (n :: Knot -> Type). KWitness (Product a b) n -> Tree p n) -> Tree (Product a b) p Source #

(KFunctor a, KFunctor b) => KFunctor (Product a b) Source # 
Instance details

Defined in AST.Class.Functor

Methods

mapK :: (forall (n :: Knot -> Type). KWitness (Product a b) n -> Tree p n -> Tree q n) -> Tree (Product a b) p -> Tree (Product a b) q Source #

(KFunctor a, KFunctor b) => KFunctor (Sum a b) Source # 
Instance details

Defined in AST.Class.Functor

Methods

mapK :: (forall (n :: Knot -> Type). KWitness (Sum a b) n -> Tree p n -> Tree q n) -> Tree (Sum a b) p -> Tree (Sum a b) q Source #

(KApply a, KApply b) => KApply (Product a b) Source # 
Instance details

Defined in AST.Class.Apply

Methods

zipK :: Tree (Product a b) p -> Tree (Product a b) q -> Tree (Product a b) (Product p q) Source #

(KFoldable a, KFoldable b) => KFoldable (Product a b) Source # 
Instance details

Defined in AST.Class.Foldable

Methods

foldMapK :: Monoid a0 => (forall (n :: Knot -> Type). KWitness (Product a b) n -> Tree p n -> a0) -> Tree (Product a b) p -> a0 Source #

(KFoldable a, KFoldable b) => KFoldable (Sum a b) Source # 
Instance details

Defined in AST.Class.Foldable

Methods

foldMapK :: Monoid a0 => (forall (n :: Knot -> Type). KWitness (Sum a b) n -> Tree p n -> a0) -> Tree (Sum a b) p -> a0 Source #

(KTraversable a, KTraversable b) => KTraversable (Product a b) Source # 
Instance details

Defined in AST.Class.Traversable

Methods

sequenceK :: Applicative f => Tree (Product a b) (ContainedK f p) -> f (Tree (Product a b) p) Source #

(KTraversable a, KTraversable b) => KTraversable (Sum a b) Source # 
Instance details

Defined in AST.Class.Traversable

Methods

sequenceK :: Applicative f => Tree (Sum a b) (ContainedK f p) -> f (Tree (Sum a b) p) Source #

(ZipMatch a, ZipMatch b) => ZipMatch (Product a b) Source # 
Instance details

Defined in AST.Class.ZipMatch

Methods

zipMatch :: Tree (Product a b) p -> Tree (Product a b) q -> Maybe (Tree (Product a b) (Product p q)) Source #

(ZipMatch a, ZipMatch b) => ZipMatch (Sum a b) Source # 
Instance details

Defined in AST.Class.ZipMatch

Methods

zipMatch :: Tree (Sum a b) p -> Tree (Sum a b) q -> Maybe (Tree (Sum a b) (Product p q)) Source #

data KWitness (Const a :: Knot -> Type) i Source # 
Instance details

Defined in AST.Class.Nodes

data KWitness (Const a :: Knot -> Type) i
type KNodesConstraint (Const a :: Knot -> Type) x Source # 
Instance details

Defined in AST.Class.Nodes

type KNodesConstraint (Const a :: Knot -> Type) x = ()
data KWitness (Product a b) n Source # 
Instance details

Defined in AST.Class.Nodes

data KWitness (Sum a b) n Source # 
Instance details

Defined in AST.Class.Nodes

data KWitness (Sum a b) n
type InferOf (Sum a b) Source # 
Instance details

Defined in AST.Class.Infer

type InferOf (Sum a b) = InferOf a
type KNodesConstraint (Product a b) x Source # 
Instance details

Defined in AST.Class.Nodes

type KNodesConstraint (Sum a b) x Source # 
Instance details

Defined in AST.Class.Nodes

type family GetKnot k where ... Source #

A type-level getter for the type constructor encoded in Knot.

Notes:

  • If DataKinds supported lifting field getters this would had been replaced with the type's getter.
  • GetKnot is injective, but due to no support for constrained type families, that's not expressible at the moment.
  • Because GetKnot can't declared as bijective, uses of it may restrict inference. In those cases wrapping terms with the asTree helper assists Haskell's type inference as if Haskell knew that GetKnot was bijective.

Equations

GetKnot (Knot t) = t 

type Tree k p = (k (Knot p) :: Type) Source #

A type synonym to express nested-HKD structures

type (#) k p = Tree (GetKnot k) p Source #

A type synonym to express child nodes in nested-HKDs

asTree :: Tree k p -> Tree k p Source #

An id variant which tells the type checker that its argument is a Tree.

See the notes for GetKnot which expand on why this might be used.

Note that asTree may often be used during development to assist the inference of incomplete code, but removed once the code is complete.