Skip to content

Commit d34ed45

Browse files
Restructure documentation: organize types by category and add function naming conventions
- Updated cabal file description with complete type listings organized by category - Organized exports in PostgresqlTypes module by category with section comments - Added comprehensive function naming convention documentation (normalizeFrom*, refineFrom*, to*) - Updated README to reference cabal file and module documentation for consistency - Maintained consistency across .cabal, README, and PostgresqlTypes module Co-authored-by: nikita-volkov <1560937+nikita-volkov@users.noreply.github.com>
1 parent cf911ed commit d34ed45

File tree

3 files changed

+307
-87
lines changed

3 files changed

+307
-87
lines changed

README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ Precise Haskell representations of PostgreSQL data types with mappings to and fr
99

1010
In active development, but already working and exhaustively tested.
1111

12+
## Documentation
13+
14+
For complete documentation including:
15+
- Full list of supported types organized by category
16+
- Function naming conventions (normalizeFrom*, refineFrom*, to*)
17+
- Type safety guarantees and valid ranges
18+
- Usage examples
19+
20+
Please refer to:
21+
- **[Package documentation on Hackage](https://hackage.haskell.org/package/postgresql-types)** - Complete API reference
22+
- **[Module documentation (PostgresqlTypes)](https://nikita-volkov.github.io/postgresql-types/PostgresqlTypes.html)** - Type listings and usage examples
23+
1224
## Key Features
1325

1426
### Ecosystem Integration
@@ -20,21 +32,24 @@ Adapter packages provide integrations for major PostgreSQL client libraries:
2032

2133
### Supported Types
2234

23-
This package provides support for nearly all PostgreSQL data types, including but not limited to:
24-
25-
- Numeric types: `Int2`, `Int4`, `Int8`, `Float4`, `Float8`, `Numeric`
26-
- Character types: `Char`, `Varchar`, `Text`
27-
- Boolean type: `Bool`
28-
- Date/time types: `Date`, `Time`, `Timestamp`, `Timestamptz`, `Interval`
29-
- Network address types: `Inet`, `Cidr`, `Macaddr`, `Macaddr8`
30-
- Geometric types: `Point`, `Line`, `Lseg`, `Box`, `Path`, `Polygon`, `Circle`
31-
- Bit string types: `Bit`, `Varbit`
32-
- UUID type: `Uuid`
33-
- JSON types: `Json`, `Jsonb`
34-
- Key-value types: `Hstore`
35-
- Range types: `Int4Range`, `Int8Range`, `NumRange`, `TsRange`, `TstzRange`, `DateRange`
36-
- Multirange types: `Int4Multirange`, `Int8Multirange`, `NumMultirange`, `TsMultirange`, `TstzMultirange`, `DateMultirange`
37-
- Array types for all of the above
35+
This package provides support for nearly all PostgreSQL data types, including:
36+
37+
- **Numeric types**: Int2, Int4, Int8, Float4, Float8, Numeric, Money, Oid
38+
- **Character types**: Char, Varchar, Text, Bpchar
39+
- **Boolean type**: Bool
40+
- **Binary data**: Bytea
41+
- **Date/time types**: Date, Time, Timestamp, Timestamptz, Timetz, Interval
42+
- **Network address types**: Inet, Cidr, Macaddr, Macaddr8
43+
- **Geometric types**: Point, Line, Lseg, Box, Path, Polygon, Circle
44+
- **Bit string types**: Bit, Varbit
45+
- **UUID type**: Uuid
46+
- **JSON types**: Json, Jsonb
47+
- **Key-value types**: Hstore
48+
- **Range types**: Range (supporting int4range, int8range, numrange, tsrange, tstzrange, daterange)
49+
- **Multirange types**: Multirange (supporting int4multirange, int8multirange, etc.)
50+
- **Array types** for all of the above
51+
52+
For detailed information about each type, see the [package documentation](https://hackage.haskell.org/package/postgresql-types).
3853

3954
### Type Safety & Valid Ranges
4055

@@ -44,10 +59,11 @@ Values can only be created through explicit constructor functions, guaranteeing
4459

4560
### Type-Safe Constructors
4661

47-
The library provides two types of constructors for each type:
62+
The library provides three types of functions for working with PostgreSQL types:
4863

4964
- **Normalizing constructors** (prefix: `normalizeFrom*`) - Always succeed by clamping or canonicalizing input values to valid ranges
5065
- **Refining constructors** (prefix: `refineFrom*`) - Return `Maybe`, failing if the input is out of range
66+
- **Accessor functions** (prefix: `to*`) - Extract values from PostgreSQL types to common Haskell types
5167

5268
This approach ensures that:
5369
- Type constructors remain hidden to protect invariants

postgresql-types.cabal

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,158 @@ description:
2222

2323
* postgresql-simple: <https://hackage-content.haskell.org/package/postgresql-simple-postgresql-types>
2424

25+
.
26+
27+
== Supported Types
28+
29+
This package provides support for nearly all PostgreSQL data types, organized by category:
30+
31+
.
32+
33+
=== Numeric Types
34+
35+
* 'Int2' - 2-byte signed integer (@int2@ \/ @smallint@)
36+
37+
* 'Int4' - 4-byte signed integer (@int4@ \/ @integer@)
38+
39+
* 'Int8' - 8-byte signed integer (@int8@ \/ @bigint@)
40+
41+
* 'Float4' - Single-precision floating point (@float4@ \/ @real@)
42+
43+
* 'Float8' - Double-precision floating point (@float8@ \/ @double precision@)
44+
45+
* 'Numeric' - Arbitrary precision numeric (@numeric@ \/ @decimal@)
46+
47+
* 'Money' - Currency amount (@money@)
48+
49+
* 'Oid' - Object identifier (@oid@)
50+
51+
.
52+
53+
=== Character Types
54+
55+
* 'Text' - Variable-length character string (@text@)
56+
57+
* 'Varchar' - Variable-length with limit (@varchar@)
58+
59+
* 'Char' - Single ASCII character (@char@)
60+
61+
* 'Bpchar' - Fixed-length character string (@char(n)@, @character(n)@, or @bpchar(n)@)
62+
63+
.
64+
65+
=== Boolean Type
66+
67+
* 'Bool' - Boolean (@bool@)
68+
69+
.
70+
71+
=== Binary Data
72+
73+
* 'Bytea' - Binary data (@bytea@)
74+
75+
.
76+
77+
=== Date\/Time Types
78+
79+
* 'Date' - Calendar date (@date@)
80+
81+
* 'Time' - Time of day without time zone (@time@)
82+
83+
* 'Timestamp' - Date and time without time zone (@timestamp@)
84+
85+
* 'Timestamptz' - Date and time with time zone (@timestamptz@)
86+
87+
* 'Timetz' - Time of day with time zone (@timetz@)
88+
89+
* 'Interval' - Time interval (@interval@)
90+
91+
.
92+
93+
=== Network Address Types
94+
95+
* 'Inet' - IPv4 or IPv6 host address (@inet@)
96+
97+
* 'Cidr' - IPv4 or IPv6 network address (@cidr@)
98+
99+
* 'Macaddr' - MAC address (@macaddr@)
100+
101+
* 'Macaddr8' - MAC address (EUI-64 format) (@macaddr8@)
102+
103+
.
104+
105+
=== Geometric Types
106+
107+
* 'Point' - Point on a plane (@point@)
108+
109+
* 'Line' - Infinite line (@line@)
110+
111+
* 'Lseg' - Line segment (@lseg@)
112+
113+
* 'Box' - Rectangular box (@box@)
114+
115+
* 'Path' - Geometric path (@path@)
116+
117+
* 'Polygon' - Closed geometric path (@polygon@)
118+
119+
* 'Circle' - Circle (@circle@)
120+
121+
.
122+
123+
=== Bit String Types
124+
125+
* 'Bit' - Fixed-length bit string (@bit@)
126+
127+
* 'Varbit' - Variable-length bit string (@varbit@)
128+
129+
.
130+
131+
=== UUID Type
132+
133+
* 'Uuid' - Universally unique identifier (@uuid@)
134+
135+
.
136+
137+
=== JSON Types
138+
139+
* 'Json' - JSON data (@json@)
140+
141+
* 'Jsonb' - Binary JSON data (@jsonb@)
142+
143+
.
144+
145+
=== Key-Value Types
146+
147+
* 'Hstore' - Key-value store (@hstore@)
148+
149+
.
150+
151+
=== Range Types
152+
153+
* 'Range' - Generic range type supporting int4range, int8range, numrange, tsrange, tstzrange, daterange
154+
155+
* 'Multirange' - Generic multirange type supporting int4multirange, int8multirange, etc.
156+
157+
.
158+
159+
=== Array Types
160+
161+
Array types are available for all of the above types.
162+
163+
.
164+
165+
== Function Naming Conventions
166+
167+
The library provides three types of functions for working with PostgreSQL types:
168+
169+
.
170+
171+
* __Normalizing constructors__ (prefix: @normalizeFrom*@) - Always succeed by clamping or canonicalizing input values to valid ranges. Use these when you want to ensure a value is valid by transforming invalid inputs into valid ones (e.g., removing NUL bytes from text, clamping dates to PostgreSQL's supported range).
172+
173+
* __Refining constructors__ (prefix: @refineFrom*@) - Return 'Maybe', failing if the input is out of range or invalid. Use these when you want to validate that input data is already within valid PostgreSQL constraints.
174+
175+
* __Accessor functions__ (prefix: @to*@) - Extract values from PostgreSQL types to common Haskell types. These conversions are always safe and total.
176+
25177
homepage: https://github.com/nikita-volkov/postgresql-types
26178
bug-reports: https://github.com/nikita-volkov/postgresql-types/issues
27179
author: Nikita Volkov <nikita.y.volkov@mail.ru>

0 commit comments

Comments
 (0)