1 | import Data.Array |
---|

2 | |
---|

3 | data Entry k v = Entry { |
---|

4 | key :: k; |
---|

5 | value :: v |
---|

6 | } |
---|

7 | |
---|

8 | data Hashtable k v = Hashtable { |
---|

9 | hash :: k -> Int; |
---|

10 | entries :: Array (List (Entry k v)) |
---|

11 | } |
---|

12 | |
---|

13 | project Hashtable k v where |
---|

14 | new = hashtable_new |
---|

15 | lookup = hashtable_lookup |
---|

16 | insert = hashtable_insert |
---|

17 | delete = hashtable_delete |
---|

18 | |
---|

19 | hashtable_new :: (k -> Int) -> Int -> Hashtable k v |
---|

20 | hashtable_new hash capacity = Hashtable hash (new&{Array} capacity) |
---|

21 | |
---|

22 | hashtable_lookup :: k -> Hashtable k v -> Maybe v |
---|

23 | hashtable_lookup key ht = Nothing |
---|

24 | |
---|

25 | hashtable_insert :: Hashtable k v -> k -> v -> () |
---|

26 | hashtable_insert ht k v = () |
---|

27 | |
---|

28 | hashtable_delete :: Hashtable k v -> k -> () |
---|

29 | hashtable_delete ht k = () |
---|

30 | |
---|

31 | main () = do |
---|

32 | --ht = new&{Hashtable} hash 100 |
---|

33 | println "ok" |
---|

34 | |
---|

35 | {- |
---|

36 | [1 of 1] Compiling Hashtable |
---|

37 | ddc: 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 | -} |
---|