Problem when mixing type classes and type families

前端 未结 3 604
梦毁少年i
梦毁少年i 2021-01-02 09:23

This code compiles fine:

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances,
  UndecidableInstances, FlexibleContexts, EmptyDataDe         


        
3条回答
  •  耶瑟儿~
    2021-01-02 10:13

    Rec is not a type constructor; it's a type function. Maybe you can use it only in the type of a value of type definition, not in a class declaration? I'm guessing wildly here; I don't understand all the rules for type families.

    I don't know how to fix it, but some things to try include:

    • Get rid of class Sel and just define type family Res a s b :: *. Use type instance instead of the class mechanism.

    • It's barely possible that making type Rec injective using data will help, but I don't think so.

    • Cut back to the smallest number of language extensions that could possibly work—it will make it easier for others to help you, and it might help the compiler as well.

提交回复
热议问题