By writing out a sentence with arbitrary "restriction aliases"?

For example, this is a declaration with deriving :

 {-# LANGUAGE DeriveDataTypeable, ConstraintKinds #-} import Data.Data (Data) import Data.Typeable (Typeable) type Constraints a = (Show a, Eq a, Ord a, Data a, Typeable a) data A = A deriving (Constraints) 

from:

 Illegal deriving item 'Constraints' 

Which makes sense considering http://downloads.haskell.org/~ghc/7.8.3/docs/html/users_guide/deriving.html

I write deriving (Show, Eq, Ord, Data, Typeable) for most of my types. It might be nice to export standard "restriction aliases", i.e. Any type of view * -> Constraint . Of course, given that the constraints in the root of the constraints are the correct arity, they have an empty "minimum complete definition", etc.

Are there any suggestions on this? How hard is that? Are there any alternatives?

+5
source share
1 answer

There is no suggestion for this. It would not be too difficult, but I suspect that it will not bring much traction. Not only can you use the haskell template to generate standalone output declarations, as the comment suggests, but you can do a macro extension to the desired sentence using CPP if you really want to.

+1
source

Source: https://habr.com/ru/post/1211476/


All Articles