KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I would like to state that the associated data is always an instance of a certain class. class (Context (Associated a b)) => Class a where data Associated a :: * -> * instance Context (Associated a b) where func1 = error "func1" However, the free variable b that is not in scope prevents me from this. One of the solutions is to copy class functions from Context , but it looks ugly. class Class a where data Associated a :: * -> * -- duplicate all functions from class Context contextFunc1 :: Associated a b -> String instance Class a => Context (Associated a b) where func1 = contextFunc1 Is there an idiomatic way to put constraints on associated data type which has variables not mentioned in head? edit: I would like to keep compatibility with GHC 7.0.3
Tags (comma-separated)
Save Edits
Cancel