1module Data.Aeson.Functions
6 -- * String conversions
12import Control.Arrow ((***), first)
13import Data.Hashable (Hashable)
14import Data.Text (Text)
15import Data.Text.Encoding (decodeUtf8, encodeUtf8)
16import qualified Data.ByteString as B
17import qualified Data.ByteString.Lazy as L
18import qualified Data.HashMap.Strict as H
19import qualified Data.Map as M
21-- | Transform one map into another. The ordering of keys must be
22-- preserved by the key transformation function.
23transformMap :: (Ord k2) => (k1 -> k2) -> (v1 -> v2)
24 -> M.Map k1 v1 -> M.Map k2 v2
25transformMap fk fv = M.fromAscList . map (fk *** fv) . M.toAscList
26{-# INLINE transformMap #-}
28-- | Transform a 'H.HashMap' into a 'M.Map'.
29hashMap :: (Ord k2) => (k1 -> k2) -> (v1 -> v2)
30 -> H.HashMap k1 v1 -> M.Map k2 v2
31hashMap fk kv = M.fromList . map (fk *** kv) . H.toList
34-- | Transform a 'M.Map' into a 'H.HashMap'.
35mapHash :: (Eq k2, Hashable k2) => (k1 -> k2) -> M.Map k1 v -> H.HashMap k2 v
36mapHash fk = H.fromList . map (first fk) . M.toList
39strict :: L.ByteString -> Text
40strict = decode . B.concat . L.toChunks
43lazy :: Text -> L.ByteString
44lazy = L.fromChunks . (:[]) . encodeUtf8
47decode :: B.ByteString -> Text
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list