Forwarder for the interface to LocalBindingsInternal used by the rest
of the system.
> module Database.HsSqlPpp.Internals.TypeChecking.LocalBindings
> (
> LocalBindingsUpdate(..)
> ,LocalBindings
> ,emptyBindings
> ,lbUpdate
> ,lbLookupID
> ,lbLookupIDInType
> ,ppLocalBindings
> ,createLocalBindings
> ,getUnqualifiedBindings
> ,joinBindings
> ,lookupLocalBinding
> ) where
>
>
> import Database.HsSqlPpp.Internals.TypeChecking.LocalBindingsInternal
>
>
>
> lookupID :: LocalEnv -> Maybe String -> String -> E (Maybe Type)
> lookupID (TrefEnv _t _pus _pvs) Nothing _i = Right Nothing
> lookupID (TrefEnv t pus pvs) (Just q) i
> | t == q =
> Right $ msum [lookup i pus, lookup i pvs]
> | otherwise = Right Nothing
> lookupID (FunTrefEnv _f _) Nothing _i = Right Nothing
> lookupID (FunTrefEnv f t) (Just q) i | q == f && i == f = Right $ Just t
> | otherwise = Right Nothing
> lookupID (JoinTrefEnv js e0 e1) Nothing _ = Right Nothing
> lookupID (JoinTrefEnv js e0 e1) (Just q) i
>
> | i `elem` js
> , t@(Right (Just _)) <- lookupe0 = t
>
> | t@(Right (Just _)) <- lookupe0
> , Nothing <- lookupe1 = t
> | Nothing <- lookupe0
> , t@(Right (Just _)) <- lookupe1 = t
> | Right (Just _) <- lookupe0
> , Right (Just _) <- lookupe1 = Left $ AmbiguousIdentifier i
> | Nothing <- lookupe0
> , Nothing <- lookupe1 = Left $ UnrecognisedIdentifier i
> where
> lookupe0 = lookupID e0 (Just q) i
> lookupe1 = lookupID e1 (Just q) i}