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

Copyright(C) 2016 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 come up in GHC.Prim but in principle other cases could be added too.

Synopsis

Documentation

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

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

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

composed2ii :: (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 #

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

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

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

composes2sAa :: (State# s -> (#State# t, ArrayArray##)) -> State# s -> (State# t -> ArrayArray# -> 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 #

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

composes2sSMa :: (State# s -> (#State# t, SmallMutableArray# u a#)) -> State# s -> (State# t -> SmallMutableArray# u a -> 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 #

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

composes2sMAa :: (State# s -> (#State# t, MutableArrayArray# u#)) -> State# s -> (State# t -> MutableArrayArray# u -> 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 a#)) -> State# s -> (State# t -> MVar# u a -> 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 #

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

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

composes2sv :: (State# s -> (#State# t, MutVar# u a#)) -> State# s -> (State# t -> MutVar# u a -> 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 #

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

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

composes3si_ :: (State# s -> (#State# t, Int#, a#)) -> State# s -> (State# t -> Int# -> a -> 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 #

decomposes2s_ :: (State# s -> (State# s -> a -> (#State# s, a#)) -> (#State# s, a#)) -> State# s -> (#State# s, 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))