Can we create Sub Type of Type Class in haskell? Up to how many level sub-typing of Type Class can go?
Can we create Sub Type of Type Class in haskell ? Up to how
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, it is possible to create some kind of subclass in Haskell. It looks basically like this:
Then any instance of
Childis also required to be an instance ofParent.See, for example,
Applicativeclass.Also I don’t think there is a restriction on ‘level’ of subclassing since (I guess so) subclassing can be though as sequential union of corresponding instances’ class dictionaries
which contain their respective implementations of polymorphic functions, and seemingly there are no boundaries for this dictionary growth.