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
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
- rvalue :: Restricted r v -> v
- data Nneg1
- data N1
- data N0
- data N254
- data Inf
- data Div4
- data Div5

# Documentation

data Restricted r v #

Type level restriction.

Instances

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

class Restriction r v where #

A uniform way to restrict values.

Minimal complete definition

toRestricted, restrict

Methods

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

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

restrict :: v -> Restricted r v #

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

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

rvalue :: Restricted r v -> v #

Get the actual value.

data Nneg1 #

type level -1

Instances

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

data N1 #

type-level 1

Instances

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

data N0 #

type-level 0

Instances

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

data N254 #

type-level 254

Instances

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

data Inf #

type-level infinity

Instances

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

data Div4 #

divisable by 4

Instances

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

data Div5 #

divisable by 5

Instances

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