Skip to content

Add new generic function: hinitialize #19

@m-bock

Description

@m-bock

I found it often useful to have an easy way to generically initialize e.g. a record:

data FillRec = FillRec

instance Initialization FillRec Int where
  initialization _ = 1

instance Initialization FillRec Char where
  initialization _ = 'a'

myRec :: { foo :: Int, bar :: Int, baz :: Char }
myRec = hinitialize FillRec
> myRec                     
{ bar: 1, baz: 'a', foo: 1 }

What do you think? Would it make sense to add this to the library? I have a branch in my fork that implements Initialization and InitializationWithIndex for records.

Alternative names would be: Replicate, Init, Fill....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions