text-postgresql-0.0.3.1: Parser and Printer of PostgreSQL extended types

Copyright | 2015-2018 Kei Hibino
License | BSD3
Maintainer | ex8k.hibino@gmail.com
Stability | experimental
Portability | unknown
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.PostgreSQL.NetworkAddress

Contents

- Definitions about inet and cidr types
- Definitions about the address type which is the pair of host-address and mask
- Definitions about the host-address types

Description

This module defines network-address types of PostgreSQL. http://www.postgresql.org/docs/current/static/datatype-net-types.html

Synopsis

- newtype Inet = Inet NetAddress
- newtype Cidr = Cidr NetAddress
- cidr4 :: V4HostAddress -> Word8 -> Maybe Cidr
- cidr4' :: V4HostAddress -> Word8 -> Maybe Cidr
- cidr6 :: V6HostAddress -> Word8 -> Maybe Cidr
- cidr6' :: V6HostAddress -> Word8 -> Maybe Cidr
- data NetAddress
  - = NetAddress4 !V4HostAddress !Word8
  - | NetAddress6 !V6HostAddress !Word8
- netAddress4 :: V4HostAddress -> Word8 -> Maybe NetAddress
- netAddress6 :: V6HostAddress -> Word8 -> Maybe NetAddress
- data V4HostAddress = V4HostAddress !Word8 !Word8 !Word8 !Word8
- v4HostAddressOctets :: V4HostAddress -> (Word8, Word8, Word8, Word8)
- data V6HostAddress = V6HostAddress !Word16 !Word16 !Word16 !Word16 !Word16 !Word16 !Word16 !Word16
- v6HostAddressLong :: Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> V6HostAddress
- v6HostAddressWords :: V6HostAddress -> (Word16, Word16, Word16, Word16, Word16, Word16, Word16, Word16)
- v6HostAddress :: [Word16] -> [Word16] -> Maybe V6HostAddress
- v6HostAddressL :: [Word16] -> Maybe V6HostAddress
- v6HostAddressR :: [Word16] -> Maybe V6HostAddress

# Definitions about inet and cidr types

newtype Inet Source #

Corresponding to INET type of PostgreSQL

Constructors

Inet NetAddress |

#### Instances

Instances details

Read Inet Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods readsPrec :: Int -> ReadS Inet Source # readList :: ReadS [Inet] Source # readPrec :: ReadPrec Inet Source # readListPrec :: ReadPrec [Inet] Source #
Show Inet Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods showsPrec :: Int -> Inet -> ShowS Source # show :: Inet -> String Source # showList :: [Inet] -> ShowS Source #
Eq Inet Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods (==) :: Inet -> Inet -> Bool Source # (/=) :: Inet -> Inet -> Bool Source #
Ord Inet Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods compare :: Inet -> Inet -> Ordering Source # (<) :: Inet -> Inet -> Bool Source # (<=) :: Inet -> Inet -> Bool Source # (>) :: Inet -> Inet -> Bool Source # (>=) :: Inet -> Inet -> Bool Source # max :: Inet -> Inet -> Inet Source # min :: Inet -> Inet -> Inet Source #

newtype Cidr Source #

Corresponding to CIDR type of PostgreSQL

Constructors

Cidr NetAddress |

#### Instances

Instances details

Read Cidr Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods readsPrec :: Int -> ReadS Cidr Source # readList :: ReadS [Cidr] Source # readPrec :: ReadPrec Cidr Source # readListPrec :: ReadPrec [Cidr] Source #
Show Cidr Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods showsPrec :: Int -> Cidr -> ShowS Source # show :: Cidr -> String Source # showList :: [Cidr] -> ShowS Source #
Eq Cidr Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods (==) :: Cidr -> Cidr -> Bool Source # (/=) :: Cidr -> Cidr -> Bool Source #
Ord Cidr Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods compare :: Cidr -> Cidr -> Ordering Source # (<) :: Cidr -> Cidr -> Bool Source # (<=) :: Cidr -> Cidr -> Bool Source # (>) :: Cidr -> Cidr -> Bool Source # (>=) :: Cidr -> Cidr -> Bool Source # max :: Cidr -> Cidr -> Cidr Source # min :: Cidr -> Cidr -> Cidr Source #

cidr4 :: V4HostAddress -> Word8 -> Maybe Cidr Source #

Make Cidr type of IPv4 from host-address bits consistent with mask

cidr4' :: V4HostAddress -> Word8 -> Maybe Cidr Source #

Same as cidr4 except for dropping host-address bits along with mask

cidr6 :: V6HostAddress -> Word8 -> Maybe Cidr Source #

Make Cidr type of IPv6 from host-address bits consistent with mask

cidr6' :: V6HostAddress -> Word8 -> Maybe Cidr Source #

Same as cidr6 except for dropping host-address bits along with mask

# Definitions about the address type which is the pair of host-address and mask

data NetAddress Source #

IPv4 or IPv6 netword address corresponding host-addr/mask. eg. '192.168.0.1/24'

Constructors

NetAddress4 !V4HostAddress !Word8 |
NetAddress6 !V6HostAddress !Word8 |

#### Instances

Instances details

Read NetAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods readsPrec :: Int -> ReadS NetAddress Source # readList :: ReadS [NetAddress] Source # readPrec :: ReadPrec NetAddress Source # readListPrec :: ReadPrec [NetAddress] Source #
Show NetAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods showsPrec :: Int -> NetAddress -> ShowS Source # show :: NetAddress -> String Source # showList :: [NetAddress] -> ShowS Source #
Eq NetAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods (==) :: NetAddress -> NetAddress -> Bool Source # (/=) :: NetAddress -> NetAddress -> Bool Source #
Ord NetAddress Source # |

Instance details

Defined in Data.PostgreSQL.NetworkAddress

Methods

compare :: NetAddress -> NetAddress -> Ordering Source #

(<) :: NetAddress -> NetAddress -> Bool Source #

(<=) :: NetAddress -> NetAddress -> Bool Source #

(>) :: NetAddress -> NetAddress -> Bool Source #

(>=) :: NetAddress -> NetAddress -> Bool Source #

max :: NetAddress -> NetAddress -> NetAddress Source #

min :: NetAddress -> NetAddress -> NetAddress Source #

netAddress4 Source #

Arguments

:: V4HostAddress | IPv4 host-address
-> Word8 | IPv4 mask 0-32
-> Maybe NetAddress | result NetAddress

Make IPv4 NetAddress type consistent with IPv4 mask

netAddress6 Source #

Arguments

:: V6HostAddress | IPv6 host-address
-> Word8 | IPv6 mask 0-128
-> Maybe NetAddress | result NetAddress

Make IPv6 NetAddress type consistent with IPv6 mask

# Definitions about the host-address types

data V4HostAddress Source #

Host address type along with IPv4 address bytes with IPv4 string order.

Constructors

V4HostAddress !Word8 !Word8 !Word8 !Word8 |

#### Instances

Instances details

Read V4HostAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods readsPrec :: Int -> ReadS V4HostAddress Source # readList :: ReadS [V4HostAddress] Source # readPrec :: ReadPrec V4HostAddress Source # readListPrec :: ReadPrec [V4HostAddress] Source #
Show V4HostAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods showsPrec :: Int -> V4HostAddress -> ShowS Source # show :: V4HostAddress -> String Source # showList :: [V4HostAddress] -> ShowS Source #
Eq V4HostAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods (==) :: V4HostAddress -> V4HostAddress -> Bool Source # (/=) :: V4HostAddress -> V4HostAddress -> Bool Source #
Ord V4HostAddress Source # |

Instance details

Defined in Data.PostgreSQL.NetworkAddress

Methods

compare :: V4HostAddress -> V4HostAddress -> Ordering Source #

(<) :: V4HostAddress -> V4HostAddress -> Bool Source #

(<=) :: V4HostAddress -> V4HostAddress -> Bool Source #

(>) :: V4HostAddress -> V4HostAddress -> Bool Source #

(>=) :: V4HostAddress -> V4HostAddress -> Bool Source #

max :: V4HostAddress -> V4HostAddress -> V4HostAddress Source #

min :: V4HostAddress -> V4HostAddress -> V4HostAddress Source #

v4HostAddressOctets :: V4HostAddress -> (Word8, Word8, Word8, Word8) Source #

data V6HostAddress Source #

Host address type along with IPv6 address words with IPv6 string order. Each `Word16` value is host byte order. Host byte order is portable in programs on its own host. Network byte order is only needed, when communicating other hosts.

Constructors

V6HostAddress !Word16 !Word16 !Word16 !Word16 !Word16 !Word16 !Word16 !Word16 |

#### Instances

Instances details

Read V6HostAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods readsPrec :: Int -> ReadS V6HostAddress Source # readList :: ReadS [V6HostAddress] Source # readPrec :: ReadPrec V6HostAddress Source # readListPrec :: ReadPrec [V6HostAddress] Source #
Show V6HostAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods showsPrec :: Int -> V6HostAddress -> ShowS Source # show :: V6HostAddress -> String Source # showList :: [V6HostAddress] -> ShowS Source #
Eq V6HostAddress Source # |
Instance details Defined in Data.PostgreSQL.NetworkAddress Methods (==) :: V6HostAddress -> V6HostAddress -> Bool Source # (/=) :: V6HostAddress -> V6HostAddress -> Bool Source #
Ord V6HostAddress Source # |

Instance details

Defined in Data.PostgreSQL.NetworkAddress

Methods

compare :: V6HostAddress -> V6HostAddress -> Ordering Source #

(<) :: V6HostAddress -> V6HostAddress -> Bool Source #

(<=) :: V6HostAddress -> V6HostAddress -> Bool Source #

(>) :: V6HostAddress -> V6HostAddress -> Bool Source #

(>=) :: V6HostAddress -> V6HostAddress -> Bool Source #

max :: V6HostAddress -> V6HostAddress -> V6HostAddress Source #

min :: V6HostAddress -> V6HostAddress -> V6HostAddress Source #

v6HostAddressLong :: Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> Word16 -> V6HostAddress Source #

v6HostAddressWords :: V6HostAddress -> (Word16, Word16, Word16, Word16, Word16, Word16, Word16, Word16) Source #

v6HostAddress :: [Word16] -> [Word16] -> Maybe V6HostAddress Source #

v6HostAddressL :: [Word16] -> Maybe V6HostAddress Source #

v6HostAddressR :: [Word16] -> Maybe V6HostAddress Source #