 
 -- | Map arbitrary 'Enum' value to 'Tag'
 toTag :: Enum a => a -> Tag
-toTag x = MkTag { tagVal = fromEnum x }
+toTag x = MkTag { tagVal = cIntConv (fromEnum x) }
 
 -- | Map 'Tag' to arbitrary 'Enum'
 fromTag :: Enum a => Tag -> a
-fromTag = toEnum . tagVal
-
-foreign import ccall unsafe "&mpi_any_tag" anyTag_ :: Ptr Int
+fromTag = toEnum . cIntConv . tagVal
+
+foreign import ccall unsafe "&mpi_any_tag" anyTag_ :: Ptr CInt
 
 -- | Predefined tag value that allows reception of the messages with
 --   arbitrary tag values. Corresponds to @MPI_ANY_TAG@.

{-| Haskell datatype that represents values which could be used as
tags for point-to-point transfers.
-}
newtype Tag = MkTag { tagVal :: Int -- ^ Extract numeric value of the Tag
                    }
   deriving (Eq, Ord, Enum, Integral, Real)


Attempt to supply a value that does not fit into 32 bits will cause a
run-time 'error'.
-}
newtype Rank = MkRank { rankId :: CInt -- ^ Extract numeric value of the 'Rank'
                      }
   deriving (Eq, Ord, Enum, Integral, Real)

