[project @ 2001-08-23 10:51:19 by simonmar]
[ghc-hetmet.git] / ghc / tests / specialise / COMMENTS
1 CHAR I/O:
2 *********
3
4 In clausify ...
5
6 The unifier would like to propogate use of Char#s all the way to the
7 readChan and appendChan. However these have explicit [Char] arguments
8 so we must explicitly coerce the Chars as we extract them.
9         clause produces [Char#]s
10         parse reads [Char] and builds Sym Char#
11         disp takes [Char#]s and produces [Char]
12
13 COMMENTS:
14 * The extent of this unboxification is quite surprising and possibly
15   unexpected.
16 * Coersion when constructing or extracting from unboxed structures can
17   be a pain. Where this occurs defines the extent of the unboxedness.
18
19 OVERLOADING CHARS:
20
21 Might want to introduce versions of I/O operations which read/write
22 [Char#]. Use a type class to capture either boxed or unboxed Chars.
23
24 class Char a 
25   toChar :: a -> Char
26   fromChar :: Char -> a
27
28 instance Char Char
29   toChar   = id
30   fromChar = id
31
32 instance Char Char#
33   toChar c#  = MkChar c#
34   fromChar c = case c of MkChar c# -> c#
35
36 Now rather than specifying type as
37    ... Char ...
38 We use
39    Char c => ... c ...
40
41 Now just need a specialised versions I/O operations which deal with [Char#]
42
43 The Char class is very similar to the overloading of numeric constants.