/usr/share/doc/libghc-base-compat-doc/html/base-compat.txt is in libghc-base-compat-doc 0.8.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | -- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A compatibility layer for base
--
-- Provides functions available in later versions of <tt>base</tt> to a
-- wider range of compilers, without requiring you to use CPP pragmas in
-- your code. See the <a>README</a> for what is covered. Also see the
-- <a>changelog</a> for recent changes.
--
-- Note that <tt>base-compat</tt> does not add any orphan instances.
-- There is a separate package <tt><a>base-orphans</a></tt> for that.
@package base-compat
@version 0.8.2
module Text.Read.Compat
-- | Parsing of <a>String</a>s, producing values.
--
-- Derived instances of <a>Read</a> make the following assumptions, which
-- derived instances of <a>Show</a> obey:
--
-- <ul>
-- <li>If the constructor is defined to be an infix operator, then the
-- derived <a>Read</a> instance will parse only infix applications of the
-- constructor (not the prefix form).</li>
-- <li>Associativity is not used to reduce the occurrence of parentheses,
-- although precedence may be.</li>
-- <li>If the constructor is defined using record syntax, the derived
-- <a>Read</a> will parse only the record-syntax form, and furthermore,
-- the fields must be given in the same order as the original
-- declaration.</li>
-- <li>The derived <a>Read</a> instance allows arbitrary Haskell
-- whitespace between tokens of the input string. Extra parentheses are
-- also allowed.</li>
-- </ul>
--
-- For example, given the declarations
--
-- <pre>
-- infixr 5 :^:
-- data Tree a = Leaf a | Tree a :^: Tree a
-- </pre>
--
-- the derived instance of <a>Read</a> in Haskell 2010 is equivalent to
--
-- <pre>
-- instance (Read a) => Read (Tree a) where
--
-- readsPrec d r = readParen (d > app_prec)
-- (\r -> [(Leaf m,t) |
-- ("Leaf",s) <- lex r,
-- (m,t) <- readsPrec (app_prec+1) s]) r
--
-- ++ readParen (d > up_prec)
-- (\r -> [(u:^:v,w) |
-- (u,s) <- readsPrec (up_prec+1) r,
-- (":^:",t) <- lex s,
-- (v,w) <- readsPrec (up_prec+1) t]) r
--
-- where app_prec = 10
-- up_prec = 5
-- </pre>
--
-- Note that right-associativity of <tt>:^:</tt> is unused.
--
-- The derived instance in GHC is equivalent to
--
-- <pre>
-- instance (Read a) => Read (Tree a) where
--
-- readPrec = parens $ (prec app_prec $ do
-- Ident "Leaf" <- lexP
-- m <- step readPrec
-- return (Leaf m))
--
-- +++ (prec up_prec $ do
-- u <- step readPrec
-- Symbol ":^:" <- lexP
-- v <- step readPrec
-- return (u :^: v))
--
-- where app_prec = 10
-- up_prec = 5
--
-- readListPrec = readListPrecDefault
-- </pre>
class Read a
-- | attempts to parse a value from the front of the string, returning a
-- list of (parsed value, remaining string) pairs. If there is no
-- successful parse, the returned list is empty.
--
-- Derived instances of <a>Read</a> and <a>Show</a> satisfy the
-- following:
--
-- <ul>
-- <li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
-- (<a>showsPrec</a> d x ""))</tt>.</li>
-- </ul>
--
-- That is, <a>readsPrec</a> parses the string produced by
-- <a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
-- with.
readsPrec :: Read a => Int -> ReadS a
-- | The method <a>readList</a> is provided to allow the programmer to give
-- a specialised way of parsing lists of values. For example, this is
-- used by the predefined <a>Read</a> instance of the <a>Char</a> type,
-- where values of type <a>String</a> should be are expected to use
-- double quotes, rather than square brackets.
readList :: Read a => ReadS [a]
-- | Proposed replacement for <a>readsPrec</a> using new-style parsers (GHC
-- only).
readPrec :: Read a => ReadPrec a
-- | Proposed replacement for <a>readList</a> using new-style parsers (GHC
-- only). The default definition uses <a>readList</a>. Instances that
-- define <a>readPrec</a> should also define <a>readListPrec</a> as
-- <a>readListPrecDefault</a>.
readListPrec :: Read a => ReadPrec [a]
-- | A parser for a type <tt>a</tt>, represented as a function that takes a
-- <a>String</a> and returns a list of possible parses as
-- <tt>(a,<a>String</a>)</tt> pairs.
--
-- Note that this kind of backtracking parser is very inefficient;
-- reading a large structure may be quite slow (cf <a>ReadP</a>).
type ReadS a = String -> [(a, String)]
-- | equivalent to <a>readsPrec</a> with a precedence of 0.
reads :: Read a => ReadS a
-- | The <a>read</a> function reads input from a string, which must be
-- completely consumed by the input process.
read :: Read a => String -> a
-- | <tt><a>readParen</a> <a>True</a> p</tt> parses what <tt>p</tt> parses,
-- but surrounded with parentheses.
--
-- <tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>
-- parses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a
-- | The <a>lex</a> function reads a single lexeme from the input,
-- discarding initial white space, and returning the characters that
-- constitute the lexeme. If the input string contains only white space,
-- <a>lex</a> returns a single successful `lexeme' consisting of the
-- empty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is
-- no legal lexeme at the beginning of the input string, <a>lex</a> fails
-- (i.e. returns <tt>[]</tt>).
--
-- This lexer is not completely faithful to the Haskell lexical syntax in
-- the following respects:
--
-- <ul>
-- <li>Qualified names are not handled properly</li>
-- <li>Octal and hexadecimal numerics are not recognized as a single
-- token</li>
-- <li>Comments are not treated properly</li>
-- </ul>
lex :: ReadS String
data Lexeme :: *
-- | Character literal
Char :: Char -> Lexeme
-- | String literal, with escapes interpreted
String :: String -> Lexeme
-- | Punctuation or reserved symbol, e.g. <tt>(</tt>, <tt>::</tt>
Punc :: String -> Lexeme
-- | Haskell identifier, e.g. <tt>foo</tt>, <tt>Baz</tt>
Ident :: String -> Lexeme
-- | Haskell symbol, e.g. <tt>>></tt>, <tt>:%</tt>
Symbol :: String -> Lexeme
Number :: Number -> Lexeme
EOF :: Lexeme
-- | Parse a single lexeme
lexP :: ReadPrec Lexeme
-- | <tt>(parens p)</tt> parses "P", "(P0)", "((P0))", etc, where
-- <tt>p</tt> parses "P" in the current precedence context and parses
-- "P0" in precedence context zero
parens :: ReadPrec a -> ReadPrec a
-- | A possible replacement definition for the <a>readList</a> method (GHC
-- only). This is only needed for GHC, and even then only for <a>Read</a>
-- instances where <a>readListPrec</a> isn't defined as
-- <a>readListPrecDefault</a>.
readListDefault :: Read a => ReadS [a]
-- | A possible replacement definition for the <a>readListPrec</a> method,
-- defined using <a>readPrec</a> (GHC only).
readListPrecDefault :: Read a => ReadPrec [a]
-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
-- exactly one valid result. A <a>Left</a> value indicates a parse error.
readEither :: Read a => String -> Either String a
-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
-- exactly one valid result.
readMaybe :: Read a => String -> Maybe a
module System.Exit.Compat
-- | Write given error message to <a>stderr</a> and terminate with
-- <a>exitFailure</a>.
die :: String -> IO a
-- | Miscellaneous information about the system environment.
module System.Environment.Compat
-- | Computation <a>getArgs</a> returns a list of the program's command
-- line arguments (not including the program name).
getArgs :: IO [String]
-- | Computation <a>getProgName</a> returns the name of the program as it
-- was invoked.
--
-- However, this is hard-to-impossible to implement on some non-Unix
-- OSes, so instead, for maximum portability, we just return the leafname
-- of the program as invoked. Even then there are some differences
-- between platforms: on Windows, for example, a program invoked as foo
-- is probably really <tt>FOO.EXE</tt>, and that is what
-- <a>getProgName</a> will return.
getProgName :: IO String
-- | Computation <a>getEnv</a> <tt>var</tt> returns the value of the
-- environment variable <tt>var</tt>. For the inverse, POSIX users can
-- use <a>putEnv</a>.
--
-- This computation may fail with:
--
-- <ul>
-- <li><a>isDoesNotExistError</a> if the environment variable does not
-- exist.</li>
-- </ul>
getEnv :: String -> IO String
-- | Return the value of the environment variable <tt>var</tt>, or
-- <tt>Nothing</tt> if there is no such value.
--
-- For POSIX users, this is equivalent to <a>getEnv</a>.
lookupEnv :: String -> IO (Maybe String)
-- | <tt>setEnv name value</tt> sets the specified environment variable to
-- <tt>value</tt>.
--
-- On Windows setting an environment variable to the <i>empty string</i>
-- removes that environment variable from the environment. For the sake
-- of compatibility we adopt that behavior. In particular
--
-- <pre>
-- setEnv name ""
-- </pre>
--
-- has the same effect as
--
-- <pre>
-- <a>unsetEnv</a> name
-- </pre>
--
-- If you don't care about Windows support and want to set an environment
-- variable to the empty string use <tt>System.Posix.Env.setEnv</tt> from
-- the <tt>unix</tt> package instead.
--
-- Throws <a>IOException</a> if <tt>name</tt> is the empty string or
-- contains an equals sign.
setEnv :: String -> String -> IO ()
-- | <tt>unSet name</tt> removes the specified environment variable from
-- the environment of the current process.
--
-- Throws <a>IOException</a> if <tt>name</tt> is the empty string or
-- contains an equals sign.
unsetEnv :: String -> IO ()
-- | <a>withArgs</a> <tt>args act</tt> - while executing action
-- <tt>act</tt>, have <a>getArgs</a> return <tt>args</tt>.
withArgs :: [String] -> IO a -> IO a
-- | <a>withProgName</a> <tt>name act</tt> - while executing action
-- <tt>act</tt>, have <a>getProgName</a> return <tt>name</tt>.
withProgName :: String -> IO a -> IO a
-- | <a>getEnvironment</a> retrieves the entire environment as a list of
-- <tt>(key,value)</tt> pairs.
--
-- If an environment entry does not contain an <tt>'='</tt> character,
-- the <tt>key</tt> is the whole entry and the <tt>value</tt> is the
-- empty string.
getEnvironment :: IO [(String, String)]
module Prelude.Compat
module Numeric.Compat
-- | Show a signed <a>RealFloat</a> value using standard decimal notation
-- (e.g. <tt>245000</tt>, <tt>0.0015</tt>).
--
-- This behaves as <a>showFFloat</a>, except that a decimal point is
-- always guaranteed, even if not needed.
showFFloatAlt :: RealFloat a => Maybe Int -> a -> ShowS
-- | Show a signed <a>RealFloat</a> value using standard decimal notation
-- for arguments whose absolute value lies between <tt>0.1</tt> and
-- <tt>9,999,999</tt>, and scientific notation otherwise.
--
-- This behaves as <a>showFFloat</a>, except that a decimal point is
-- always guaranteed, even if not needed.
showGFloatAlt :: RealFloat a => Maybe Int -> a -> ShowS
module Foreign.Marshal.Utils.Compat
-- | Fill a given number of bytes in memory area with a byte value.
fillBytes :: Ptr a -> Word8 -> Int -> IO ()
module Foreign.Marshal.Array.Compat
-- | Like <a>mallocArray</a>, but allocated memory is filled with bytes of
-- value zero.
callocArray :: Storable a => Int -> IO (Ptr a)
-- | Like <a>callocArray0</a>, but allocated memory is filled with bytes of
-- value zero.
callocArray0 :: Storable a => Int -> IO (Ptr a)
module Foreign.Marshal.Alloc.Compat
-- | Like <a>malloc</a> but memory is filled with bytes of value zero.
calloc :: Storable a => IO (Ptr a)
-- | Llike <a>mallocBytes</a> but memory is filled with bytes of value
-- zero.
callocBytes :: Int -> IO (Ptr a)
module Foreign.Marshal.Compat
module Foreign.Compat
module Debug.Trace.Compat
-- | Like <a>trace</a> but returns the message instead of a third value.
traceId :: String -> String
-- | Like <a>traceShow</a> but returns the shown value instead of a third
-- value.
traceShowId :: Show a => a -> a
-- | Like <a>trace</a> but returning unit in an arbitrary monad. Allows for
-- convenient use in do-notation. Note that the application of
-- <a>trace</a> is not an action in the monad, as <a>traceIO</a> is in
-- the <a>IO</a> monad.
--
-- <pre>
-- ... = do
-- x <- ...
-- traceM $ "x: " ++ show x
-- y <- ...
-- traceM $ "y: " ++ show y
-- </pre>
traceM :: Monad m => String -> m ()
-- | Like <a>traceM</a>, but uses <a>show</a> on the argument to convert it
-- to a <a>String</a>.
--
-- <pre>
-- ... = do
-- x <- ...
-- traceMShow $ x
-- y <- ...
-- traceMShow $ x + y
-- </pre>
traceShowM :: (Show a, Monad m) => a -> m ()
module Data.Word.Compat
-- | Swap bytes in <a>Word16</a>.
byteSwap16 :: Word16 -> Word16
-- | Reverse order of bytes in <a>Word32</a>.
byteSwap32 :: Word32 -> Word32
-- | Reverse order of bytes in <a>Word64</a>.
byteSwap64 :: Word64 -> Word64
module Data.Version.Compat
-- | Construct tag-less <a>Version</a>
makeVersion :: [Int] -> Version
module Data.Monoid.Compat
-- | An infix synonym for <a>mappend</a>.
(<>) :: Monoid m => m -> m -> m
module Data.List.Compat
module Data.Functor.Compat
-- | The <a>Functor</a> class is used for types that can be mapped over.
-- Instances of <a>Functor</a> should satisfy the following laws:
--
-- <pre>
-- fmap id == id
-- fmap (f . g) == fmap f . fmap g
-- </pre>
--
-- The instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
-- satisfy these laws.
class Functor (f :: * -> *)
fmap :: Functor f => (a -> b) -> f a -> f b
-- | Replace all locations in the input with the same value. The default
-- definition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
-- overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
-- | Flipped version of <a><$</a>.
--
-- <h4><b>Examples</b></h4>
--
-- Replace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with a
-- constant <tt>String</tt>:
--
-- <pre>
-- >>> Nothing $> "foo"
-- Nothing
--
-- >>> Just 90210 $> "foo"
-- Just "foo"
-- </pre>
--
-- Replace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
-- <tt>Int</tt></tt> with a constant <tt>String</tt>, resulting in an
-- <tt><tt>Either</tt> <tt>Int</tt> <tt>String</tt></tt>:
--
-- <pre>
-- >>> Left 8675309 $> "foo"
-- Left 8675309
--
-- >>> Right 8675309 $> "foo"
-- Right "foo"
-- </pre>
--
-- Replace each element of a list with a constant <tt>String</tt>:
--
-- <pre>
-- >>> [1,2,3] $> "foo"
-- ["foo","foo","foo"]
-- </pre>
--
-- Replace the second element of a pair with a constant <tt>String</tt>:
--
-- <pre>
-- >>> (1,2) $> "foo"
-- (1,"foo")
-- </pre>
($>) :: Functor f => f a -> b -> f b
-- | <tt><a>void</a> value</tt> discards or ignores the result of
-- evaluation, such as the return value of an <a>IO</a> action.
--
-- <h4><b>Examples</b></h4>
--
-- Replace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with
-- unit:
--
-- <pre>
-- >>> void Nothing
-- Nothing
--
-- >>> void (Just 3)
-- Just ()
-- </pre>
--
-- Replace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
-- <tt>Int</tt></tt> with unit, resulting in an <tt><tt>Either</tt>
-- <tt>Int</tt> '()'</tt>:
--
-- <pre>
-- >>> void (Left 8675309)
-- Left 8675309
--
-- >>> void (Right 8675309)
-- Right ()
-- </pre>
--
-- Replace every element of a list with unit:
--
-- <pre>
-- >>> void [1,2,3]
-- [(),(),()]
-- </pre>
--
-- Replace the second element of a pair with unit:
--
-- <pre>
-- >>> void (1,2)
-- (1,())
-- </pre>
--
-- Discard the result of an <a>IO</a> action:
--
-- <pre>
-- >>> mapM print [1,2]
-- 1
-- 2
-- [(),()]
--
-- >>> void $ mapM print [1,2]
-- 1
-- 2
-- </pre>
void :: Functor f => f a -> f ()
module Data.Function.Compat
-- | <a>&</a> is a reverse application operator. This provides
-- notational convenience. Its precedence is one higher than that of the
-- forward application operator <a>$</a>, which allows <a>&</a> to be
-- nested in <a>$</a>.
(&) :: a -> (a -> b) -> b
module Data.Foldable.Compat
module Data.Either.Compat
-- | Return <a>True</a> if the given value is a <a>Left</a>-value,
-- <a>False</a> otherwise.
--
-- <h4><b>Examples</b></h4>
--
-- Basic usage:
--
-- <pre>
-- >>> isLeft (Left "foo")
-- True
--
-- >>> isLeft (Right 3)
-- False
-- </pre>
--
-- Assuming a <a>Left</a> value signifies some sort of error, we can use
-- <a>isLeft</a> to write a very simple error-reporting function that
-- does absolutely nothing in the case of success, and outputs "ERROR" if
-- any error occurred.
--
-- This example shows how <a>isLeft</a> might be used to avoid pattern
-- matching when one does not care about the value contained in the
-- constructor:
--
-- <pre>
-- >>> import Control.Monad ( when )
--
-- >>> let report e = when (isLeft e) $ putStrLn "ERROR"
--
-- >>> report (Right 1)
--
-- >>> report (Left "parse error")
-- ERROR
-- </pre>
isLeft :: Either a b -> Bool
-- | Return <a>True</a> if the given value is a <a>Right</a>-value,
-- <a>False</a> otherwise.
--
-- <h4><b>Examples</b></h4>
--
-- Basic usage:
--
-- <pre>
-- >>> isRight (Left "foo")
-- False
--
-- >>> isRight (Right 3)
-- True
-- </pre>
--
-- Assuming a <a>Left</a> value signifies some sort of error, we can use
-- <a>isRight</a> to write a very simple reporting function that only
-- outputs "SUCCESS" when a computation has succeeded.
--
-- This example shows how <a>isRight</a> might be used to avoid pattern
-- matching when one does not care about the value contained in the
-- constructor:
--
-- <pre>
-- >>> import Control.Monad ( when )
--
-- >>> let report e = when (isRight e) $ putStrLn "SUCCESS"
--
-- >>> report (Left "parse error")
--
-- >>> report (Right 1)
-- SUCCESS
-- </pre>
isRight :: Either a b -> Bool
module Data.Bool.Compat
-- | Case analysis for the <a>Bool</a> type. <tt><a>bool</a> x y p</tt>
-- evaluates to <tt>x</tt> when <tt>p</tt> is <a>False</a>, and evaluates
-- to <tt>y</tt> when <tt>p</tt> is <a>True</a>.
--
-- This is equivalent to <tt>if p then y else x</tt>; that is, one can
-- think of it as an if-then-else construct with its arguments reordered.
--
-- <h4><b>Examples</b></h4>
--
-- Basic usage:
--
-- <pre>
-- >>> bool "foo" "bar" True
-- "bar"
--
-- >>> bool "foo" "bar" False
-- "foo"
-- </pre>
--
-- Confirm that <tt><a>bool</a> x y p</tt> and <tt>if p then y else
-- x</tt> are equivalent:
--
-- <pre>
-- >>> let p = True; x = "bar"; y = "foo"
--
-- >>> bool x y p == if p then y else x
-- True
--
-- >>> let p = False
--
-- >>> bool x y p == if p then y else x
-- True
-- </pre>
bool :: a -> a -> Bool -> a
module Data.Bits.Compat
-- | Default implementation for <a>bit</a>.
--
-- Note that: <tt>bitDefault i = 1 <a>shiftL</a> i</tt>
bitDefault :: (Bits a, Num a) => Int -> a
-- | Default implementation for <a>testBit</a>.
--
-- Note that: <tt>testBitDefault x i = (x .&. bit i) /= 0</tt>
testBitDefault :: (Bits a, Num a) => a -> Int -> Bool
-- | Default implementation for <a>popCount</a>.
--
-- This implementation is intentionally naive. Instances are expected to
-- provide an optimized implementation for their size.
popCountDefault :: (Bits a, Num a) => a -> Int
-- | Attempt to convert an <a>Integral</a> type <tt>a</tt> to an
-- <a>Integral</a> type <tt>b</tt> using the size of the types as
-- measured by <a>Bits</a> methods.
--
-- A simpler version of this function is:
--
-- <pre>
-- toIntegral :: (Integral a, Integral b) => a -> Maybe b
-- toIntegral x
-- | toInteger x == y = Just (fromInteger y)
-- | otherwise = Nothing
-- where
-- y = toInteger x
-- </pre>
--
-- This version requires going through <a>Integer</a>, which can be
-- inefficient. However, <tt>toIntegralSized</tt> is optimized to allow
-- GHC to statically determine the relative type sizes (as measured by
-- <a>bitSizeMaybe</a> and <a>isSigned</a>) and avoid going through
-- <a>Integer</a> for many types. (The implementation uses
-- <a>fromIntegral</a>, which is itself optimized with rules for
-- <tt>base</tt> types but may go through <a>Integer</a> for some type
-- pairs.)
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
module Control.Monad.Compat
-- | The <a>Monad</a> class defines the basic operations over a
-- <i>monad</i>, a concept from a branch of mathematics known as
-- <i>category theory</i>. From the perspective of a Haskell programmer,
-- however, it is best to think of a monad as an <i>abstract datatype</i>
-- of actions. Haskell's <tt>do</tt> expressions provide a convenient
-- syntax for writing monadic expressions.
--
-- Instances of <a>Monad</a> should satisfy the following laws:
--
-- <ul>
-- <li><pre><a>return</a> a <a>>>=</a> k = k a</pre></li>
-- <li><pre>m <a>>>=</a> <a>return</a> = m</pre></li>
-- <li><pre>m <a>>>=</a> (x -> k x <a>>>=</a> h) = (m
-- <a>>>=</a> k) <a>>>=</a> h</pre></li>
-- </ul>
--
-- Furthermore, the <a>Monad</a> and <a>Applicative</a> operations should
-- relate as follows:
--
-- <ul>
-- <li><pre><a>pure</a> = <a>return</a></pre></li>
-- <li><pre>(<a><*></a>) = <a>ap</a></pre></li>
-- </ul>
--
-- The above laws imply:
--
-- <ul>
-- <li><pre><a>fmap</a> f xs = xs <a>>>=</a> <a>return</a> .
-- f</pre></li>
-- <li><pre>(<a>>></a>) = (<a>*></a>)</pre></li>
-- </ul>
--
-- and that <a>pure</a> and (<a><*></a>) satisfy the applicative
-- functor laws.
--
-- The instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
-- defined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad (m :: * -> *)
-- | Sequentially compose two actions, passing any value produced by the
-- first as an argument to the second.
(>>=) :: Monad m => m a -> (a -> m b) -> m b
-- | Sequentially compose two actions, discarding any value produced by the
-- first, like sequencing operators (such as the semicolon) in imperative
-- languages.
(>>) :: Monad m => m a -> m b -> m b
-- | Inject a value into the monadic type.
return :: Monad m => a -> 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
-- <tt>do</tt> expression.
fail :: Monad m => String -> m a
-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus (m :: * -> *)
-- | the identity of <a>mplus</a>. It should also satisfy the equations
--
-- <pre>
-- mzero >>= f = mzero
-- v >> mzero = mzero
-- </pre>
mzero :: MonadPlus m => m a
-- | an associative operation
mplus :: MonadPlus m => m a -> m a -> m a
module Control.Concurrent.MVar.Compat
-- | Like <a>withMVar</a>, but the <tt>IO</tt> action in the second
-- argument is executed with asynchronous exceptions masked.
withMVarMasked :: MVar a -> (a -> IO b) -> IO b
|