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

Copyright | (c) 2011-2013 Toralf Wittner
License | MIT
Maintainer | Toralf Wittner <tw@dtex.org>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe-Inferred
Language | Haskell98

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

- data Restricted r v
- class Restriction r v where
  - toRestricted :: v -> Maybe (Restricted r v)
  - restrict :: v -> Restricted r v
- rvalue :: Restricted r v -> v
- data Nneg1
- data N1
- data N0
- data N254
- data Inf
- data Div4
- data Div5

# Documentation

data Restricted r v Source #

Type level restriction.

#### Instances

Instances details

Show v => Show (Restricted r v) Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> Restricted r v -> ShowS Source # show :: Restricted r v -> String Source # showList :: [Restricted r v] -> ShowS Source #

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.

#### Instances

Instances details

Restriction Div4 ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted Div4 ByteString) Source # restrict :: ByteString -> Restricted Div4 ByteString Source #
Restriction Div5 ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted Div5 ByteString) Source # restrict :: ByteString -> Restricted Div5 ByteString Source #
Integral a => Restriction (N0, Int32) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Int32) a) Source # restrict :: a -> Restricted (N0, Int32) a Source #
Integral a => Restriction (N0, Int64) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Int64) a) Source # restrict :: a -> Restricted (N0, Int64) a Source #
Integral a => Restriction (N0, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Inf) a) Source # restrict :: a -> Restricted (N0, Inf) a Source #
Restriction (N0, N254) ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted (N0, N254) ByteString) Source # restrict :: ByteString -> Restricted (N0, N254) ByteString Source #
Integral a => Restriction (N1, Int32) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Int32) a) Source # restrict :: a -> Restricted (N1, Int32) a Source #
Integral a => Restriction (N1, Int64) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Int64) a) Source # restrict :: a -> Restricted (N1, Int64) a Source #
Integral a => Restriction (N1, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Inf) a) Source # restrict :: a -> Restricted (N1, Inf) a Source #
Restriction (N1, N254) ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted (N1, N254) ByteString) Source # restrict :: ByteString -> Restricted (N1, N254) ByteString Source #
Restriction (N1, N254) String Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: String -> Maybe (Restricted (N1, N254) String) Source # restrict :: String -> Restricted (N1, N254) String Source #
Integral a => Restriction (Nneg1, Int32) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Int32) a) Source # restrict :: a -> Restricted (Nneg1, Int32) a Source #
Integral a => Restriction (Nneg1, Int64) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Int64) a) Source # restrict :: a -> Restricted (Nneg1, Int64) a Source #
Integral a => Restriction (Nneg1, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Inf) a) Source # restrict :: a -> Restricted (Nneg1, Inf) a Source #

rvalue :: Restricted r v -> v Source #

Get the actual value.

data Nneg1 Source #

type level -1

#### Instances

Instances details

Show Nneg1 Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> Nneg1 -> ShowS Source # show :: Nneg1 -> String Source # showList :: [Nneg1] -> ShowS Source #
Integral a => Restriction (Nneg1, Int32) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Int32) a) Source # restrict :: a -> Restricted (Nneg1, Int32) a Source #
Integral a => Restriction (Nneg1, Int64) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Int64) a) Source # restrict :: a -> Restricted (Nneg1, Int64) a Source #
Integral a => Restriction (Nneg1, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Inf) a) Source # restrict :: a -> Restricted (Nneg1, Inf) a Source #

data N1 Source #

type-level 1

#### Instances

Instances details

Show N1 Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> N1 -> ShowS Source # show :: N1 -> String Source # showList :: [N1] -> ShowS Source #
Integral a => Restriction (N1, Int32) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Int32) a) Source # restrict :: a -> Restricted (N1, Int32) a Source #
Integral a => Restriction (N1, Int64) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Int64) a) Source # restrict :: a -> Restricted (N1, Int64) a Source #
Integral a => Restriction (N1, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Inf) a) Source # restrict :: a -> Restricted (N1, Inf) a Source #
Restriction (N1, N254) ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted (N1, N254) ByteString) Source # restrict :: ByteString -> Restricted (N1, N254) ByteString Source #
Restriction (N1, N254) String Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: String -> Maybe (Restricted (N1, N254) String) Source # restrict :: String -> Restricted (N1, N254) String Source #

data N0 Source #

type-level 0

#### Instances

Instances details

Show N0 Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> N0 -> ShowS Source # show :: N0 -> String Source # showList :: [N0] -> ShowS Source #
Integral a => Restriction (N0, Int32) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Int32) a) Source # restrict :: a -> Restricted (N0, Int32) a Source #
Integral a => Restriction (N0, Int64) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Int64) a) Source # restrict :: a -> Restricted (N0, Int64) a Source #
Integral a => Restriction (N0, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Inf) a) Source # restrict :: a -> Restricted (N0, Inf) a Source #
Restriction (N0, N254) ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted (N0, N254) ByteString) Source # restrict :: ByteString -> Restricted (N0, N254) ByteString Source #

data N254 Source #

type-level 254

#### Instances

Instances details

Show N254 Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> N254 -> ShowS Source # show :: N254 -> String Source # showList :: [N254] -> ShowS Source #
Restriction (N0, N254) ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted (N0, N254) ByteString) Source # restrict :: ByteString -> Restricted (N0, N254) ByteString Source #
Restriction (N1, N254) ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted (N1, N254) ByteString) Source # restrict :: ByteString -> Restricted (N1, N254) ByteString Source #
Restriction (N1, N254) String Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: String -> Maybe (Restricted (N1, N254) String) Source # restrict :: String -> Restricted (N1, N254) String Source #

data Inf Source #

type-level infinity

#### Instances

Instances details

Show Inf Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> Inf -> ShowS Source # show :: Inf -> String Source # showList :: [Inf] -> ShowS Source #
Integral a => Restriction (N0, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N0, Inf) a) Source # restrict :: a -> Restricted (N0, Inf) a Source #
Integral a => Restriction (N1, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (N1, Inf) a) Source # restrict :: a -> Restricted (N1, Inf) a Source #
Integral a => Restriction (Nneg1, Inf) a Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: a -> Maybe (Restricted (Nneg1, Inf) a) Source # restrict :: a -> Restricted (Nneg1, Inf) a Source #

data Div4 Source #

divisable by 4

#### Instances

Instances details

Show Div4 Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> Div4 -> ShowS Source # show :: Div4 -> String Source # showList :: [Div4] -> ShowS Source #
Restriction Div4 ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted Div4 ByteString) Source # restrict :: ByteString -> Restricted Div4 ByteString Source #

data Div5 Source #

divisable by 5

#### Instances

Instances details

Show Div5 Source # |
Instance details Defined in Data.Restricted Methods showsPrec :: Int -> Div5 -> ShowS Source # show :: Div5 -> String Source # showList :: [Div5] -> ShowS Source #
Restriction Div5 ByteString Source # |
Instance details Defined in Data.Restricted Methods toRestricted :: ByteString -> Maybe (Restricted Div5 ByteString) Source # restrict :: ByteString -> Restricted Div5 ByteString Source #