[project @ 1999-04-29 11:53:12 by simonpj]
[ghc-hetmet.git] / ghc / tests / programs / jeff-bug / Init.hs
1 module Init where
2
3 import Signal
4
5 -- Begin Signature ------------------------------------------------------
6 {-
7
8 Very often, particularily when operating over pointed domains, each
9 type has a particular value that serves well as an inital state. 
10 The Init class picks that value out.  For example, the "def" value
11 for lists is "[]"
12
13 -}
14
15 class Init a where
16    def :: a
17
18 {-instance Init [a]-}
19 {-instance Init (Maybe a)-}
20 {-instance Init Int-}
21 {-instance Init Bool-}
22
23
24 -- delay a signal using the type's default value as the initializer
25 del :: Init a => Signal a -> Signal a
26
27
28 -- End Signature ------------------------------------------------------
29    
30 instance Init [a] where
31    def = []
32
33 instance Init (Maybe a) where
34    def = Nothing
35
36 instance Init Int where
37    def = 0
38
39 instance Init Bool where
40    def = False
41
42 del x = delay def x