haskell-gi-base-0.15: Foundation for libraries generated by haskell-gi

Safe HaskellNone
LanguageHaskell98

Data.GI.Base.ShortPrelude

Description

The Haskell Prelude exports a number of symbols that can easily collide with functions appearing in bindings. The generated code requires just a small subset of the functions in the Prelude, together with some of the functionality in Data.GI.Base, we reexport this explicitly here.

Synopsis

Documentation

module Data.Char

module Data.Int

module Data.Word

module Foreign.C

class Enum a where

Class Enum defines operations on sequentially ordered types.

The enumFrom... methods are used in Haskell's translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1. See Chapter 10 of the Haskell Report for more details.

For any type that is an instance of class Bounded as well as Enum, the following should hold:

   enumFrom     x   = enumFromTo     x maxBound
   enumFromThen x y = enumFromThenTo x y bound
     where
       bound | fromEnum y >= fromEnum x = maxBound
             | otherwise                = minBound

Methods

toEnum :: Int -> a

Convert from an Int.

fromEnum :: a -> Int

Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.

class Show a where

Conversion of values to readable Strings.

Minimal complete definition: showsPrec or show.

Derived instances of Show have the following properties, which are compatible with derived instances of Read:

  • The result of show is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used.
  • If the constructor is defined to be an infix operator, then showsPrec will produce infix applications of the constructor.
  • the representation will be enclosed in parentheses if the precedence of the top-level constructor in x is less than d (associativity is ignored). Thus, if d is 0 then the result is never surrounded in parentheses; if d is 11 it is always surrounded in parentheses, unless it is an atomic expression.
  • If the constructor is defined using record syntax, then show will produce the record-syntax form, with the fields given in the same order as the original declaration.

For example, given the declarations

infixr 5 :^:
data Tree a =  Leaf a  |  Tree a :^: Tree a

the derived instance of Show is equivalent to

instance (Show a) => Show (Tree a) where

       showsPrec d (Leaf m) = showParen (d > app_prec) $
            showString "Leaf " . showsPrec (app_prec+1) m
         where app_prec = 10

       showsPrec d (u :^: v) = showParen (d > up_prec) $
            showsPrec (up_prec+1) u .
            showString " :^: "      .
            showsPrec (up_prec+1) v
         where up_prec = 5

Note that right-associativity of :^: is ignored. For example,

  • show (Leaf 1 :^: Leaf 2 :^: Leaf 3) produces the string "Leaf 1 :^: (Leaf 2 :^: Leaf 3)".

Minimal complete definition

showsPrec | show

Methods

showsPrec

Arguments

:: Int

the operator precedence of the enclosing context (a number from 0 to 11). Function application has precedence 10.

-> a

the value to be converted to a String

-> ShowS 

Convert a value to a readable String.

showsPrec should satisfy the law

showsPrec d x r ++ s  ==  showsPrec d x (r ++ s)

Derived instances of Read and Show satisfy the following:

That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.

show :: a -> String

A specialised variant of showsPrec, using precedence context zero, and returning an ordinary String.

showList :: [a] -> ShowS

The method showList is provided to allow the programmer to give a specialised way of showing lists of values. For example, this is used by the predefined Show instance of the Char type, where values of type String should be shown in double quotes, rather than between square brackets.

Instances

Show Bool 
Show Char 
Show Double 
Show Float 
Show Int 
Show Int8 
Show Int16 
Show Int32 
Show Int64 
Show Integer 
Show Ordering 
Show Word 
Show Word8 
Show Word16 
Show Word32 
Show Word64 
Show () 
Show SomeNat 
Show SomeSymbol 
Show PatternMatchFail 
Show RecSelError 
Show RecConError 
Show RecUpdError 
Show NoMethodError 
Show NonTermination 
Show NestedAtomically 
Show WordPtr 
Show IntPtr 
Show GeneralCategory 
Show CChar 
Show CSChar 
Show CUChar 
Show CShort 
Show CUShort 
Show CInt 
Show CUInt 
Show CLong 
Show CULong 
Show CLLong 
Show CULLong 
Show CFloat 
Show CDouble 
Show CPtrdiff 
Show CSize 
Show CWchar 
Show CSigAtomic 
Show CClock 
Show CTime 
Show CUSeconds 
Show CSUSeconds 
Show CIntPtr 
Show CUIntPtr 
Show CIntMax 
Show CUIntMax 
Show MaskingState 
Show ErrorCall 
Show ArithException 
Show All 
Show Any 
Show Arity 
Show Fixity 
Show Associativity 
Show TypeRep 
Show TyCon 
Show Fingerprint 
Show SomeException 
Show ByteString 
Show I16 
Show Text 
Show UnexpectedNullPointerReturn 
Show GError 
Show GVariantSignature 
Show GVariantObjectPath 
Show GVariantHandle 
Show a => Show [a] 
(Integral a, Show a) => Show (Ratio a) 
Show (Ptr a) 
Show (FunPtr a) 
Show (U1 p) 
Show p => Show (Par1 p) 
Show (ForeignPtr a) 
Show a => Show (ZipList a) 
Show a => Show (Dual a) 
Show a => Show (Sum a) 
Show a => Show (Product a) 
Show a => Show (First a) 
Show a => Show (Last a) 
Show a => Show (Maybe a) 
Show a => Show (GVariantSinglet a) 
(Show a, Show b) => Show (Either a b) 
Show (f p) => Show (Rec1 f p) 
(Show a, Show b) => Show (a, b) 
Show (Proxy k s) 
(Show k, Show a) => Show (Map k a) 
(Show key, Show value) => Show (GVariantDictEntry key value) 
Show c => Show (K1 i c p) 
(Show (f p), Show (g p)) => Show ((:+:) f g p) 
(Show (f p), Show (g p)) => Show ((:*:) f g p) 
Show (f (g p)) => Show ((:.:) f g p) 
(Show a, Show b, Show c) => Show (a, b, c) 
Show ((:~:) k a b) 
Show (f p) => Show (M1 i c f p) 
(Show a, Show b, Show c, Show d) => Show (a, b, c, d) 
(Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) 
(Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n) 
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 

class Eq a where

The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq.

Minimal complete definition: either == or /=.

Minimal complete definition

(==) | (/=)

Methods

(==) :: a -> a -> Bool infix 4

(/=) :: a -> a -> Bool infix 4

Instances

Eq Bool 
Eq Char 
Eq Double 
Eq Float 
Eq Int 
Eq Int8 
Eq Int16 
Eq Int32 
Eq Int64 
Eq Integer 
Eq Ordering 
Eq Word 
Eq Word8 
Eq Word16 
Eq Word32 
Eq Word64 
Eq () 
Eq SpecConstrAnnotation 
Eq SomeNat 
Eq SomeSymbol 
Eq WordPtr 
Eq IntPtr 
Eq GeneralCategory 
Eq CChar 
Eq CSChar 
Eq CUChar 
Eq CShort 
Eq CUShort 
Eq CInt 
Eq CUInt 
Eq CLong 
Eq CULong 
Eq CLLong 
Eq CULLong 
Eq CFloat 
Eq CDouble 
Eq CPtrdiff 
Eq CSize 
Eq CWchar 
Eq CSigAtomic 
Eq CClock 
Eq CTime 
Eq CUSeconds 
Eq CSUSeconds 
Eq CIntPtr 
Eq CUIntPtr 
Eq CIntMax 
Eq CUIntMax 
Eq MaskingState 
Eq ErrorCall 
Eq ArithException 
Eq All 
Eq Any 
Eq Arity 
Eq Fixity 
Eq Associativity 
Eq TypeRep 
Eq TyCon 
Eq Fingerprint 
Eq ByteString 
Eq I16 
Eq Text 
Eq GVariantSignature 
Eq GVariantObjectPath 
Eq GVariantHandle 
Eq a => Eq [a] 
Eq a => Eq (Ratio a) 
Eq (StablePtr a) 
Eq (Ptr a) 
Eq (FunPtr a) 
Eq (U1 p) 
Eq p => Eq (Par1 p) 
Eq (ForeignPtr a) 
Eq a => Eq (ZipList a) 
Eq a => Eq (Dual a) 
Eq a => Eq (Sum a) 
Eq a => Eq (Product a) 
Eq a => Eq (First a) 
Eq a => Eq (Last a) 
Eq a => Eq (Maybe a) 
Eq a => Eq (GVariantSinglet a) 
(Eq a, Eq b) => Eq (Either a b) 
Eq (f p) => Eq (Rec1 f p) 
(Eq a, Eq b) => Eq (a, b) 
Eq (Proxy k s) 
(Eq k, Eq a) => Eq (Map k a) 
(Eq key, Eq value) => Eq (GVariantDictEntry key value) 
Eq c => Eq (K1 i c p) 
(Eq (f p), Eq (g p)) => Eq ((:+:) f g p) 
(Eq (f p), Eq (g p)) => Eq ((:*:) f g p) 
Eq (f (g p)) => Eq ((:.:) f g p) 
(Eq a, Eq b, Eq c) => Eq (a, b, c) 
Eq ((:~:) k a b) 
Eq (f p) => Eq (M1 i c f p) 
(Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) 
(Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) 
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 

data IO a :: * -> *

A value of type IO a is a computation which, when performed, does some I/O before returning a value of type a.

There is really only one way to "perform" an I/O action: bind it to Main.main in your program. When your program is run, the I/O will be performed. It isn't possible to perform I/O from an arbitrary function, unless that function is itself in the IO monad and called at some point, directly or indirectly, from Main.main.

IO is a monad, so IO actions can be combined using either the do-notation or the >> and >>= operations from the Monad class.

Instances

class Monad m where

The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions.

Minimal complete definition: >>= and return.

Instances of Monad should satisfy the following laws:

return a >>= k  ==  k a
m >>= return  ==  m
m >>= (\x -> k x >>= h)  ==  (m >>= k) >>= h

Instances of both Monad and Functor should additionally satisfy the law:

fmap f xs  ==  xs >>= return . f

The instances of Monad for lists, Maybe and IO defined in the Prelude satisfy these laws.

Minimal complete definition

(>>=), return

Methods

(>>=) :: m a -> (a -> m b) -> m b infixl 1

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

(>>) :: m a -> m b -> m b infixl 1

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

return :: a -> m a

Inject a value into the monadic type.

fail :: String -> m a

Fail with a message. This operation is not part of the mathematical definition of a monad, but is invoked on pattern-match failure in a do expression.

Instances

Monad [] 
Monad IO 
Monad Maybe 
Monad ((->) r) 
Monad (Either e) 
Monad m => Monad (WrappedMonad m) 
Monad (Proxy *) 

data Maybe a :: * -> *

The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error.

The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

Constructors

Nothing 
Just a 

Instances

Alternative Maybe 
Monad Maybe 
Functor Maybe 
MonadPlus Maybe 
Applicative Maybe 
Generic1 Maybe 
Eq a => Eq (Maybe a) 
Ord a => Ord (Maybe a) 
Show a => Show (Maybe a) 
Generic (Maybe a) 
Monoid a => Monoid (Maybe a)

Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S." Since there is no "Semigroup" typeclass providing just mappend, we use Monoid instead.

NullToNothing (Maybe a) 
IsGValue (Maybe String) 
IsGValue (Maybe Text) 
IsGVariant a => IsGVariant (Maybe a) 
Typeable (* -> *) Maybe 
type Rep1 Maybe = D1 D1Maybe ((:+:) (C1 C1_0Maybe U1) (C1 C1_1Maybe (S1 NoSelector Par1))) 
type Rep (Maybe a) = D1 D1Maybe ((:+:) (C1 C1_0Maybe U1) (C1 C1_1Maybe (S1 NoSelector (Rec0 a)))) 
type (==) (Maybe k) a b = EqMaybe k a b 

(.) :: (b -> c) -> (a -> b) -> a -> c infixr 9

Function composition.

($) :: (a -> b) -> a -> b infixr 0

Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example:

    f $ g $ h x  =  f (g (h x))

It is also useful in higher-order situations, such as map ($ 0) xs, or zipWith ($) fs xs.

(++) :: [a] -> [a] -> [a] infixr 5

Append two lists, i.e.,

[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]

If the first list is not finite, the result is the first list.

(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1

Same as >>=, but with the arguments interchanged.

data Bool :: *

Constructors

False 
True 

Instances

data Float :: *

Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.

data Double :: *

Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.

undefined :: a

A special case of error. It is expected that compilers will recognize this and insert error messages which are more appropriate to the context in which undefined appears.

error :: [Char] -> a

error stops execution and displays an error message.

map :: (a -> b) -> [a] -> [b]

map f xs is the list obtained by applying f to each element of xs, i.e.,

map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
map f [x1, x2, ...] == [f x1, f x2, ...]

length :: [a] -> Int

O(n). length returns the length of a finite list as an Int. It is an instance of the more general genericLength, the result type of which may be any kind of number.

mapM :: Monad m => (a -> m b) -> [a] -> m [b]

mapM f is equivalent to sequence . map f.

mapM_ :: Monad m => (a -> m b) -> [a] -> m ()

mapM_ f is equivalent to sequence_ . map f.

when :: Monad m => Bool -> m () -> m ()

Conditional execution of monadic expressions. For example,

      when debug (putStr "Debugging\n")

will output the string Debugging\n if the Boolean value debug is True, and otherwise do nothing.

fromIntegral :: (Integral a, Num b) => a -> b

general coercion from integral types

realToFrac :: (Real a, Fractional b) => a -> b

general coercion to fractional types