Skip to content

Refactor the Instance datatype to use non-closed STypes #1287

@jorisdral

Description

@jorisdral

#1247 changes the Instance type in the HsBindgen.Backend.SHs.AST module to include superclasses, and we add a TFree constructor to the SType datatype in the same module to represent free type variables. This allows us to write instances like:

instance ( ty ~ CFieldType MyInt "un_MyInt"
         ) => HasField "un_MyInt" (Ptr MyInt) (Ptr ty) where

The downside of this approach is that ty is not really a free type variable. ty is bound implicitly in the class instance. For example, the following are equivalent:

instance S ty => C ty
instance forall ty. S ty => C ty

So, using TFree is kind of cheating. If we wanted to represent instance types correctly, we should refactor Instance to use non-closed types with properly scoped type variables instead. And then we can probably remove TFree altogether.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageRequires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions