File: Keyed.hs

package info (click to toggle)
haskell-foundation 0.0.30-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 928 kB
  • sloc: haskell: 9,124; ansic: 570; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 651 bytes parent folder | download | duplicates (5)
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
-- |
-- Module      : Foundation.Array.Keyed
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : portable
--
{-# LANGUAGE FlexibleInstances #-}
module Foundation.Collection.Keyed
    ( KeyedCollection(..)
    ) where

import           Basement.Compat.Base
import qualified Data.List

-- | Collection of things that can be looked up by Key
class KeyedCollection c where
    type Key c
    type Value c
    lookup :: Key c -> c -> Maybe (Value c)

instance Eq k => KeyedCollection [(k, v)] where
    type Key [(k,v)] = k
    type Value [(k,v)] = v
    lookup = Data.List.lookup