box-tuples-0.2.0.2: A hack to use GHC.Prim primitives in GHCi

Copyright(C) 20162020 mniip
LicenseMIT
Maintainermniip <mniip@mniip.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Tuple.Unboxed

Description

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:

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.

Synopsis

Documentation

compose_1_ :: (a -> (#b#)) -> a -> (b -> r) -> r Source #

composei1_ :: (Int# -> (#a#)) -> Int# -> (a -> r) -> r Source #

composeo1_ :: (BCO# -> (#a#)) -> BCO# -> (a -> r) -> r Source #

composep1_ :: (Addr# -> (#a#)) -> Addr# -> (a -> r) -> r Source #

composew1_ :: (Word# -> (#a#)) -> Word# -> (a -> r) -> r Source #

compose_2ab :: (a -> (#Array# e, ByteArray##)) -> a -> (Array# e -> ByteArray# -> r) -> r Source #

composed2ii :: (Double# -> (#Int#, Int##)) -> Double# -> (Int# -> Int# -> r) -> r Source #

composed2llii :: (Double# -> (#Int#, Int##)) -> Double# -> (Int# -> Int# -> r) -> r Source #

composef2ii :: (Float# -> (#Int#, Int##)) -> Float# -> (Int# -> Int# -> r) -> r Source #

composei2i_ :: (Int# -> (#Int#, a#)) -> Int# -> (Int# -> a -> r) -> r Source #

composei2ib :: (Int# -> (#Int#, ByteArray##)) -> Int# -> (Int# -> ByteArray# -> r) -> r Source #

composei2ii :: (Int# -> (#Int#, Int##)) -> Int# -> (Int# -> Int# -> r) -> r Source #

composeli2ib :: (Int# -> (#Int#, ByteArray##)) -> Int# -> (Int# -> ByteArray# -> r) -> r Source #

composelli2ib :: (Int# -> (#Int#, ByteArray##)) -> Int# -> (Int# -> ByteArray# -> r) -> r Source #

composellw2ib :: (Word# -> (#Int#, ByteArray##)) -> Word# -> (Int# -> ByteArray# -> r) -> r Source #

composelw2ib :: (Word# -> (#Int#, ByteArray##)) -> Word# -> (Int# -> ByteArray# -> r) -> r Source #

composep2ib :: (Addr# -> (#Int#, ByteArray##)) -> Addr# -> (Int# -> ByteArray# -> r) -> r Source #

composes2s_ :: (State# s -> (#State# t, a#)) -> State# s -> (State# t -> a -> r) -> r Source #

composes2sa :: (State# s -> (#State# t, Array# e#)) -> State# s -> (State# t -> Array# e -> r) -> r Source #

composes2sb :: (State# s -> (#State# t, ByteArray##)) -> State# s -> (State# t -> ByteArray# -> r) -> r Source #

composes2sc :: (State# s -> (#State# t, Char##)) -> State# s -> (State# t -> Char# -> r) -> r Source #

composes2sd :: (State# s -> (#State# t, Double##)) -> State# s -> (State# t -> Double# -> r) -> r Source #

composes2sf :: (State# s -> (#State# t, Float##)) -> State# s -> (State# t -> Float# -> r) -> r Source #

composes2si :: (State# s -> (#State# t, Int##)) -> State# s -> (State# t -> Int# -> r) -> r Source #

composes2sli :: (State# s -> (#State# t, Int##)) -> State# s -> (State# t -> Int# -> r) -> r Source #

composes2slli :: (State# s -> (#State# t, Int##)) -> State# s -> (State# t -> Int# -> r) -> r Source #

composes2sllw :: (State# s -> (#State# t, Word##)) -> State# s -> (State# t -> Word# -> r) -> r Source #

composes2slw :: (State# s -> (#State# t, Word##)) -> State# s -> (State# t -> Word# -> r) -> r Source #

composes2sMa :: (State# s -> (#State# t, MutableArray# u e#)) -> State# s -> (State# t -> MutableArray# u e -> r) -> r Source #

composes2sMb :: (State# s -> (#State# t, MutableByteArray# u#)) -> State# s -> (State# t -> MutableByteArray# u -> r) -> r Source #

composes2sMv :: (State# s -> (#State# t, MVar# u e#)) -> State# s -> (State# t -> MVar# u e -> r) -> r Source #

composes2so :: (State# s -> (#State# t, BCO##)) -> State# s -> (State# t -> BCO# -> r) -> r Source #

composes2sp :: (State# s -> (#State# t, Addr##)) -> State# s -> (State# t -> Addr# -> r) -> r Source #

composes2sSn :: (State# s -> (#State# t, StableName# a#)) -> State# s -> (State# t -> StableName# a -> r) -> r Source #

composes2sSp :: (State# s -> (#State# t, StablePtr# a#)) -> State# s -> (State# t -> StablePtr# a -> r) -> r Source #

composes2st :: (State# s -> (#State# t, ThreadId##)) -> State# s -> (State# t -> ThreadId# -> r) -> r Source #

composes2sTv :: (State# s -> (#State# t, TVar# u e#)) -> State# s -> (State# t -> TVar# u e -> r) -> r Source #

composes2sv :: (State# s -> (#State# t, MutVar# u e#)) -> State# s -> (State# t -> MutVar# u e -> r) -> r Source #

composes2sw :: (State# s -> (#State# t, Word##)) -> State# s -> (State# t -> Word# -> r) -> r Source #

composes2sWp :: (State# s -> (#State# t, Weak# a#)) -> State# s -> (State# t -> Weak# a -> r) -> r Source #

composew2ib :: (Word# -> (#Int#, ByteArray##)) -> Word# -> (Int# -> ByteArray# -> r) -> r Source #

composew2wi :: (Word# -> (#Word#, Int##)) -> Word# -> (Word# -> Int# -> r) -> r Source #

composew2ww :: (Word# -> (#Word#, Word##)) -> Word# -> (Word# -> Word# -> r) -> r Source #

compose_3pab :: (a -> (#Addr#, Array# e, ByteArray##)) -> a -> (Addr# -> Array# e -> ByteArray# -> r) -> r Source #

compose_3pba :: (a -> (#Addr#, ByteArray#, Array# e#)) -> a -> (Addr# -> ByteArray# -> Array# e -> r) -> r Source #

composed3iib :: (Double# -> (#Int#, Int#, ByteArray##)) -> Double# -> (Int# -> Int# -> ByteArray# -> r) -> r Source #

composed3iii :: (Double# -> (#Int#, Int#, Int##)) -> Double# -> (Int# -> Int# -> Int# -> r) -> r Source #

composef3iib :: (Float# -> (#Int#, Int#, ByteArray##)) -> Float# -> (Int# -> Int# -> ByteArray# -> r) -> r Source #

composei3iii :: (Int# -> (#Int#, Int#, Int##)) -> Int# -> (Int# -> Int# -> Int# -> r) -> r Source #

composes3s__ :: (State# s -> (#State# t, a, b#)) -> State# s -> (State# t -> a -> b -> r) -> r Source #

composes3sii :: (State# s -> (#State# t, Int#, Int##)) -> State# s -> (State# t -> Int# -> Int# -> r) -> r Source #

composes3si_ :: (State# s -> (#State# t, Int#, a#)) -> State# s -> (State# t -> Int# -> a -> r) -> r Source #

composes3spw :: (State# s -> (#State# t, Addr#, Word##)) -> State# s -> (State# t -> Addr# -> Word# -> r) -> r Source #

composed4iwwi :: (Double# -> (#Int#, Word#, Word#, Int##)) -> Double# -> (Int# -> Word# -> Word# -> Int# -> r) -> r Source #

composes4siii :: (State# s -> (#State# t, Int#, Int#, Int##)) -> State# s -> (State# t -> Int# -> Int# -> Int# -> r) -> r Source #

composes2sSa :: (State# s -> (#State# t, SmallArray# e#)) -> State# s -> (State# t -> SmallArray# e -> r) -> r Source #

composes2sSMa :: (State# s -> (#State# t, SmallMutableArray# u e#)) -> State# s -> (State# t -> SmallMutableArray# u e -> r) -> r Source #

composes3s_2__ :: (State# s -> (#State# t, a, (#b, c#)#)) -> State# s -> (State# t -> a -> b -> c -> r) -> r Source #

composes2sAa :: (State# s -> (#State# t, ArrayArray##)) -> State# s -> (State# t -> ArrayArray# -> r) -> r Source #

composes2sMAa :: (State# s -> (#State# t, MutableArrayArray# u#)) -> State# s -> (State# t -> MutableArrayArray# u -> r) -> r Source #

decomposes2s_ :: (State# s -> (State# t -> a -> (#State# t, a#)) -> (#State# t, a#)) -> State# s -> (#State# t, a#) Source #

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))

decompose_2__ :: (a -> (b -> c -> (#b, c#)) -> (#b, c#)) -> a -> (#b, c#) Source #