types

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package types declares the types and implements the algorithms for type inference for programs written using the asyncpi package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Infer

func Infer(p asyncpi.Process) error

func IsEqual

func IsEqual(t, u Type) bool

IsEqual compare types.

func ProcType

func ProcType(p asyncpi.Process) (string, error)

ProcType returns the process type of the Process p.

func Unify

func Unify(p asyncpi.Process) error

Unify combines the constraints of sending and receiving channels with best effort.

It is assumed that the names are already typed, and an error is returned if the typing constraints are in conflict and cannot be unified. A Process is well-typed if no error is returned.

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

Base represents a base (concrete) type. Base types are 'abstract' type only known by their name.

func NewBase

func NewBase(name string) *Base

NewBase returns a new base type for the given base type name.

func (*Base) String

func (b *Base) String() string

func (*Base) Underlying

func (b *Base) Underlying() Type

Underlying returns itself as the underlying type of b.

type Chan

type Chan struct {
	// contains filtered or unexported fields
}

Chan represents a channel type.

func NewChan

func NewChan(elem Type) *Chan

NewChan returns a new channel type for the given element type.

func (*Chan) Elem

func (c *Chan) Elem() Type

Elem returns the element type of channel c.

func (*Chan) String

func (c *Chan) String() string

func (*Chan) Underlying

func (c *Chan) Underlying() Type

Underlying returns itself as the underlying type of c.

type Composite

type Composite struct {
	// contains filtered or unexported fields
}

Composite represents a composite type of multiple types. The type is mainly used for representing polyadic parameters of a channel.

func NewComposite

func NewComposite(t ...Type) *Composite

NewComposite returns a new Composite type for the given types.

func (*Composite) Elems

func (c *Composite) Elems() []Type

Elems returns the element types of c.

func (*Composite) String

func (c *Composite) String() string

String returns a struct of the composed types.

func (*Composite) Underlying

func (c *Composite) Underlying() Type

Underlying returns itself as the underlying type of c.

type InferUntypedError

type InferUntypedError struct {
	Name string
}

InferUnTypedError is the type of error when type inference is applied on an untyped Process.

func (InferUntypedError) Error

func (e InferUntypedError) Error() string

type Reference

type Reference struct {
	// contains filtered or unexported fields
}

Reference is a reference to the type of a given Name.

func NewReference

func NewReference(n asyncpi.Name) *Reference

NewReference returns a new Name reference to the given Name.

func (*Reference) String

func (r *Reference) String() string

func (*Reference) Underlying

func (r *Reference) Underlying() Type

Underlying returns the type of the referenced Name as the underlying type of r.

type Type

type Type interface {
	// Underlying returns the underlying type of a type.
	Underlying() Type

	// String returns a string representation of a type.
	String() string
}

A Type represents a type in asyncpi. All types implement the Type interface.

type TypeArityError

type TypeArityError struct {
	Got      int
	Expected int
	Msg      string
}

TypeArityError is the type of error when process parameter arity does not match when unifying.

func (TypeArityError) Error

func (e TypeArityError) Error() string

type TypeError

type TypeError struct {
	T, U Type
	Msg  string
}

TypeError is the type of error when analysing the behavioural type of an asyncpi Process.

func (TypeError) Error

func (e TypeError) Error() string

type TypedName

type TypedName interface {
	// Name is the wrapped Name.
	asyncpi.Name

	// Type returns the type of the wrapped Name.
	Type() Type
	// contains filtered or unexported methods
}

TypedName is a typed wrapper for Name. A TypedName can be used as a Name.

func AttachType

func AttachType(n asyncpi.Name) TypedName

AttachType wraps the given n with types. The default type is unconstrained.

Notes

Bugs

  • Inference may fail if type of a name is recursively defined (e.g. a<a> → typed chan of type(a)), printing the type will cause a stack overflow.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL