{-# LANGUAGE UnboxedTuples, MagicHash, CPP #-}
{-# OPTIONS_GHC -fobject-code #-}
#include "MachDeps.h"
-------------------------------------------------------------------------------
-- |
-- Module      : Data.Tuple.Unboxed
-- Copyright   : (C) 2016,2020 mniip
-- License     : MIT
-- Maintainer  : mniip <mniip@mniip.com>
-- Stability   : experimental
-- Portability : non-portable
--
-- As of now, the GHCi interactive runtime is incapable of working on unboxed
-- tuples. In particular, it is unable to fully apply any function returning an
-- unboxed tuple, create a function that takes a non-nullary unboxed tuple as
-- argument, or pass a non-nullary tuple to some other function. The usual
-- solution is to enable object code generation with @-fobject-code@. This
-- module serves as a workaround for the cases where @-fobject-code@ is
-- undesiable.
--
-- Due to the aforementioned restrictions on operations on unboxed tuples, we
-- can't simply expose operations of type @(\# a, b \#) -> (a, b)@. We have to
-- provide operations for working on functions of type @a -> (\# b, c \#)@.
--
-- More often than not, the types in unboxed tuples are themselves unboxed.
-- There are two major issues with this: 1) we cannot use @(,)@ and 2) we have to
-- provide different functions for different combinations of types. It is also
-- worth mentioning that the 'a' above can also be unboxed and therefore cannot
-- be quantified either.
--
-- This module provides a class of @compose@ functions of type
--
-- > composeA#BC :: (a -> (# b, c, ... #)) -> a -> (b -> c -> ... -> r) -> r
--
-- Where @A@ is the function argument type 'a', @#@ is number of fields in the
-- tuple, and @BC@ are the tupled types 'b', 'c', ...
-- 
-- The key for type names is as follows:
--
--  * _ = @forall (a :: *). a@ (regular lifted type)
--  * a = 'Array#'
--  * Aa = 'ArrayArray#'
--  * b = 'ByteArray#'
--  * c = 'Char#'
--  * C = 'Compact#'
--  * d = 'Double#'
--  * f = 'Float#'
--  * i = 'Int#'
--  * li = INT32 (@if WORD\_SIZE_IN_BITS >= 32 then 'Int#' else 'Int32#'@)
--  * lli = INT64 (@if WORD\_SIZE_IN_BITS >= 64 then 'Int#' else 'Int64#'@)
--  * hi = 'Int16#'
--  * hhi = 'Int8#'
--  * Ma = 'MutableArray#'
--  * MAa = 'MutableArrayArray#'
--  * Mb = 'MutableByteArray#'
--  * Mv = 'MVar#'
--  * o = 'BCO#'
--  * p = 'Addr#'
--  * s = 'State#'
--  * Sa = 'SmallArray#'
--  * SMa = 'SmallMutableArray#'
--  * Sn = 'StableName#'
--  * Sp = 'StablePtr#'
--  * t = 'ThreadId#'
--  * Tv = 'TVar#'
--  * v = 'MutVar#'
--  * w = 'Word#'
--  * lw = WORD32 (@if WORD\_SIZE_IN_BITS >= 32 then 'Word#' else 'Word32#'@)
--  * llw = WORD64 (@if WORD\_SIZE_IN_BITS >= 64 then 'Word#' else 'Word64#'@)
--  * hw = 'Word16#'
--  * hhw = 'Word8#'
--  * Wp = 'Weak#'
--
-- This module contains functions for all combinations of types that have ever
-- come up in "GHC.Prim" but in principle other cases could be added too.
-------------------------------------------------------------------------------
module Data.Tuple.Unboxed where

import GHC.Prim

#if WORD_SIZE_IN_BITS >= 32
#define INT32 Int#
#define WORD32 Word#
#else
#define INT32 Int32#
#define WORD32 Word32#
#endif
#if WORD_SIZE_IN_BITS >= 64
#define INT64 Int#
#define WORD64 Word#
#else
#define INT64 Int64#
#define WORD64 Word64#
#endif

compose_1_ :: (a -> (# b #)) -> a -> (b -> r) -> r
composei1_ :: (Int# -> (# a #)) -> Int# -> (a -> r) -> r
composep1_ :: (Addr# -> (# a #)) -> Addr# -> (a -> r) -> r
composew1_ :: (Word# -> (# a #)) -> Word# -> (a -> r) -> r
compose_2ab :: (a -> (# Array# e, ByteArray# #)) -> a -> (Array# e -> ByteArray# -> r) -> r
composeb2ib :: (ByteArray# -> (# Int#, ByteArray# #)) -> ByteArray# -> (Int# -> ByteArray# -> r) -> r
composed2ii :: (Double# -> (# INT64, Int# #)) -> Double# -> (Int# -> Int# -> r) -> r
composed2llii :: (Double# -> (# INT64, Int# #)) -> Double# -> (INT64 -> Int# -> r) -> r
composef2ii :: (Float# -> (# Int#, Int# #)) -> Float# -> (Int# -> Int# -> r) -> r
composei2i_ :: (Int# -> (# Int#, a #)) -> Int# -> (Int# -> a -> r) -> r
composei2ib :: (Int# -> (# Int#, ByteArray# #)) -> Int# -> (Int# -> ByteArray# -> r) -> r
composei2ii :: (Int# -> (# Int#, Int# #)) -> Int# -> (Int# -> Int# -> r) -> r
composeli2ib :: (INT32 -> (# Int#, ByteArray# #)) -> INT32 -> (Int# -> ByteArray# -> r) -> r
composelli2ib :: (INT64 -> (# Int#, ByteArray# #)) -> INT64 -> (Int# -> ByteArray# -> r) -> r
composellw2ib :: (WORD64 -> (# Int#, ByteArray# #)) -> WORD64 -> (Int# -> ByteArray# -> r) -> r
composelw2ib :: (WORD32 -> (# Int#, ByteArray# #)) -> WORD32 -> (Int# -> ByteArray# -> r) -> r
composep2ib :: (Addr# -> (# Int#, ByteArray# #)) -> Addr# -> (Int# -> ByteArray# -> r) -> r
composes2s_ :: (State# s -> (# State# t, a #)) -> State# s -> (State# t -> a -> r) -> r
composes2sa :: (State# s -> (# State# t, Array# e #)) -> State# s -> (State# t -> Array# e -> r) -> r
composes2sb :: (State# s -> (# State# t, ByteArray# #)) -> State# s -> (State# t -> ByteArray# -> r) -> r
composes2sc :: (State# s -> (# State# t, Char# #)) -> State# s -> (State# t -> Char# -> r) -> r
composes2sd :: (State# s -> (# State# t, Double# #)) -> State# s -> (State# t -> Double# -> r) -> r
composes2sf :: (State# s -> (# State# t, Float# #)) -> State# s -> (State# t -> Float# -> r) -> r
composes2si :: (State# s -> (# State# t, Int# #)) -> State# s -> (State# t -> Int# -> r) -> r
composes2sli :: (State# s -> (# State# t, INT32 #)) -> State# s -> (State# t -> INT32 -> r) -> r
composes2slli :: (State# s -> (# State# t, INT64 #)) -> State# s -> (State# t -> INT64 -> r) -> r
composes2sllw :: (State# s -> (# State# t, WORD64 #)) -> State# s -> (State# t -> WORD64 -> r) -> r
composes2slw :: (State# s -> (# State# t, WORD32 #)) -> State# s -> (State# t -> WORD32 -> r) -> r
composes2sMa :: (State# s -> (# State# t, MutableArray# u e #)) -> State# s -> (State# t -> MutableArray# u e -> r) -> r
composes2sMb :: (State# s -> (# State# t, MutableByteArray# u #)) -> State# s -> (State# t -> MutableByteArray# u -> r) -> r
composes2sMv :: (State# s -> (# State# t, MVar# u e #)) -> State# s -> (State# t -> MVar# u e -> r) -> r
composes2sp :: (State# s -> (# State# t, Addr# #)) -> State# s -> (State# t -> Addr# -> r) -> r
composes2sSn :: (State# s -> (# State# t, StableName# a #)) -> State# s -> (State# t -> StableName# a -> r) -> r
composes2sSp :: (State# s -> (# State# t, StablePtr# a #)) -> State# s -> (State# t -> StablePtr# a -> r) -> r
composes2st :: (State# s -> (# State# t, ThreadId# #)) -> State# s -> (State# t -> ThreadId# -> r) -> r
composes2sTv :: (State# s -> (# State# t, TVar# u e #)) -> State# s -> (State# t -> TVar# u e -> r) -> r
composes2sv :: (State# s -> (# State# t, MutVar# u e #)) -> State# s -> (State# t -> MutVar# u e -> r) -> r
composes2sw :: (State# s -> (# State# t, Word# #)) -> State# s -> (State# t -> Word# -> r) -> r
composes2sWp :: (State# s -> (# State# t, Weak# a #)) -> State# s -> (State# t -> Weak# a -> r) -> r
composew2ib :: (Word# -> (# Int#, ByteArray# #)) -> Word# -> (Int# -> ByteArray# -> r) -> r
composew2wi :: (Word# -> (# Word#, Int# #)) -> Word# -> (Word# -> Int# -> r) -> r
composew2ww :: (Word# -> (# Word#, Word# #)) -> Word# -> (Word# -> Word# -> r) -> r
compose_3pab :: (a -> (# Addr#, Array# e, ByteArray# #)) -> a -> (Addr# -> Array# e -> ByteArray# -> r) -> r
compose_3pba :: (a -> (# Addr#, ByteArray#, Array# e #)) -> a -> (Addr# -> ByteArray# -> Array# e -> r) -> r
composed3iib :: (Double# -> (# Int#, Int#, ByteArray# #)) -> Double# -> (Int# -> Int# -> ByteArray# -> r) -> r
composed3iii :: (Double# -> (# Int#, Int#, Int# #)) -> Double# -> (Int# -> Int# -> Int# -> r) -> r
composef3iib :: (Float# -> (# Int#, Int#, ByteArray# #)) -> Float# -> (Int# -> Int# -> ByteArray# -> r) -> r
composei3iii :: (Int# -> (# Int#, Int#, Int# #)) -> Int# -> (Int# -> Int# -> Int# -> r) -> r
composes3s__ :: (State# s -> (# State# t, a, b #)) -> State# s -> (State# t -> a -> b -> r) -> r
composes3sii :: (State# s -> (# State# t, Int#, Int# #)) -> State# s -> (State# t -> Int# -> Int# -> r) -> r
composes3si_ :: (State# s -> (# State# t, Int#, a #)) -> State# s -> (State# t -> Int# -> a -> r) -> r
composes3spw :: (State# s -> (# State# t, Addr#, Word# #)) -> State# s -> (State# t -> Addr# -> Word# -> r) -> r
composeb4ibib :: (ByteArray# -> (# Int#, ByteArray#, Int#, ByteArray# #)) -> ByteArray# -> (Int# -> ByteArray# -> Int# -> ByteArray# -> r) -> r
composed4iwwi :: (Double# -> (# Int#, Word#, Word#, Int# #)) -> Double# -> (Int# -> Word# -> Word# -> Int# -> r) -> r
composes4siii :: (State# s -> (# State# t, Int#, Int#, Int# #)) -> State# s -> (State# t -> Int# -> Int# -> Int# -> r) -> r

compose_1_ :: (a -> (# b #)) -> a -> (b -> r) -> r
compose_1_ a -> (# b #)
f a
x b -> r
k = case a -> (# b #)
f a
x of (# b
a #) -> b -> r
k b
a
composei1_ :: (Int# -> (# a #)) -> Int# -> (a -> r) -> r
composei1_ Int# -> (# a #)
f Int#
x a -> r
k = case Int# -> (# a #)
f Int#
x of (# a
a #) -> a -> r
k a
a
composep1_ :: (Addr# -> (# a #)) -> Addr# -> (a -> r) -> r
composep1_ Addr# -> (# a #)
f Addr#
x a -> r
k = case Addr# -> (# a #)
f Addr#
x of (# a
a #) -> a -> r
k a
a
composew1_ :: (Word# -> (# a #)) -> Word# -> (a -> r) -> r
composew1_ Word# -> (# a #)
f Word#
x a -> r
k = case Word# -> (# a #)
f Word#
x of (# a
a #) -> a -> r
k a
a
compose_2ab :: (a -> (# Array# e, ByteArray# #))
-> a -> (Array# e -> ByteArray# -> r) -> r
compose_2ab a -> (# Array# e, ByteArray# #)
f a
x Array# e -> ByteArray# -> r
k = case a -> (# Array# e, ByteArray# #)
f a
x of (# Array# e
a, ByteArray#
b #) -> Array# e -> ByteArray# -> r
k Array# e
a ByteArray#
b
composeb2ib :: (ByteArray# -> (# Int#, ByteArray# #))
-> ByteArray# -> (Int# -> ByteArray# -> r) -> r
composeb2ib ByteArray# -> (# Int#, ByteArray# #)
f ByteArray#
x Int# -> ByteArray# -> r
k = case ByteArray# -> (# Int#, ByteArray# #)
f ByteArray#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composed2ii :: (Double# -> (# Int#, Int# #))
-> Double# -> (Int# -> Int# -> r) -> r
composed2ii Double# -> (# Int#, Int# #)
f Double#
x Int# -> Int# -> r
k = case Double# -> (# Int#, Int# #)
f Double#
x of (# Int#
a, Int#
b #) -> Int# -> Int# -> r
k Int#
a Int#
b
composed2llii :: (Double# -> (# Int#, Int# #))
-> Double# -> (Int# -> Int# -> r) -> r
composed2llii Double# -> (# Int#, Int# #)
f Double#
x Int# -> Int# -> r
k = case Double# -> (# Int#, Int# #)
f Double#
x of (# Int#
a, Int#
b #) -> Int# -> Int# -> r
k Int#
a Int#
b
composef2ii :: (Float# -> (# Int#, Int# #)) -> Float# -> (Int# -> Int# -> r) -> r
composef2ii Float# -> (# Int#, Int# #)
f Float#
x Int# -> Int# -> r
k = case Float# -> (# Int#, Int# #)
f Float#
x of (# Int#
a, Int#
b #) -> Int# -> Int# -> r
k Int#
a Int#
b
composei2i_ :: (Int# -> (# Int#, a #)) -> Int# -> (Int# -> a -> r) -> r
composei2i_ Int# -> (# Int#, a #)
f Int#
x Int# -> a -> r
k = case Int# -> (# Int#, a #)
f Int#
x of (# Int#
a, a
b #) -> Int# -> a -> r
k Int#
a a
b
composei2ib :: (Int# -> (# Int#, ByteArray# #))
-> Int# -> (Int# -> ByteArray# -> r) -> r
composei2ib Int# -> (# Int#, ByteArray# #)
f Int#
x Int# -> ByteArray# -> r
k = case Int# -> (# Int#, ByteArray# #)
f Int#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composei2ii :: (Int# -> (# Int#, Int# #)) -> Int# -> (Int# -> Int# -> r) -> r
composei2ii Int# -> (# Int#, Int# #)
f Int#
x Int# -> Int# -> r
k = case Int# -> (# Int#, Int# #)
f Int#
x of (# Int#
a, Int#
b #) -> Int# -> Int# -> r
k Int#
a Int#
b
composeli2ib :: (Int# -> (# Int#, ByteArray# #))
-> Int# -> (Int# -> ByteArray# -> r) -> r
composeli2ib Int# -> (# Int#, ByteArray# #)
f Int#
x Int# -> ByteArray# -> r
k = case Int# -> (# Int#, ByteArray# #)
f Int#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composelli2ib :: (Int# -> (# Int#, ByteArray# #))
-> Int# -> (Int# -> ByteArray# -> r) -> r
composelli2ib Int# -> (# Int#, ByteArray# #)
f Int#
x Int# -> ByteArray# -> r
k = case Int# -> (# Int#, ByteArray# #)
f Int#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composellw2ib :: (Word# -> (# Int#, ByteArray# #))
-> Word# -> (Int# -> ByteArray# -> r) -> r
composellw2ib Word# -> (# Int#, ByteArray# #)
f Word#
x Int# -> ByteArray# -> r
k = case Word# -> (# Int#, ByteArray# #)
f Word#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composelw2ib :: (Word# -> (# Int#, ByteArray# #))
-> Word# -> (Int# -> ByteArray# -> r) -> r
composelw2ib Word# -> (# Int#, ByteArray# #)
f Word#
x Int# -> ByteArray# -> r
k = case Word# -> (# Int#, ByteArray# #)
f Word#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composep2ib :: (Addr# -> (# Int#, ByteArray# #))
-> Addr# -> (Int# -> ByteArray# -> r) -> r
composep2ib Addr# -> (# Int#, ByteArray# #)
f Addr#
x Int# -> ByteArray# -> r
k = case Addr# -> (# Int#, ByteArray# #)
f Addr#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composes2s_ :: (State# s -> (# State# t, a #))
-> State# s -> (State# t -> a -> r) -> r
composes2s_ State# s -> (# State# t, a #)
f State# s
x State# t -> a -> r
k = case State# s -> (# State# t, a #)
f State# s
x of (# State# t
a, a
b #) -> State# t -> a -> r
k State# t
a a
b
composes2sa :: (State# s -> (# State# t, Array# e #))
-> State# s -> (State# t -> Array# e -> r) -> r
composes2sa State# s -> (# State# t, Array# e #)
f State# s
x State# t -> Array# e -> r
k = case State# s -> (# State# t, Array# e #)
f State# s
x of (# State# t
a, Array# e
b #) -> State# t -> Array# e -> r
k State# t
a Array# e
b
composes2sb :: (State# s -> (# State# t, ByteArray# #))
-> State# s -> (State# t -> ByteArray# -> r) -> r
composes2sb State# s -> (# State# t, ByteArray# #)
f State# s
x State# t -> ByteArray# -> r
k = case State# s -> (# State# t, ByteArray# #)
f State# s
x of (# State# t
a, ByteArray#
b #) -> State# t -> ByteArray# -> r
k State# t
a ByteArray#
b
composes2sc :: (State# s -> (# State# t, Char# #))
-> State# s -> (State# t -> Char# -> r) -> r
composes2sc State# s -> (# State# t, Char# #)
f State# s
x State# t -> Char# -> r
k = case State# s -> (# State# t, Char# #)
f State# s
x of (# State# t
a, Char#
b #) -> State# t -> Char# -> r
k State# t
a Char#
b
composes2sd :: (State# s -> (# State# t, Double# #))
-> State# s -> (State# t -> Double# -> r) -> r
composes2sd State# s -> (# State# t, Double# #)
f State# s
x State# t -> Double# -> r
k = case State# s -> (# State# t, Double# #)
f State# s
x of (# State# t
a, Double#
b #) -> State# t -> Double# -> r
k State# t
a Double#
b
composes2sf :: (State# s -> (# State# t, Float# #))
-> State# s -> (State# t -> Float# -> r) -> r
composes2sf State# s -> (# State# t, Float# #)
f State# s
x State# t -> Float# -> r
k = case State# s -> (# State# t, Float# #)
f State# s
x of (# State# t
a, Float#
b #) -> State# t -> Float# -> r
k State# t
a Float#
b
composes2si :: (State# s -> (# State# t, Int# #))
-> State# s -> (State# t -> Int# -> r) -> r
composes2si State# s -> (# State# t, Int# #)
f State# s
x State# t -> Int# -> r
k = case State# s -> (# State# t, Int# #)
f State# s
x of (# State# t
a, Int#
b #) -> State# t -> Int# -> r
k State# t
a Int#
b
composes2sli :: (State# s -> (# State# t, Int# #))
-> State# s -> (State# t -> Int# -> r) -> r
composes2sli State# s -> (# State# t, Int# #)
f State# s
x State# t -> Int# -> r
k = case State# s -> (# State# t, Int# #)
f State# s
x of (# State# t
a, Int#
b #) -> State# t -> Int# -> r
k State# t
a Int#
b
composes2slli :: (State# s -> (# State# t, Int# #))
-> State# s -> (State# t -> Int# -> r) -> r
composes2slli State# s -> (# State# t, Int# #)
f State# s
x State# t -> Int# -> r
k = case State# s -> (# State# t, Int# #)
f State# s
x of (# State# t
a, Int#
b #) -> State# t -> Int# -> r
k State# t
a Int#
b
composes2sllw :: (State# s -> (# State# t, Word# #))
-> State# s -> (State# t -> Word# -> r) -> r
composes2sllw State# s -> (# State# t, Word# #)
f State# s
x State# t -> Word# -> r
k = case State# s -> (# State# t, Word# #)
f State# s
x of (# State# t
a, Word#
b #) -> State# t -> Word# -> r
k State# t
a Word#
b
composes2slw :: (State# s -> (# State# t, Word# #))
-> State# s -> (State# t -> Word# -> r) -> r
composes2slw State# s -> (# State# t, Word# #)
f State# s
x State# t -> Word# -> r
k = case State# s -> (# State# t, Word# #)
f State# s
x of (# State# t
a, Word#
b #) -> State# t -> Word# -> r
k State# t
a Word#
b
composes2sMa :: (State# s -> (# State# t, MutableArray# u e #))
-> State# s -> (State# t -> MutableArray# u e -> r) -> r
composes2sMa State# s -> (# State# t, MutableArray# u e #)
f State# s
x State# t -> MutableArray# u e -> r
k = case State# s -> (# State# t, MutableArray# u e #)
f State# s
x of (# State# t
a, MutableArray# u e
b #) -> State# t -> MutableArray# u e -> r
k State# t
a MutableArray# u e
b
composes2sMb :: (State# s -> (# State# t, MutableByteArray# u #))
-> State# s -> (State# t -> MutableByteArray# u -> r) -> r
composes2sMb State# s -> (# State# t, MutableByteArray# u #)
f State# s
x State# t -> MutableByteArray# u -> r
k = case State# s -> (# State# t, MutableByteArray# u #)
f State# s
x of (# State# t
a, MutableByteArray# u
b #) -> State# t -> MutableByteArray# u -> r
k State# t
a MutableByteArray# u
b
composes2sMv :: (State# s -> (# State# t, MVar# u e #))
-> State# s -> (State# t -> MVar# u e -> r) -> r
composes2sMv State# s -> (# State# t, MVar# u e #)
f State# s
x State# t -> MVar# u e -> r
k = case State# s -> (# State# t, MVar# u e #)
f State# s
x of (# State# t
a, MVar# u e
b #) -> State# t -> MVar# u e -> r
k State# t
a MVar# u e
b
composes2sp :: (State# s -> (# State# t, Addr# #))
-> State# s -> (State# t -> Addr# -> r) -> r
composes2sp State# s -> (# State# t, Addr# #)
f State# s
x State# t -> Addr# -> r
k = case State# s -> (# State# t, Addr# #)
f State# s
x of (# State# t
a, Addr#
b #) -> State# t -> Addr# -> r
k State# t
a Addr#
b
composes2sSn :: (State# s -> (# State# t, StableName# a #))
-> State# s -> (State# t -> StableName# a -> r) -> r
composes2sSn State# s -> (# State# t, StableName# a #)
f State# s
x State# t -> StableName# a -> r
k = case State# s -> (# State# t, StableName# a #)
f State# s
x of (# State# t
a, StableName# a
b #) -> State# t -> StableName# a -> r
k State# t
a StableName# a
b
composes2sSp :: (State# s -> (# State# t, StablePtr# a #))
-> State# s -> (State# t -> StablePtr# a -> r) -> r
composes2sSp State# s -> (# State# t, StablePtr# a #)
f State# s
x State# t -> StablePtr# a -> r
k = case State# s -> (# State# t, StablePtr# a #)
f State# s
x of (# State# t
a, StablePtr# a
b #) -> State# t -> StablePtr# a -> r
k State# t
a StablePtr# a
b
composes2st :: (State# s -> (# State# t, ThreadId# #))
-> State# s -> (State# t -> ThreadId# -> r) -> r
composes2st State# s -> (# State# t, ThreadId# #)
f State# s
x State# t -> ThreadId# -> r
k = case State# s -> (# State# t, ThreadId# #)
f State# s
x of (# State# t
a, ThreadId#
b #) -> State# t -> ThreadId# -> r
k State# t
a ThreadId#
b
composes2sTv :: (State# s -> (# State# t, TVar# u e #))
-> State# s -> (State# t -> TVar# u e -> r) -> r
composes2sTv State# s -> (# State# t, TVar# u e #)
f State# s
x State# t -> TVar# u e -> r
k = case State# s -> (# State# t, TVar# u e #)
f State# s
x of (# State# t
a, TVar# u e
b #) -> State# t -> TVar# u e -> r
k State# t
a TVar# u e
b
composes2sv :: (State# s -> (# State# t, MutVar# u e #))
-> State# s -> (State# t -> MutVar# u e -> r) -> r
composes2sv State# s -> (# State# t, MutVar# u e #)
f State# s
x State# t -> MutVar# u e -> r
k = case State# s -> (# State# t, MutVar# u e #)
f State# s
x of (# State# t
a, MutVar# u e
b #) -> State# t -> MutVar# u e -> r
k State# t
a MutVar# u e
b
composes2sw :: (State# s -> (# State# t, Word# #))
-> State# s -> (State# t -> Word# -> r) -> r
composes2sw State# s -> (# State# t, Word# #)
f State# s
x State# t -> Word# -> r
k = case State# s -> (# State# t, Word# #)
f State# s
x of (# State# t
a, Word#
b #) -> State# t -> Word# -> r
k State# t
a Word#
b
composes2sWp :: (State# s -> (# State# t, Weak# a #))
-> State# s -> (State# t -> Weak# a -> r) -> r
composes2sWp State# s -> (# State# t, Weak# a #)
f State# s
x State# t -> Weak# a -> r
k = case State# s -> (# State# t, Weak# a #)
f State# s
x of (# State# t
a, Weak# a
b #) -> State# t -> Weak# a -> r
k State# t
a Weak# a
b
composew2ib :: (Word# -> (# Int#, ByteArray# #))
-> Word# -> (Int# -> ByteArray# -> r) -> r
composew2ib Word# -> (# Int#, ByteArray# #)
f Word#
x Int# -> ByteArray# -> r
k = case Word# -> (# Int#, ByteArray# #)
f Word#
x of (# Int#
a, ByteArray#
b #) -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b
composew2wi :: (Word# -> (# Word#, Int# #)) -> Word# -> (Word# -> Int# -> r) -> r
composew2wi Word# -> (# Word#, Int# #)
f Word#
x Word# -> Int# -> r
k = case Word# -> (# Word#, Int# #)
f Word#
x of (# Word#
a, Int#
b #) -> Word# -> Int# -> r
k Word#
a Int#
b
composew2ww :: (Word# -> (# Word#, Word# #))
-> Word# -> (Word# -> Word# -> r) -> r
composew2ww Word# -> (# Word#, Word# #)
f Word#
x Word# -> Word# -> r
k = case Word# -> (# Word#, Word# #)
f Word#
x of (# Word#
a, Word#
b #) -> Word# -> Word# -> r
k Word#
a Word#
b
compose_3pab :: (a -> (# Addr#, Array# e, ByteArray# #))
-> a -> (Addr# -> Array# e -> ByteArray# -> r) -> r
compose_3pab a -> (# Addr#, Array# e, ByteArray# #)
f a
x Addr# -> Array# e -> ByteArray# -> r
k = case a -> (# Addr#, Array# e, ByteArray# #)
f a
x of (# Addr#
a, Array# e
b, ByteArray#
c #) -> Addr# -> Array# e -> ByteArray# -> r
k Addr#
a Array# e
b ByteArray#
c
compose_3pba :: (a -> (# Addr#, ByteArray#, Array# e #))
-> a -> (Addr# -> ByteArray# -> Array# e -> r) -> r
compose_3pba a -> (# Addr#, ByteArray#, Array# e #)
f a
x Addr# -> ByteArray# -> Array# e -> r
k = case a -> (# Addr#, ByteArray#, Array# e #)
f a
x of (# Addr#
a, ByteArray#
b, Array# e
c #) -> Addr# -> ByteArray# -> Array# e -> r
k Addr#
a ByteArray#
b Array# e
c
composed3iib :: (Double# -> (# Int#, Int#, ByteArray# #))
-> Double# -> (Int# -> Int# -> ByteArray# -> r) -> r
composed3iib Double# -> (# Int#, Int#, ByteArray# #)
f Double#
x Int# -> Int# -> ByteArray# -> r
k = case Double# -> (# Int#, Int#, ByteArray# #)
f Double#
x of (# Int#
a, Int#
b, ByteArray#
c #) -> Int# -> Int# -> ByteArray# -> r
k Int#
a Int#
b ByteArray#
c
composed3iii :: (Double# -> (# Int#, Int#, Int# #))
-> Double# -> (Int# -> Int# -> Int# -> r) -> r
composed3iii Double# -> (# Int#, Int#, Int# #)
f Double#
x Int# -> Int# -> Int# -> r
k = case Double# -> (# Int#, Int#, Int# #)
f Double#
x of (# Int#
a, Int#
b, Int#
c #) -> Int# -> Int# -> Int# -> r
k Int#
a Int#
b Int#
c
composef3iib :: (Float# -> (# Int#, Int#, ByteArray# #))
-> Float# -> (Int# -> Int# -> ByteArray# -> r) -> r
composef3iib Float# -> (# Int#, Int#, ByteArray# #)
f Float#
x Int# -> Int# -> ByteArray# -> r
k = case Float# -> (# Int#, Int#, ByteArray# #)
f Float#
x of (# Int#
a, Int#
b, ByteArray#
c #) -> Int# -> Int# -> ByteArray# -> r
k Int#
a Int#
b ByteArray#
c
composei3iii :: (Int# -> (# Int#, Int#, Int# #))
-> Int# -> (Int# -> Int# -> Int# -> r) -> r
composei3iii Int# -> (# Int#, Int#, Int# #)
f Int#
x Int# -> Int# -> Int# -> r
k = case Int# -> (# Int#, Int#, Int# #)
f Int#
x of (# Int#
a, Int#
b, Int#
c #) -> Int# -> Int# -> Int# -> r
k Int#
a Int#
b Int#
c
composes3s__ :: (State# s -> (# State# t, a, b #))
-> State# s -> (State# t -> a -> b -> r) -> r
composes3s__ State# s -> (# State# t, a, b #)
f State# s
x State# t -> a -> b -> r
k = case State# s -> (# State# t, a, b #)
f State# s
x of (# State# t
a, a
b, b
c #) -> State# t -> a -> b -> r
k State# t
a a
b b
c
composes3sii :: (State# s -> (# State# t, Int#, Int# #))
-> State# s -> (State# t -> Int# -> Int# -> r) -> r
composes3sii State# s -> (# State# t, Int#, Int# #)
f State# s
x State# t -> Int# -> Int# -> r
k = case State# s -> (# State# t, Int#, Int# #)
f State# s
x of (# State# t
a, Int#
b, Int#
c #) -> State# t -> Int# -> Int# -> r
k State# t
a Int#
b Int#
c
composes3si_ :: (State# s -> (# State# t, Int#, a #))
-> State# s -> (State# t -> Int# -> a -> r) -> r
composes3si_ State# s -> (# State# t, Int#, a #)
f State# s
x State# t -> Int# -> a -> r
k = case State# s -> (# State# t, Int#, a #)
f State# s
x of (# State# t
a, Int#
b, a
c #) -> State# t -> Int# -> a -> r
k State# t
a Int#
b a
c
composes3spw :: (State# s -> (# State# t, Addr#, Word# #))
-> State# s -> (State# t -> Addr# -> Word# -> r) -> r
composes3spw State# s -> (# State# t, Addr#, Word# #)
f State# s
x State# t -> Addr# -> Word# -> r
k = case State# s -> (# State# t, Addr#, Word# #)
f State# s
x of (# State# t
a, Addr#
b, Word#
c #) -> State# t -> Addr# -> Word# -> r
k State# t
a Addr#
b Word#
c
composeb4ibib :: (ByteArray# -> (# Int#, ByteArray#, Int#, ByteArray# #))
-> ByteArray#
-> (Int# -> ByteArray# -> Int# -> ByteArray# -> r)
-> r
composeb4ibib ByteArray# -> (# Int#, ByteArray#, Int#, ByteArray# #)
f ByteArray#
x Int# -> ByteArray# -> Int# -> ByteArray# -> r
k = case ByteArray# -> (# Int#, ByteArray#, Int#, ByteArray# #)
f ByteArray#
x of (# Int#
a, ByteArray#
b, Int#
c, ByteArray#
d #) -> Int# -> ByteArray# -> Int# -> ByteArray# -> r
k Int#
a ByteArray#
b Int#
c ByteArray#
d
composed4iwwi :: (Double# -> (# Int#, Word#, Word#, Int# #))
-> Double# -> (Int# -> Word# -> Word# -> Int# -> r) -> r
composed4iwwi Double# -> (# Int#, Word#, Word#, Int# #)
f Double#
x Int# -> Word# -> Word# -> Int# -> r
k = case Double# -> (# Int#, Word#, Word#, Int# #)
f Double#
x of (# Int#
a, Word#
b, Word#
c, Int#
d #) -> Int# -> Word# -> Word# -> Int# -> r
k Int#
a Word#
b Word#
c Int#
d
composes4siii :: (State# s -> (# State# t, Int#, Int#, Int# #))
-> State# s -> (State# t -> Int# -> Int# -> Int# -> r) -> r
composes4siii State# s -> (# State# t, Int#, Int#, Int# #)
f State# s
x State# t -> Int# -> Int# -> Int# -> r
k = case State# s -> (# State# t, Int#, Int#, Int# #)
f State# s
x of (# State# t
a, Int#
b, Int#
c, Int#
d #) -> State# t -> Int# -> Int# -> Int# -> r
k State# t
a Int#
b Int#
c Int#
d

#if __GLASGOW_HASKELL__ >= 808
composehhi2hhihhi :: (Int8# -> (# Int8#, Int8# #)) -> Int8# -> (Int8# -> Int8# -> r) -> r
composehhw2hhwhhw :: (Word8# -> (# Word8#, Word8# #)) -> Word8# -> (Word8# -> Word8# -> r) -> r
composehi2hihi :: (Int16# -> (# Int16#, Int16# #)) -> Int16# -> (Int16# -> Int16# -> r) -> r
composehw2hwhw :: (Word16# -> (# Word16#, Word16# #)) -> Word16# -> (Word16# -> Word16# -> r) -> r
composehhi2hhihhi :: (Int8# -> (# Int8#, Int8# #))
-> Int8# -> (Int8# -> Int8# -> r) -> r
composehhi2hhihhi Int8# -> (# Int8#, Int8# #)
f Int8#
x Int8# -> Int8# -> r
k = case Int8# -> (# Int8#, Int8# #)
f Int8#
x of (# Int8#
a, Int8#
b #) -> Int8# -> Int8# -> r
k Int8#
a Int8#
b
composehhw2hhwhhw :: (Word8# -> (# Word8#, Word8# #))
-> Word8# -> (Word8# -> Word8# -> r) -> r
composehhw2hhwhhw Word8# -> (# Word8#, Word8# #)
f Word8#
x Word8# -> Word8# -> r
k = case Word8# -> (# Word8#, Word8# #)
f Word8#
x of (# Word8#
a, Word8#
b #) -> Word8# -> Word8# -> r
k Word8#
a Word8#
b
composehi2hihi :: (Int16# -> (# Int16#, Int16# #))
-> Int16# -> (Int16# -> Int16# -> r) -> r
composehi2hihi Int16# -> (# Int16#, Int16# #)
f Int16#
x Int16# -> Int16# -> r
k = case Int16# -> (# Int16#, Int16# #)
f Int16#
x of (# Int16#
a, Int16#
b #) -> Int16# -> Int16# -> r
k Int16#
a Int16#
b
composehw2hwhw :: (Word16# -> (# Word16#, Word16# #))
-> Word16# -> (Word16# -> Word16# -> r) -> r
composehw2hwhw Word16# -> (# Word16#, Word16# #)
f Word16#
x Word16# -> Word16# -> r
k = case Word16# -> (# Word16#, Word16# #)
f Word16#
x of (# Word16#
a, Word16#
b #) -> Word16# -> Word16# -> r
k Word16#
a Word16#
b
#endif
#if __GLASGOW_HASKELL >= 802
composes2sC :: (State# s -> (# State# t, Compact# #)) -> State# s -> (State# t -> Compact# -> r) -> r
composes3sCp :: (State# s -> (# State# t, Compact#, Addr# #)) -> State# s -> (State# t -> Compact# -> Addr# -> r) -> r
composes2sC f x k = case f x of (# a, b #) -> k a b
composes3sCp f x k = case f x of (# a, b, c #) -> k a b c
#endif
#if __GLASGOW_HASKELL__ >= 710
composes2sSa :: (State# s -> (# State# t, SmallArray# e #)) -> State# s -> (State# t -> SmallArray# e -> r) -> r
composes2sSMa :: (State# s -> (# State# t, SmallMutableArray# u e #)) -> State# s -> (State# t -> SmallMutableArray# u e -> r) -> r
composes2sSa :: (State# s -> (# State# t, SmallArray# e #))
-> State# s -> (State# t -> SmallArray# e -> r) -> r
composes2sSa State# s -> (# State# t, SmallArray# e #)
f State# s
x State# t -> SmallArray# e -> r
k = case State# s -> (# State# t, SmallArray# e #)
f State# s
x of (# State# t
a, SmallArray# e
b #) -> State# t -> SmallArray# e -> r
k State# t
a SmallArray# e
b
composes2sSMa :: (State# s -> (# State# t, SmallMutableArray# u e #))
-> State# s -> (State# t -> SmallMutableArray# u e -> r) -> r
composes2sSMa State# s -> (# State# t, SmallMutableArray# u e #)
f State# s
x State# t -> SmallMutableArray# u e -> r
k = case State# s -> (# State# t, SmallMutableArray# u e #)
f State# s
x of (# State# t
a, SmallMutableArray# u e
b #) -> State# t -> SmallMutableArray# u e -> r
k State# t
a SmallMutableArray# u e
b
#endif
#if __GLASGOW_HASKELL__ >= 706
composes3s_2__ :: (State# s -> (# State# t, a, (# b, c #) #)) -> State# s -> (State# t -> a -> b -> c -> r) -> r
composes3s_2__ :: (State# s -> (# State# t, a, (# b, c #) #))
-> State# s -> (State# t -> a -> b -> c -> r) -> r
composes3s_2__ State# s -> (# State# t, a, (# b, c #) #)
f State# s
x State# t -> a -> b -> c -> r
k = case State# s -> (# State# t, a, (# b, c #) #)
f State# s
x of (# State# t
a, a
b, (# b
c, c
d #) #) -> State# t -> a -> b -> c -> r
k State# t
a a
b b
c c
d
#endif
#if __GLASGOW_HASKELL__ >= 704
composes2sAa :: (State# s -> (# State# t, ArrayArray# #)) -> State# s -> (State# t -> ArrayArray# -> r) -> r
composes2sMAa :: (State# s -> (# State# t, MutableArrayArray# u #)) -> State# s -> (State# t -> MutableArrayArray# u -> r) -> r
composes2sAa :: (State# s -> (# State# t, ArrayArray# #))
-> State# s -> (State# t -> ArrayArray# -> r) -> r
composes2sAa State# s -> (# State# t, ArrayArray# #)
f State# s
x State# t -> ArrayArray# -> r
k = case State# s -> (# State# t, ArrayArray# #)
f State# s
x of (# State# t
a, ArrayArray#
b #) -> State# t -> ArrayArray# -> r
k State# t
a ArrayArray#
b
composes2sMAa :: (State# s -> (# State# t, MutableArrayArray# u #))
-> State# s -> (State# t -> MutableArrayArray# u -> r) -> r
composes2sMAa State# s -> (# State# t, MutableArrayArray# u #)
f State# s
x State# t -> MutableArrayArray# u -> r
k = case State# s -> (# State# t, MutableArrayArray# u #)
f State# s
x of (# State# t
a, MutableArrayArray# u
b #) -> State# t -> MutableArrayArray# u -> r
k State# t
a MutableArrayArray# u
b
#endif
#if __GLASGOW_HASKELL__ < 900
composeo1_ :: (BCO# -> (# a #)) -> BCO# -> (a -> r) -> r
composes2so :: (State# s -> (# State# t, BCO# #)) -> State# s -> (State# t -> BCO# -> r) -> r
composeo1_ :: (BCO# -> (# a #)) -> BCO# -> (a -> r) -> r
composeo1_ BCO# -> (# a #)
f BCO#
x a -> r
k = case BCO# -> (# a #)
f BCO#
x of (# a
a #) -> a -> r
k a
a
composes2so :: (State# s -> (# State# t, BCO# #))
-> State# s -> (State# t -> BCO# -> r) -> r
composes2so State# s -> (# State# t, BCO# #)
f State# s
x State# t -> BCO# -> r
k = case State# s -> (# State# t, BCO# #)
f State# s
x of (# State# t
a, BCO#
b #) -> State# t -> BCO# -> r
k State# t
a BCO#
b
#endif

-- | This is an \"inverse\" of 'composes2s_' because sometimes it might be
-- useful to produce a @'State#' s a -> (\# 'State#' s, a \#)@ of your own.
-- Example:
-- 
-- @returnIO x = 'IO' ('decomposes2s_' (\s r -> r s x))@
decomposes2s_ :: (State# s -> (State# t -> a -> (# State# t, a #)) -> (# State# t, a #)) -> State# s -> (# State# t, a #)
decomposes2s_ :: (State# s
 -> (State# t -> a -> (# State# t, a #)) -> (# State# t, a #))
-> State# s -> (# State# t, a #)
decomposes2s_ State# s
-> (State# t -> a -> (# State# t, a #)) -> (# State# t, a #)
f State# s
x = State# s
-> (State# t -> a -> (# State# t, a #)) -> (# State# t, a #)
f State# s
x (\State# t
a a
b -> (# State# t
a, a
b #))

decompose_2__ :: (a -> (b -> c -> (# b, c #)) -> (# b, c #)) -> a -> (# b, c #)
decompose_2__ :: (a -> (b -> c -> (# b, c #)) -> (# b, c #)) -> a -> (# b, c #)
decompose_2__ a -> (b -> c -> (# b, c #)) -> (# b, c #)
f a
x = a -> (b -> c -> (# b, c #)) -> (# b, c #)
f a
x (\b
a c
b -> (# b
a, c
b #))