Ticket #155: Hashtable.ds

File Hashtable.ds, 1.1 kB (added by blackh, 5 years ago)
Line 
1import Data.Array
2
3data Entry k v = Entry {
4        key   :: k;
5        value :: v
6    }
7
8data Hashtable k v = Hashtable {
9        hash    :: k -> Int;
10        entries :: Array (List (Entry k v))
11    }
12
13project Hashtable k v where
14    new = hashtable_new
15    lookup = hashtable_lookup
16    insert = hashtable_insert
17    delete = hashtable_delete
18
19hashtable_new :: (k -> Int) -> Int -> Hashtable k v
20hashtable_new hash capacity = Hashtable hash (new&{Array} capacity)
21
22hashtable_lookup :: k -> Hashtable k v -> Maybe v
23hashtable_lookup key ht = Nothing
24
25hashtable_insert :: Hashtable k v -> k -> v -> ()
26hashtable_insert ht k v = ()
27
28hashtable_delete :: Hashtable k v -> k -> ()
29hashtable_delete ht k = ()
30
31main () = do
32    --ht = new&{Hashtable} hash 100
33    println "ok"
34
35{-
36[1 of 1] Compiling Hashtable
37ddc: PANIC in Type.Squid.Class
38        mergeClasses: classes have differing kinds
39            cids = [720, 721]
40            ks   = [*, * -> *]
41       
42        Please report this bug to the maintainers at:
43            http://trac.haskell.org/ddc
44            or by emailing disciple-cafe@googlegroups.com
45-}