Skip to content

need example or documentaion for reading from an array with a count field #28

@redfish64

Description

@redfish64

Admittedly I don't know very much about haskell, so I apologize if the solution is obvious, but I can't seem to figure out how to read from an array which has a variable length.

The best I could come up with is this (for reading the memoryTypes from the "vkGetPhysicalDeviceMemoryProperties" function)

      memTypes <- case memTypeIndex of
        0 -> Just <$> readFieldArray @"memoryTypes" @0 memPropPtr
        1 -> Just <$> readFieldArray @"memoryTypes" @1 memPropPtr
        2 -> Just <$> readFieldArray @"memoryTypes" @2 memPropPtr
        3 -> Just <$> readFieldArray @"memoryTypes" @3 memPropPtr
        4 -> Just <$> readFieldArray @"memoryTypes" @4 memPropPtr
        5 -> Just <$> readFieldArray @"memoryTypes" @5 memPropPtr
        6 -> Just <$> readFieldArray @"memoryTypes" @6 memPropPtr
        7 -> Just <$> readFieldArray @"memoryTypes" @7 memPropPtr
...

I can't find any example or code anywhere that uses readFieldArray with a variable length, so with my limited knowledge of Haskell, I'm not sure if there is a better way.

Would it be possible to describe how this is done in some documentation somewhere or in an example?

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