summaryrefslogtreecommitdiff
path: root/libraries/base/Foreign
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-01-18 16:24:17 -0500
committerBen Gamari <ben@smart-cactus.org>2017-01-18 17:39:48 -0500
commit0d769d5b96232ee0fe5a44f2ce5717bdb0e7eaa3 (patch)
treebecb8c6897014d5cae795d0c210ee87a67a94ed0 /libraries/base/Foreign
parent181688abae5c0b32237a5bd783dfc9667641cce2 (diff)
downloadhaskell-0d769d5b96232ee0fe5a44f2ce5717bdb0e7eaa3.tar.gz
Add CBool to Foreign.C.Types
This adds a `CBool` type wrapping C99's `bool`, i.e., an `unsigned char`. Fixes #13136. Test Plan: ./validate on Tier-1 platforms Reviewers: austin, hvr, simonmar, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie, erikd Differential Revision: https://phabricator.haskell.org/D2982 GHC Trac Issues: #13136
Diffstat (limited to 'libraries/base/Foreign')
-rw-r--r--libraries/base/Foreign/C/Types.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/libraries/base/Foreign/C/Types.hs b/libraries/base/Foreign/C/Types.hs
index f76ff1c6ef..b2e723f724 100644
--- a/libraries/base/Foreign/C/Types.hs
+++ b/libraries/base/Foreign/C/Types.hs
@@ -44,7 +44,7 @@ module Foreign.C.Types
, CShort(..), CUShort(..), CInt(..), CUInt(..)
, CLong(..), CULong(..)
, CPtrdiff(..), CSize(..), CWchar(..), CSigAtomic(..)
- , CLLong(..), CULLong(..)
+ , CLLong(..), CULLong(..), CBool(..)
, CIntPtr(..), CUIntPtr(..), CIntMax(..), CUIntMax(..)
-- ** Numeric types
@@ -126,6 +126,11 @@ INTEGRAL_TYPE(CLLong,HTYPE_LONG_LONG)
-- | Haskell type representing the C @unsigned long long@ type.
INTEGRAL_TYPE(CULLong,HTYPE_UNSIGNED_LONG_LONG)
+-- | Haskell type representing the C @bool@ type.
+--
+-- @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CBool,bool,HTYPE_BOOL)
+
{-# RULES
"fromIntegral/a->CChar" fromIntegral = \x -> CChar (fromIntegral x)
"fromIntegral/a->CSChar" fromIntegral = \x -> CSChar (fromIntegral x)
@@ -150,6 +155,7 @@ INTEGRAL_TYPE(CULLong,HTYPE_UNSIGNED_LONG_LONG)
"fromIntegral/CULong->a" fromIntegral = \(CULong x) -> fromIntegral x
"fromIntegral/CLLong->a" fromIntegral = \(CLLong x) -> fromIntegral x
"fromIntegral/CULLong->a" fromIntegral = \(CULLong x) -> fromIntegral x
+"fromIntegral/CBool->a" fromIntegral = \(CBool x) -> fromIntegral x
#-}
-- | Haskell type representing the C @float@ type.