[Haskell-cafe] Exporting a Type Class for Type Signatures

Dominic Steinitz dominic.steinitz at blueyonder.co.uk
Mon Nov 10 14:56:37 EST 2008

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.

More information about the Haskell-Cafe mailing list