What are uses of polymorphic kinds?

前端 未结 3 761
走了就别回头了
走了就别回头了 2021-02-13 00:06

Polymorphic kinds are an extension to Haskell\'s type system, supported by UHC, allowing

data A x y = A (y x)

to be typed (kinded?) as a

3条回答
  •  眼角桃花
    2021-02-13 00:10

    One possible usage example can be using conal's TypeCompose for composing monad transformers in point-free style.

    type MyT = StateT Foo :. MaybeT :. ContT Bar
    

    (just as an example, I have no idea what one's going to do with those foos and bars..)

    Instead of:

    type MyT m = StateT Foo (MaybeT (ContT Bar m))
    

    (this would have the same result apart from newtype-wrappers)

    Currently you'll need to duplicate the combinators code for different kinds, and this extension abolishes the repetition and allows using one piece of code to rule them all.

提交回复
热议问题