
8 Jun
2015
8 Jun
'15
2:18 p.m.
I have the type data NonEmpty f a = NonEmpty a (f a) and want to declare an NFData instance in Haskell 98. With the existing NFData class this is not possible because it requires a (NFData (f a)) constraint which needs FlexibleContexts. A solution would be an NFData1 class analogously to the classes in transformers:Data.Functor.Classes: class NFData1 f where rnf1 :: NFData a => f a -> () instance NFData1 [] where rnf1 = rnf instance (NFData1 f) => NFData1 (NonEmpty f) where rnf1 (NonEmpty x xs) = rnf (x, rnf1 xs) instance (NFData1 f, NFData a) => NFData (NonEmpty f a) where rnf = rnf1
3635
Age (days ago)
3635
Last active (days ago)
0 comments
1 participants
participants (1)
-
Henning Thielemann