Typeclasses and instances for converting between types

Version on this page:
LTS Haskell 17.11:
Stackage Nightly 2021-05-15:
Latest on Hackage:

See all snapshots convertible appears in

BSD-3-Clause licensed by John Goerzen, Nicolas Wu
Maintained by Nicolas Wu
This version can be pinned in stack with:convertible-,3343

Module documentation for

  • Data
    • Data.Convertible
      • Data.Convertible.Base
      • Data.Convertible.Instances
        • Data.Convertible.Instances.C
        • Data.Convertible.Instances.Map
        • Data.Convertible.Instances.Num
        • Data.Convertible.Instances.Text
        • Data.Convertible.Instances.Time
      • Data.Convertible.Utils

convertible provides a typeclass with a single function that is designed to help convert between different types: numeric values, dates and times, and the like. The conversions perform bounds checking and return a pure Either value. This means that you need not remember which specific function performs the conversion you desire.

Also included in the package are optional instances that provide conversion for various numeric and time types, as well as utilities for writing your own instances.

Finally, there is a function that will raise an exception on bounds-checking violation, or return a bare value otherwise, implemented in terms of the safer function described above.

Convertible is also used by HDBC 2.0 for handling marshalling of data to and from databases.

Convertible is backed by an extensive test suite and passes tests on GHC and Hugs.