Skip to content

Is there a easier way to express appended Record types? #171

@billksun

Description

@billksun

I am trying to append 2 Records together using rappend, where the 2 Records have the following type:

type MetaData = Record '[ MetaCol1, MetaCol2]
type SomeData = Record '[Col1, Col2]

I then have a function that prepends the columns from MetaData to SomeData:

AddMeta :: SomeData -> Record `[MetaCol1, MetaCol2, Col1, Col2]
AddMeta someData = metaCol1 &: metaCol2 &: RNil <+> someData 

My question is, is there a way to simplify AddMeta's type signature so I don't have to type out all the columns explicitly? This sample case only has 4 columns total, but this can quickly get unwieldy if I am trying to append 2 frames with large amounts of columns together.

I have seen the usage of ++ in the type signatures, and have tried to use AddMeta :: SomeData -> MetaData ++ SomeData but this results in the following compile error:

Expected kind ‘[k0]’, but ‘HpcUsage’ has kind ‘Type’

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