ca63c3131e6318f1e9a3e866a99ea4483fcdfd53
[ghc-prim.git] / GHC / Types.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module      :  GHC.Types
4 -- Copyright   :  (c) The University of Glasgow 2009
5 -- License     :  see libraries/ghc-prim/LICENSE
6 --
7 -- Maintainer  :  cvs-ghc@haskell.org
8 -- Stability   :  internal
9 -- Portability :  non-portable (GHC Extensions)
10 --
11 -- GHC type definitions.
12 -- Use GHC.Exts from the base package instead of importing this
13 -- module directly.
14 --
15 -----------------------------------------------------------------------------
16
17 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
18 {-# OPTIONS_GHC -XNoGenerics        #-}
19
20 module GHC.Types (Bool(..), Char(..), Int(..), Float(..), Double(..), IO(..)) where
21
22 import GHC.Prim
23 -- We need Inl etc behind the scenes for the type definitions
24 import GHC.Generics () -- JPM: Do we really need this?
25
26 infixr 5 :
27
28 data [] a = [] | a : [a]
29
30 data Bool = False | True
31
32 {-| The character type 'Char' is an enumeration whose values represent
33 Unicode (or equivalently ISO\/IEC 10646) characters
34 (see <http://www.unicode.org/> for details).
35 This set extends the ISO 8859-1 (Latin-1) character set
36 (the first 256 charachers), which is itself an extension of the ASCII
37 character set (the first 128 characters).
38 A character literal in Haskell has type 'Char'.
39
40 To convert a 'Char' to or from the corresponding 'Int' value defined
41 by Unicode, use 'Prelude.toEnum' and 'Prelude.fromEnum' from the
42 'Prelude.Enum' class respectively (or equivalently 'ord' and 'chr').
43 -}
44 data Char = C# Char#
45
46 data Int = I# Int#
47 -- ^A fixed-precision integer type with at least the range @[-2^29 .. 2^29-1]@.
48 -- The exact range for a given implementation can be determined by using
49 -- 'Prelude.minBound' and 'Prelude.maxBound' from the 'Prelude.Bounded' class.
50
51 -- | Single-precision floating point numbers.
52 -- It is desirable that this type be at least equal in range and precision
53 -- to the IEEE single-precision type.
54 data Float      = F# Float#
55
56 -- | Double-precision floating point numbers.
57 -- It is desirable that this type be at least equal in range and precision
58 -- to the IEEE double-precision type.
59 data Double     = D# Double#
60
61 {-|
62 A value of type @'IO' a@ is a computation which, when performed,
63 does some I\/O before returning a value of type @a@.
64
65 There is really only one way to \"perform\" an I\/O action: bind it to
66 @Main.main@ in your program.  When your program is run, the I\/O will
67 be performed.  It isn't possible to perform I\/O from an arbitrary
68 function, unless that function is itself in the 'IO' monad and called
69 at some point, directly or indirectly, from @Main.main@.
70
71 'IO' is a monad, so 'IO' actions can be combined using either the do-notation
72 or the '>>' and '>>=' operations from the 'Monad' class.
73 -}
74 newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))
75