#Lookup Source

class Lookup c k r | c -> r where

Types that implement the Lookup class can be looked up by some key to retrieve some value. For instance, you could have an implementation for String Int String where lookup s i returns Just a String containing the character in s at i, or Nothing if i is out of bounds.


  • lookup :: c -> k -> Maybe r

    Given some type and a key on that type, extract some value that corresponds to that key.


  • Lookup (Array t) Int t

    The instance of Lookup for an Array is just !! as defined in Data.Array.

  • Lookup (Object t) String t

    The instance of Lookup for a Object just uses Object.lookup (but flipped, because Object.lookup expects the key first, which would end up with a really weird API for !!).

  • Lookup (Map CaseInsensitiveString t) String t

    The instance of Lookup for a Map CaseInsensitiveString converts the String to a CaseInsensitiveString for lookup.

#at Source

at :: forall c k r. Monoid r => Lookup c k r => c -> k -> r

This simple helper works on any Lookup instance where the return type is a Monoid, and is the same as lookup except that it returns a t instead of a Maybe t. If lookup would return Nothing, then at returns mempty.

#(!@) Source

Operator alias for (left-associative / precedence 8)

Expose at as the infix operator !@

#has Source

has :: forall c k r. Lookup (c r) k r => c r -> k -> Boolean

This simple helper works on any Lookup instance, where the container set has a single type variable, and returns a Boolean indicating if the given key matches any value in the given container.

#(!?) Source

Operator alias for HTTPurple.Lookup.has (left-associative / precedence 8)

Expose has as the infix operator !?

#(!!) Source

Operator alias for HTTPurple.Lookup.lookup (left-associative / precedence 8)

!! is inspired by !! in Data.Array, but note that it differs from !! in Data.Array in that you can use !! for any other instance of Lookup.