[project @ 2001-04-13 21:37:42 by panne]
[ghc-hetmet.git] / ghc / compiler / prelude / TysWiredIn.lhs
index 961325a..b0ebb94 100644 (file)
@@ -19,6 +19,9 @@ module TysWiredIn (
        ptrDataCon,
        ptrTy,
        ptrTyCon,
+       funPtrDataCon,
+       funPtrTy,
+       funPtrTyCon,
        boolTy,
        boolTyCon,
        charDataCon,
@@ -111,7 +114,7 @@ import BasicTypes   ( Arity, RecFlag(..), Boxity(..), isBoxed )
 import Type            ( Type, mkTyConTy, mkTyConApp, mkTyVarTys, 
                          mkArrowKinds, liftedTypeKind, unliftedTypeKind,
                          splitTyConApp_maybe, repType,
-                         TauType, ClassContext )
+                         TauType, ThetaType )
 import Unique          ( incrUnique, mkTupleTyConUnique, mkTupleDataConUnique )
 import PrelNames
 import CmdLineOpts
@@ -136,6 +139,7 @@ wiredInTyCons = data_tycons ++ tuple_tycons ++ unboxed_tuple_tycons
 data_tycons = genericTyCons ++
              [ addrTyCon
              , ptrTyCon
+             , funPtrTyCon
              , boolTyCon
              , charTyCon
              , doubleTyCon
@@ -197,7 +201,7 @@ mk_tc_gen_info mod tc_uniq tc_name tycon
        name1       = mkWiredInName  mod occ_name1 fn1_key
        name2       = mkWiredInName  mod occ_name2 fn2_key
 
-pcDataCon :: Name -> [TyVar] -> ClassContext -> [TauType] -> TyCon -> DataCon
+pcDataCon :: Name -> [TyVar] -> ThetaType -> [TauType] -> TyCon -> DataCon
 -- The unique is the first of two free uniques;
 -- the first is used for the datacon itself and the worker;
 -- the second is used for the wrapper.
@@ -344,6 +348,13 @@ ptrDataCon = pcDataCon ptrDataConName alpha_tyvar [] [addrPrimTy] ptrTyCon
 \end{code}
 
 \begin{code}
+funPtrTy = mkTyConTy funPtrTyCon
+
+funPtrTyCon = pcNonRecDataTyCon funPtrTyConName alpha_tyvar [(True,False)] [funPtrDataCon]
+funPtrDataCon = pcDataCon funPtrDataConName alpha_tyvar [] [addrPrimTy] funPtrTyCon
+\end{code}
+
+\begin{code}
 floatTy        = mkTyConTy floatTyCon
 
 floatTyCon   = pcNonRecDataTyCon floatTyConName   [] [] [floatDataCon]
@@ -452,19 +463,19 @@ isFFIExportResultTy :: Type -> Bool
 isFFIExportResultTy ty = checkRepTyCon legalFEResultTyCon ty
 
 isFFIDynArgumentTy :: Type -> Bool
--- The argument type of a foreign import dynamic must be Ptr, Addr,
+-- The argument type of a foreign import dynamic must be Ptr, FunPtr, Addr,
 -- or a newtype of either.
-isFFIDynArgumentTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == addrTyCon)
+isFFIDynArgumentTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == funPtrTyCon || tc == addrTyCon)
 
 isFFIDynResultTy :: Type -> Bool
--- The result type of a foreign export dynamic must be Ptr, Addr,
+-- The result type of a foreign export dynamic must be Ptr, FunPtr, Addr,
 -- or a newtype of either.
-isFFIDynResultTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == addrTyCon)
+isFFIDynResultTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == funPtrTyCon || tc == addrTyCon)
 
 isFFILabelTy :: Type -> Bool
--- The type of a foreign label must be Ptr, Addr,
+-- The type of a foreign label must be Ptr, FunPtr, Addr,
 -- or a newtype of either.
-isFFILabelTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == addrTyCon)
+isFFILabelTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == funPtrTyCon || tc == addrTyCon)
 
 checkRepTyCon :: (TyCon -> Bool) -> Type -> Bool
        -- look through newtypes
@@ -533,7 +544,7 @@ boxedMarshalableTyCon tc
                         , wordTyConKey, word8TyConKey, word16TyConKey
                         , word32TyConKey, word64TyConKey
                         , floatTyConKey, doubleTyConKey
-                        , addrTyConKey, ptrTyConKey
+                        , addrTyConKey, ptrTyConKey, funPtrTyConKey
                         , charTyConKey, foreignObjTyConKey
                         , foreignPtrTyConKey
                         , stablePtrTyConKey