Skip to content

How to create a new GType corresponding to a simple Haskell datatype? #447

@sheaf

Description

@sheaf

I would like to create a new GType corresponding to a simple haskell datatype such as

data MyType = MkA | MkB Int | MkC Int

I thought the way to do this was to write a Storable instance and use boxedTypeRegisterStatic, but the type of that function makes no sense to me: it expects two functions, one copy function of type type BoxedCopyFunc = IO (Ptr ()) and one free function of type typed BoxedFreeFunc = IO (), but neither of those functions get the input pointer. There are type synonyms type BoxedCopyFunc_WithClosures = Ptr () -> IO (Ptr ()) and type BoxedFreeFunc_WithClosures = Ptr () -> IO () which pass the input pointer to be copied or freed, but those two type synonyms don't really seem to be used anywhere.

I don't want to create a type that is a descendant of GObject as that is very heavy when all I want is a little bit of data that I can put in a GValue and pass along in e.g. a drag-and-drop operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions