model-0.5: Derive a model of a data type using Generics

Safe HaskellSafe
LanguageHaskell2010

Data.Convertible.Tiny

Contents

Synopsis

The conversion process

convert :: Convertible a b => a -> b #

Convert from one type of data to another. Raises an exception if there is an error with the conversion. For a function that does not raise an exception in that case, see safeConvert.

class Convertible a b where #

A typeclass that represents something that can be converted. A Convertible a b instance represents an a that can be converted to a b.

Methods

safeConvert :: a -> ConvertResult b #

Convert a to b, returning Right on success and Left on error. For a simpler interface, see convert.

Instances
Convertible a a Source #

Any type can be converted to itself.

Instance details

Defined in Data.Convertible.Tiny

Methods

safeConvert :: a -> ConvertResult a #

Convertible String QualName Source # 
Instance details

Defined in Data.Model.Types

Convertible QualName String Source # 
Instance details

Defined in Data.Model.Types

Handling the results

type ConvertResult a = Either ConvertError a #

The result of a safe conversion via safeConvert.

Orphan instances

Convertible a a Source #

Any type can be converted to itself.

Instance details

Methods

safeConvert :: a -> ConvertResult a #