mauke / data-default

A class for types with a default value
45 stars 16 forks source link

Drop the instance for function #15

Open nikita-volkov opened 8 years ago

nikita-volkov commented 8 years ago

The current instance isn't very useful and it occupies the space for a whole universe of way more useful default morphism instances, e.g.:

instance Default (Int8 -> Int) where def = fromIntegral
instance Default (String -> Data.Text.Text) where def = Data.Text.pack

Basically, the whole "conversion" ecosystem could be encoded this way.

SX91 commented 7 years ago

I'd want that too. It could also be used for parametrised construction (factories?):

data Parameter = P1 | P2
data MyDataType = First A B C | Second D E F

instance Default (Parameter -> MyDataType) where
    def P1 = First def def def
    def P2 = Second def def def