free-foil-0.4.0: Efficient Type-Safe Capture-Avoiding Substitution for Free (Scoped Monads)
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Free.Foil.Binary

Description

Binary instances for the scope-safe syntax: the wire view of a term is the term itself, raw ids and all.

The instances are deliberately orphans in a module of their own, so that they are opt-in: importing this module is what brings them into scope, and nothing else in the library does. (The dependency this costs is binary, a GHC boot library.)

Note that decoding mints scope evidence: a Name comes back at whatever scope index the context asks for, and the existential scope under a binder is chosen arbitrarily. Thus the instances are a trust boundary, in the sense of checkExtScope. The bytes are meaningful only under the discipline of the layer that wrote them, and that layer is expected to validate what it can on the way in. In particular, it should resolve the references it made world-independent, and check that the names it left verbatim lie where its allocation policy says. Control.Monad.Free.Foil.Artifact supplies those checks.

Orphan instances

Binary NameRange Source #

The two bounds. A range carries no scope index, so nothing is minted: this instance is layout metadata for the serialising layer.

Instance details

Binary (Name n) Source #

The raw id and nothing else. See the module documentation for what decoding trusts.

Instance details

Methods

put :: Name n -> Put #

get :: Get (Name n) #

putList :: [Name n] -> Put #

Binary (NameBinder n l) Source #

See the Binary instance of Name.

Instance details

Methods

put :: NameBinder n l -> Put #

get :: Get (NameBinder n l) #

putList :: [NameBinder n l] -> Put #

(forall (x :: S) (y :: S). Binary (binder x y), forall scope term. (Binary scope, Binary term) => Binary (sig scope term)) => Binary (AST binder sig n) Source #

A tag byte, then the name or the node.

Instance details

Methods

put :: AST binder sig n -> Put #

get :: Get (AST binder sig n) #

putList :: [AST binder sig n] -> Put #

(forall (x :: S) (y :: S). Binary (binder x y), forall (l :: S). Binary (AST binder sig l)) => Binary (ScopedAST binder sig n) Source #

The binder and the body, one after the other. Decoding mints the scope under the binder. See the module documentation.

Instance details

Methods

put :: ScopedAST binder sig n -> Put #

get :: Get (ScopedAST binder sig n) #

putList :: [ScopedAST binder sig n] -> Put #