module Data.Homeomorphic(
    Shell, shell,
    (<<|), couple, dive,
    Homeomorphic, empty, insert, find, findOne
    ) where

import qualified Data.Homeomorphic.MemoCache as H
import Data.Homeomorphic.Internal

-- wrap the Homeomorphic library in a newtype, to get
-- better haddocks in the right place
--
-- document the general interface here, document the specific variants
-- in the individual modules

-- | Datatype to store a homemorphic embedding.
newtype Homeomorphic k v = Homeomorphic (H.Homeomorphic k v)

-- | An empty embedding
empty :: Homeomorphic k v
empty = Homeomorphic H.empty

-- | Insert a new key (coded as a shell) and an associated value
--   into an embedding.
insert :: Ord k => Shell k -> v -> Homeomorphic k v -> Homeomorphic k v
insert a b (Homeomorphic c) = Homeomorphic (H.insert a b c)

-- | Does any relation xs <| y hold, given y.
find :: Ord k => Shell k -> Homeomorphic k v -> [v]
find a (Homeomorphic b) = H.find a b

-- | @findOne y = listToMaybe . find y@
findOne :: Ord k => Shell k -> Homeomorphic k v -> Maybe v
findOne a (Homeomorphic b) = H.findOne a b