zeromq4-haskell-0.5: Bindings to ZeroMQ 4.x

Copyright(c) 2011-2013 Toralf Wittner
LicenseMIT
MaintainerToralf Wittner <tw@dtex.org>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Restricted

Description

Type-level restricted data. This module allows for type declarations which embed certain restrictions, such as value bounds. E.g. Restricted N0 N1 Int denotes an Int which can only have values [0 .. 1]. When creating such a value, the constructor functions restrict or toRestricted ensure that the restrictions are obeyed. Code that consumes restricted types does not need to check the constraints.

N.B. This module is more or less tailored to be used within ZMQ3. Therefore the provided type level restrictions are limited.

Synopsis

Documentation

data Restricted r v Source

Type level restriction.

Instances

Show v => Show (Restricted r v) 

class Restriction r v where Source

A uniform way to restrict values.

Methods

toRestricted :: v -> Maybe (Restricted r v) Source

Create a restricted value. Returns Nothing if the given value does not satisfy all restrictions.

restrict :: v -> Restricted r v Source

Create a restricted value. If the given value does not satisfy the restrictions, a modified variant is used instead, e.g. if an integer is larger than the upper bound, the upper bound value is used.

rvalue :: Restricted r v -> v Source

Get the actual value.

data Nneg1 Source

type level -1

data N0 Source

type-level 0

Instances

data N254 Source

type-level 254

data Inf Source

type-level infinity

Instances

data Div4 Source

divisable by 4

data Div5 Source

divisable by 5