mauke / data-default

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

Is Default (e -> r) necessary? #6

Open 2piix opened 10 years ago

2piix commented 10 years ago

Do you personally use the (e -> r) instance? Do you know if anybody else does? I'm trying to define:

data Preference = Preference 
  { userId :: UserId
  , max   :: Int
  }

Obviously, the UserId can't be defaulted (sensibly -- i.e., while respecting the app's semantics for a UserId), but it would be pretty nice to be able to define:

instance Default (UserId -> Preference) where
  def = \uid -> (Preference uid 1000)