Skip to content

Instantly share code, notes, and snippets.

@mfelsche
Last active February 1, 2019 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfelsche/0a4f11a582da3846f6fb535cde30d20f to your computer and use it in GitHub Desktop.
Save mfelsche/0a4f11a582da3846f6fb535cde30d20f to your computer and use it in GitHub Desktop.
Ponylang HKT implementation checklist: https://github.com/ponylang/rfcs/pull/134
  • how to handle reification of types with a HKT type-param?
    • if the hkt-type-param is not used: class Foo[F[_]]

    • if the hkt-type-param is used in method signatures:

      trait Foo[F[_]]
        def map[A](a: A): F[A]
      
    • if the hkt-type-param is used in the body of a function with a concrete type (is that even possible? where should it get that type from?):

      trait Foo[F[_]]
        def string(): String =>
          let f: F[String] = Fs.str_f[F]()
          f.string()
      

      should we reify Foo for each instance of F here, without type-args? Or for each F[String], with type-args? After all F could be used with different args across the whole type (e.g. in different methods with different type-args, not depending on a type-param in the method signature).

    • how to handle usage in constraints on the same type and on methods?

      trait Foo[F[_], T: F[String]] 
        def map[X: F[U8]](): T
      
  • handle iftype
    • only allow using HKT-type-args applied with a type-param on the LHS of an iftype: iftype F[T] <: F[String] then
    • can we allow the raw HKT-type on the LHS: iftype F <: List[String] then? In which context? What could be put on the RHS, also a generic HKT-type with a specified type-arg, like: iftype F <: F[String] then or is the above the only thing?
@erip
Copy link

erip commented Jan 30, 2019

  • if the hkt-type-param is used in the body of a function with a concrete type

I don't think this is possible without some constraint. Like you said, there's no way to know how to construct an F, let alone how to stuff some type in it. 😄

@erip
Copy link

erip commented Feb 1, 2019

  • if the hkt-type-param is not used

I think this should be fine, much like if any other type param is unused:

primitive Foo[A]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment