On Mon, Nov 10, 2008 at 1:56 PM, Dominic Steinitz <[EMAIL PROTECTED]> wrote: > In the crypto package, I have two functions > >> encrypt :: AESKey a => a -> Word128 -> Word128 >> decrypt :: AESKey a => a -> Word128 -> Word128 > > which are exported. > > I also have > >> class (Bits a, Integral a) => AESKey a >> >> instance AESKey Word128 >> instance AESKey Word192 >> instance AESKey Word256 > > unexported which stops you using invalid keys. > > Someone has asked me to export AESKey as they want to write an explicit > type signature for a function they are creating e.g. > > foo :: AESKey a => a -> Word128 -> Word128 > foo x y = encrypt x y > > but this generates an error. Is there a way of allowing someone to use > AESKey in a type signature but not allow them to declare new instances? > > Thanks, Dominic. >
Is there anything wrong with: > encrypt :: AESKey -> Word128 -> Word128 > data AESKey = Key128 Word128 | Key192 Word192 | Key256 Word256 Aside from the obvious that it's a breaking interface change. -Antoine _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
