8040fec3a44ee4e6d75979ca35300a8c68a81914
[ghc-prim.git] / GHC / Types.hs
1
2 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
3
4 module GHC.Types (Char(..), Int(..), Float(..), Double(..), IO(..)) where
5
6 import GHC.Prim
7 -- We need Inl etc behind the scenes for the type definitions
8 import GHC.Generics ()
9
10 infixr 5 :
11
12 data [] a = [] | a : [a]
13
14 data Char = C# Char#
15
16 data Int = I# Int#
17 -- ^A fixed-precision integer type with at least the range @[-2^29 .. 2^29-1]@.
18 -- The exact range for a given implementation can be determined by using
19 -- 'Prelude.minBound' and 'Prelude.maxBound' from the 'Prelude.Bounded' class.
20
21 -- | Single-precision floating point numbers.
22 -- It is desirable that this type be at least equal in range and precision
23 -- to the IEEE single-precision type.
24 data Float      = F# Float#
25
26 -- | Double-precision floating point numbers.
27 -- It is desirable that this type be at least equal in range and precision
28 -- to the IEEE double-precision type.
29 data Double     = D# Double#
30
31 {-|
32 A value of type @'IO' a@ is a computation which, when performed,
33 does some I\/O before returning a value of type @a@.
34
35 There is really only one way to \"perform\" an I\/O action: bind it to
36 @Main.main@ in your program.  When your program is run, the I\/O will
37 be performed.  It isn't possible to perform I\/O from an arbitrary
38 function, unless that function is itself in the 'IO' monad and called
39 at some point, directly or indirectly, from @Main.main@.
40
41 'IO' is a monad, so 'IO' actions can be combined using either the do-notation
42 or the '>>' and '>>=' operations from the 'Monad' class.
43 -}
44 newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))
45