higgledy-0.1.1.1: Partial types as a type constructor.

Copyright(c) Tom Harding 2019
LicenseMIT
Maintainertom.harding@habito.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Generic.HKD.Build

Description

 
Synopsis

Documentation

class Build (structure :: Type) (f :: Type -> Type) (k :: Type) | f structure -> k where Source #

With many HKD applications, we're working with types like Maybe where it makes sense for us to start with mempty and add values in as we go.

This isn't always the case, however: if all the component parts of our type are gathered using some IO action, we'd like to construct something like HKD MyType IO, and IO a isn't a Monoid for all types a. When this happens, we need to pass in our parameters when we build our structure.

The build function lets us construct our type by passing explicit values for each parameter:

>>> :set -XDeriveGeneric -XTypeApplications
>>> :{
data User
  = User { name :: String, age :: Int, likesDogs :: Bool }
  deriving Generic
:}
>>> :{
test :: _
test = build @User
:}
...
... • Found type wildcard ‘_’
...     standing for ‘f [Char] -> f Int -> f Bool -> HKD User f’
...

Once we call the build function, and indicate the type we want to build, we are free to pick whichever f we like and get to work!

Methods

build :: k Source #

Instances
(Fill f structure xs, GBuild f structure xs k) => Build structure f k Source # 
Instance details

Defined in Data.Generic.HKD.Build

Methods

build :: k Source #