[Haskell-cafe] Layered I/O

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Sep 15 08:32:27 EDT 2004

My thoughts on I/O, binary and chars can be summerised:

1) Produce a new WordN based IO library.       
2) Character strings cannot be separated from their encodings
   (ie they must be encoded somehow - even if that encoding
   is ascii). I would approch this using parameterised phantom
   types, so for example you would have:

	data Ascii  
	data Chr a = Char

   Then the encoding becomes explicit in the type system, but of course
   functions like equality on types cvan still be expressed generically:

	charEq :: Chr a -> Chr a -> Bool

   but of course, you must be comparing the same encodings (enforced
   by type system)!

   The phantom type could be used in IO, IE to define a new encodeing:

	data MyEncoding

        instance ChrToBinary MyEncoding where
		chrToBinary = ...

	instance BinaryToChr MyEncoding where
		binaryToChr = ...


More information about the Haskell-Cafe mailing list