-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Singleton Tuple -- -- This package is a compatibility package for a singleton data type -- --
-- data Solo a = MkSolo a ---- -- Note: it's not a newtype -- -- Solo is available in base-4.16 (GHC-9.2). @package OneTuple @version 0.4 -- | Solo fills the tuple gap with a singleton tuple. -- -- Solo does not support the usual parenthesized tuple -- syntax. -- -- Solo -- --
-- index :: Array a -> Int -> a ---- -- Now imagine that someone wants to extract a value from an array and -- store it in a lazy-valued finite map/dictionary: -- --
-- insert "hello" (arr index 12) m ---- -- This can actually lead to a space leak. The value is not actually -- extracted from the array until that value (now buried in a map) is -- forced. That means the entire array may be kept live by just that -- value! Often, the solution is to use a strict map, or to force the -- value before storing it, but for some purposes that's undesirable. -- -- One common solution is to include an indexing function that can -- produce its result in an arbitrary Applicative context: -- --
-- indexA :: Applicative f => Array a -> Int -> f a ---- -- When using indexA in a pure context, Solo -- serves as a handy Applicative functor to hold the result. You -- could write a non-leaky version of the above example thus: -- --
-- case arr indexA 12 of -- Solo a -> insert "hello" a m ---- -- While such simple extraction functions are the most common uses for -- unary tuples, they can also be useful for fine-grained control of -- strict-spined data structure traversals, and for unifying the -- implementations of lazy and strict mapping functions. data Solo a Solo :: a -> Solo a pattern MkSolo :: a -> Solo a getSolo :: Solo a -> a -- | This is a module to help migration from OneTuple to -- Solo. Migrate to use Data.Tuple from -- base-4.16 or Data.Tuple.Solo with all GHCs. -- -- The pattern synonym is provided for GHCs supporting pattern synonyms -- (7.8+) -- | Deprecated: Use Data.Tuple.Solo module Data.Tuple.OneTuple type OneTuple = Solo pattern OneTuple :: a -> Solo a only :: OneTuple a -> a -- | This module provides TH helpers, which use Solo from this -- package, for 1-tuples. module Data.Tuple.Solo.TH tupE :: Quote m => [m Exp] -> m Exp