summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_compile/T17904.hs
blob: 18badc605a2438af7aabffdfdd248fd6c3a5ed25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -fno-full-laziness  #-}

module T17904
    ( difference
    , differenceWith
    ) where

import GHC.Exts ( TYPE, Int (..)  )
import Prelude hiding (lookup)

{-# ANN module ("HLint: ignore Eta reduce" :: String) #-}

class Hashable a where
    hashWithSalt :: Int -> a -> Int

data Leaf k v = L k v

data HashMap k v
    = Empty
    | Leaf Word (Leaf k v)

lookup :: (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
lookup k m = case lookupCont (\_ -> (# (# #) | #)) (\v _i -> (# | v #)) (fromIntegral $ (hashWithSalt undefined) k) k m of
  _ -> undefined
{-# INLINE lookup #-}

lookupCont ::
  forall rep (r :: TYPE rep) k v.
     Eq k
  => ((# #) -> r)
  -> (v -> Int -> r)
  -> Word
  -> k -> HashMap k v -> r
lookupCont _absent _present _h0 _k0 _m0 = go undefined undefined undefined undefined
  where
    go :: Word -> k -> Int -> HashMap k v -> r
    go h k _ _
        | h == undefined && k == undefined = undefined
        | otherwise          = undefined

difference :: (Eq k, Hashable k) => HashMap k v -> HashMap k w -> HashMap k v
difference a b = foldlWithKey' go undefined a
  where
    go _m k _v = case lookup k b of
                 Nothing -> undefined
                 _       -> undefined

differenceWith :: (Eq k, Hashable k) => a -> HashMap k v -> HashMap k w -> HashMap k v
differenceWith _f a b = foldlWithKey' go undefined a
  where
    go _m k _v = case lookup k b of
                 Nothing -> undefined
                 _  -> undefined

foldlWithKey' :: (a -> k -> v -> a) -> a -> HashMap k v -> a
foldlWithKey' _f = go
  where
    go _z Empty          = undefined
    go _z (Leaf _ _)     = undefined