Line No. | Rev | Author | Line |
---|---|---|---|
1 | 1 | paulosilva | |
2 | {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, | ||
3 | TypeSynonymInstances, OverlappingInstances #-} | ||
4 | {-# OPTIONS_GHC -Wall #-} | ||
5 | |||
6 | ------------------------------------------------------------------------------- | ||
7 | |||
8 | {- | | ||
9 | Module : Data.Stream | ||
10 | Description : Streams of values. | ||
11 | Copyright : (c) Paulo Silva | ||
12 | License : LGPL | ||
13 | |||
14 | Maintainer : paufil@di.uminho.pt | ||
15 | Stability : experimental | ||
16 | Portability : portable | ||
17 | |||
18 | -} | ||
19 | |||
20 | ------------------------------------------------------------------------------- | ||
21 | |||
22 | module Data.Stream where | ||
23 | |||
24 | ------------------------------------------------------------------------------- | ||
25 | |||
26 | class Stream a v | a -> v where | ||
27 | headStr :: a -> v | ||
28 | tailStr :: a -> a | ||
29 | |||
30 | ------------------------------------------------------------------------------- | ||
31 | |||
32 | instance Stream [a] a where | ||
33 | headStr = head | ||
34 | tailStr = tail | ||
35 | |||
36 | ------------------------------------------------------------------------------- | ||
37 | |||
38 | instance Stream Int Int where | ||
39 | headStr n = n | ||
40 | tailStr n = succ n | ||
41 | |||
42 | ------------------------------------------------------------------------------- | ||
43 | |||
44 | instance Stream [String] String where | ||
45 | headStr = head | ||
46 | tailStr = tail | ||
47 | |||
48 | ------------------------------------------------------------------------------- | ||
49 |