[Haskell-cafe] newbie type signature question

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Jun 10 02:01:05 EDT 2006

Hello Brian,

Saturday, June 10, 2006, 3:05:25 AM, you wrote:

> It is possible that this feature was added to the language for the benefit
> of people who prefer not to use explicit type signatures but afaiu this goes
> against best practice where everything should always have an explicit 
> signature to make code easy to understand and facilitate debugging of type
> errors.

when you work with C++ or some other OOP language, you can define that
some field in structure should some some specific interface and this
allows to use functions of this interface on this field. i required
the same feature in Haskell, for example:

data UTF8Stream h = (ByteStream h) => UTF8Stream h

instance TextStream (UTF8Stream h) ...

addUTF8Encoding :: h -> (UTF8Stream h)

and so on. currently i should add type constraint to each and every
class and function i declared. i don't tried using existential types
here, so i'm not sure that they will give the same high speed for
inlined functions. moreover, they "lose" information about other type
classes that 'h' supports, although functions from these classes may
be required for application that use "UTF8Stream h" and even by other
definitions in my lib:

instance (ByteStringStream h) => ByteStringStream (UTF8Stream h) ...

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list