Opened 5 years ago

Last modified 4 years ago

#9328 new feature request

MINIMAL pragma should supprt negation

Reported by: augustss Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Consider this class declaration

class Conv a where
    to :: Integer -> a
    from :: a -> Integer
    default to :: (Generic a) => Integer -> a
    to i = ...
    default from :: (Generic a) => a -> Integer
    from a = ...

The class provides default methods for the two methods using generics. An instance declaration for this type is likely to want to use the default for both methods or for none. So I'd like a MINIMAL pragma that can express this. E.g.

    {-# MINIMAL (to, from) | (!to, !from) #-}

I've used ! for negation (following the lead set by the MINIMAL pragma using a non-Haskell OR operator), so this says: either implement 'to' and 'from' or don't implement neither 'to' nor 'from'.

Change History (2)

comment:1 Changed 5 years ago by nomeata

That’s no longer a statement of what instances are MINIMAL, but rather a complete description of sensible instantiations, isn’t it?

comment:2 Changed 4 years ago by augustss

Yes, you could say that. Implementing nothing is MINIMAL, but if you implement to you must also implement from (and v.v.). But I think it's a natural extension of the MINIMAL pragma.

Note: See TracTickets for help on using tickets.