| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Prairie.AsRecord
Description
Synopsis
- newtype AsRecord rec = AsRecord {
- unAsRecord :: rec
Documentation
This newtype is intended for use with DerivingVia.
For an example use, let's consider this User datatype:
data Foo = Foo
{ ints :: [Int]
, char :: First Char
}
mkRecord ''FooLet's say we want to define an instance of Semigroup for this type, so
that we can combine two of them. Ordinarily, we'd need to write
a boilerplate-y instance:
instance Semigroup Foo where
f0 <> f1 = Foo
{ ints = f0.ints <> f1.ints
, char = f0.char <> f1.char
}With DerivingVia, we can use AsRecord to provide it easily:
deriving via AsRecord Foo instance Semigroup Foo
Since: 0.0.4.0
Constructors
| AsRecord | |
Fields
| |