diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-09-28 13:43:29 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:27:53 -0500 |
commit | 11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (patch) | |
tree | 5716463275c2d3e902889db619908ded2a73971c /src/Data/Wrapper/PSQInt.hs | |
parent | add2c76bced51fde5e9917e7449ef52be70faf87 (diff) |
Factor out some new libraries
word64-map:
Data.Word64Map
network-addr:
Network.Address
tox-crypto:
Crypto.Tox
lifted-concurrent:
Control.Concurrent.Lifted.Instrument
Control.Concurrent.Async.Lifted.Instrument
psq-wrap:
Data.Wrapper.PSQInt
Data.Wrapper.PSQ
minmax-psq:
Data.MinMaxPSQ
tasks:
Control.Concurrent.Tasks
kad:
Network.Kademlia
Network.Kademlia.Bootstrap
Network.Kademlia.Routing
Network.Kademlia.CommonAPI
Network.Kademlia.Persistence
Network.Kademlia.Search
Diffstat (limited to 'src/Data/Wrapper/PSQInt.hs')
-rw-r--r-- | src/Data/Wrapper/PSQInt.hs | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/Data/Wrapper/PSQInt.hs b/src/Data/Wrapper/PSQInt.hs deleted file mode 100644 index 5badb8b2..00000000 --- a/src/Data/Wrapper/PSQInt.hs +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | {-# LANGUAGE PatternSynonyms #-} | ||
2 | {-# LANGUAGE CPP #-} | ||
3 | {-# LANGUAGE ConstraintKinds #-} | ||
4 | module Data.Wrapper.PSQInt | ||
5 | #if 0 | ||
6 | ( module Data.Wrapper.PSQInt , module Data.PSQueue ) where | ||
7 | |||
8 | import Data.PSQueue hiding (foldr, foldl, PSQ) | ||
9 | import qualified Data.PSQueue as PSQueue | ||
10 | |||
11 | type PSQ p = PSQueue.PSQ Int p | ||
12 | |||
13 | -- | Wrapper over PSQueue-style foldr to implement a psqueues-style interface. | ||
14 | fold' :: (Ord p) => (Int -> p -> () -> a -> a) -> a -> PSQ p -> a | ||
15 | fold' f a q = PSQueue.foldr f' a q | ||
16 | where | ||
17 | f' (k :-> prio) x = f k prio () x | ||
18 | |||
19 | #else | ||
20 | ( module Data.Wrapper.PSQInt | ||
21 | , module IntPSQ | ||
22 | , module Data.Wrapper.PSQ | ||
23 | ) where | ||
24 | |||
25 | import Data.Wrapper.PSQ (Binding, pattern (:->), key, prio, toMicroseconds) | ||
26 | |||
27 | import Data.IntPSQ as IntPSQ hiding (insert, map, singleton, minView) | ||
28 | import qualified Data.IntPSQ as Q | ||
29 | |||
30 | type PSQ p = IntPSQ p () | ||
31 | |||
32 | type PSQKey = () | ||
33 | |||
34 | insert :: (Ord p) => Int -> p -> PSQ p -> PSQ p | ||
35 | insert k p q = Q.insert k p () q | ||
36 | {-# INLINE insert #-} | ||
37 | |||
38 | insertWith :: (Ord p) => (p -> p -> p) -> Int -> p -> PSQ p -> PSQ p | ||
39 | insertWith f k p0 q = snd $ Q.alter f' k q | ||
40 | where | ||
41 | f' (Just (p,())) = ((),Just (f p0 p, ())) | ||
42 | f' Nothing = ((),Nothing) | ||
43 | {-# INLINE insertWith #-} | ||
44 | |||
45 | singleton :: (Ord p) => Int -> p -> PSQ p | ||
46 | singleton k p = Q.singleton k p () | ||
47 | {-# INLINE singleton #-} | ||
48 | |||
49 | minView :: (Ord p) => PSQ p -> Maybe (Binding Int p, PSQ p) | ||
50 | minView q = fmap (\(k,p,(),q') -> (k :-> p, q')) $ Q.minView q | ||
51 | {-# INLINE minView #-} | ||
52 | |||
53 | #endif | ||