1{-# LANGUAGE FlexibleInstances #-}
4 -- Module : Gen.Types.Map
5-- Copyright : (c) 2013-2015 Brendan Hay
6-- License : This Source Code Form is subject to the terms of
7-- the Mozilla Public License, v. 2.0.
8-- A copy of the MPL can be found in the LICENSE file or
9-- you can obtain it at http://mozilla.org/MPL/2.0/.
10-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
11-- Stability : provisional
12-- Portability : non-portable (GHC extensions)
14module Gen.Types.Map where
19import Data.Aeson.Types
22import qualified Data.HashMap.Strict as Map
24import Data.Text (Text)
28vMapMaybe :: (Eq k, Hashable k)
32vMapMaybe f = runIdentity . kvTraverseMaybe (const (pure . f))
34kvTraverseMaybe :: (Applicative f, Eq k, Hashable k)
35 => (k -> a -> f (Maybe b))
38kvTraverseMaybe f = fmap (Map.map fromJust . Map.filter isJust)
39 . Map.traverseWithKey f
41class (Hashable a, Eq a) => TextKey a where
44instance (TextKey k, FromJSON v) => FromJSON (Map k v) where
45 parseJSON = fmap (Map.fromList . map (first toKey) . Map.toList)
48-- instance (TextKey k, ToJSON v) => ToJSON (Map k v) where
49-- toJSON = toJSON . map (first fromKey) . Map.toList
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