Skip to content

singlet and Mu do not work on higher kinded types. #13

@brandonzstride

Description

@brandonzstride

The definitions of singlet and Mu can only work on types that do not have a parameter. This is not a bug, but it's a limitation in the definitions.

A parametrized type is a function on types, and a function is not a type. Hence the e in singlet e and Mu t. e cannot be a parametrized/higher-kinded type. It must only be an expression that evaluates to a type.

Here are practical cases for wanting them to work with parametrized types.

let F : (S : sig val t : type -> type end) -> (sig val t : singlet S.t end) =
  fun S -> struct
    let t = S.t
  end

This is more readable (to me) as the following.

let F : (S : sig val t : type -> type end) -> (sig val t = S.t end) =
  fun S -> struct
    let t = S.t
  end

Any parametrized recursive type must be written as a recursive function, which works just fine but messes with some heuristics we use for performance.

let rec t a = e

... might be better written as ...

let t = Mu t a. e

or

let t = Mu t. fun a -> e

if possible. I think this is similarly as difficult to fix as the singlet issue.

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