HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebasement-0.0.16Haskell2010

Basement.From

Flexible Type convertion

From is multi parameter type class that allow converting from a to b.

Only type that are valid to convert to another type should be From instance; otherwise TryFrom should be used.

Into (resp TryInto) allows the contrary instances to be able to specify the destination type before the source. This is practical with TypeApplication

  • 2 types
  • 2 classes
  • 2 values
  • Packagebasement-0.0.16
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFrom.hs
classclass From a b where
#

Class of things that can be converted from a to b.

In a valid instance, the source should be always representable by the destination, otherwise the instance should be using TryFrom

Methods

Instances73From, …
classclass TryFrom a b where
#

Class of things that can mostly be converted from a to b, but with possible error cases.

Methods

Instances6TryFrom
valueinto :: Into b a => a -> b
#

Same as from but reverse the type variable so that the destination type can be specified first

e.g. converting:

from _ Word (10 :: Int)

into @Word (10 :: Int)