{-# LANGUAGE
  MultiParamTypeClasses
  #-}
module LLVM.Internal.Value where

import LLVM.Prelude

import Control.Monad.State

import Foreign.Ptr

import qualified LLVM.Internal.FFI.PtrHierarchy as FFI
import qualified LLVM.Internal.FFI.Value as FFI

import LLVM.Internal.Coding
import LLVM.Internal.DecodeAST
import LLVM.Internal.Type () 

import qualified LLVM.AST.Type as A

typeOf :: FFI.DescendentOf FFI.Value v => Ptr v -> DecodeAST A.Type
typeOf :: Ptr v -> DecodeAST Type
typeOf = Ptr Type -> DecodeAST Type
forall (d :: * -> *) h c. DecodeM d h c => c -> d h
decodeM (Ptr Type -> DecodeAST Type)
-> (Ptr v -> DecodeAST (Ptr Type)) -> Ptr v -> DecodeAST Type
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< IO (Ptr Type) -> DecodeAST (Ptr Type)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr Type) -> DecodeAST (Ptr Type))
-> (Ptr v -> IO (Ptr Type)) -> Ptr v -> DecodeAST (Ptr Type)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Value -> IO (Ptr Type)
FFI.typeOf (Ptr Value -> IO (Ptr Type))
-> (Ptr v -> Ptr Value) -> Ptr v -> IO (Ptr Type)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr v -> Ptr Value
forall a b. DescendentOf a b => Ptr b -> Ptr a
FFI.upCast