Data.Tuple.OneTuple

OneTuple-0.2.1: Singleton Tuple

Safe Haskell | Safe
Language | Haskell98

Data.Tuple.OneTuple

Description

OneTuple fills the tuple gap with a singleton tuple.

OneTuple does not support the usual parenthesized tuple syntax.

OneTuple

- has the expected laziness properties
- can be pattern-matched
- ships with instances for several standard type classes, including all those supported by H98-standard tuples
- requires no language extensions, except for hierarchical modules

Synopsis

- data OneTuple a = OneTuple a
- only :: OneTuple a -> a

# Documentation

data OneTuple a #

OneTuple is the singleton tuple data type.

Constructors

OneTuple a | singleton tuple constructor

Instances

Monad OneTuple # |
Methods (>>=) :: OneTuple a -> (a -> OneTuple b) -> OneTuple b # (>>) :: OneTuple a -> OneTuple b -> OneTuple b # return :: a -> OneTuple a # fail :: String -> OneTuple a #
Functor OneTuple # |
Methods fmap :: (a -> b) -> OneTuple a -> OneTuple b # (<$) :: a -> OneTuple b -> OneTuple a #
MonadFix OneTuple # |
Methods mfix :: (a -> OneTuple a) -> OneTuple a #
Applicative OneTuple # |
Methods pure :: a -> OneTuple a # (<*>) :: OneTuple (a -> b) -> OneTuple a -> OneTuple b # liftA2 :: (a -> b -> c) -> OneTuple a -> OneTuple b -> OneTuple c # (*>) :: OneTuple a -> OneTuple b -> OneTuple b # (<*) :: OneTuple a -> OneTuple b -> OneTuple a #
Foldable OneTuple # |
Methods fold :: Monoid m => OneTuple m -> m # foldMap :: Monoid m => (a -> m) -> OneTuple a -> m # foldr :: (a -> b -> b) -> b -> OneTuple a -> b # foldr' :: (a -> b -> b) -> b -> OneTuple a -> b # foldl :: (b -> a -> b) -> b -> OneTuple a -> b # foldl' :: (b -> a -> b) -> b -> OneTuple a -> b # foldr1 :: (a -> a -> a) -> OneTuple a -> a # foldl1 :: (a -> a -> a) -> OneTuple a -> a # toList :: OneTuple a -> [a] # null :: OneTuple a -> Bool # length :: OneTuple a -> Int # elem :: Eq a => a -> OneTuple a -> Bool # maximum :: Ord a => OneTuple a -> a # minimum :: Ord a => OneTuple a -> a # sum :: Num a => OneTuple a -> a # product :: Num a => OneTuple a -> a #
Traversable OneTuple # |
Methods traverse :: Applicative f => (a -> f b) -> OneTuple a -> f (OneTuple b) # sequenceA :: Applicative f => OneTuple (f a) -> f (OneTuple a) # mapM :: Monad m => (a -> m b) -> OneTuple a -> m (OneTuple b) # sequence :: Monad m => OneTuple (m a) -> m (OneTuple a) #
Bounded a => Bounded (OneTuple a) # |
Methods minBound :: OneTuple a # maxBound :: OneTuple a #
Enum a => Enum (OneTuple a) # |
Methods succ :: OneTuple a -> OneTuple a # pred :: OneTuple a -> OneTuple a # toEnum :: Int -> OneTuple a # fromEnum :: OneTuple a -> Int # enumFrom :: OneTuple a -> [OneTuple a] # enumFromThen :: OneTuple a -> OneTuple a -> [OneTuple a] # enumFromTo :: OneTuple a -> OneTuple a -> [OneTuple a] # enumFromThenTo :: OneTuple a -> OneTuple a -> OneTuple a -> [OneTuple a] #
Eq a => Eq (OneTuple a) # |
Methods (==) :: OneTuple a -> OneTuple a -> Bool # (/=) :: OneTuple a -> OneTuple a -> Bool #
Ord a => Ord (OneTuple a) # |
Methods compare :: OneTuple a -> OneTuple a -> Ordering # (<) :: OneTuple a -> OneTuple a -> Bool # (<=) :: OneTuple a -> OneTuple a -> Bool # (>) :: OneTuple a -> OneTuple a -> Bool # (>=) :: OneTuple a -> OneTuple a -> Bool # max :: OneTuple a -> OneTuple a -> OneTuple a # min :: OneTuple a -> OneTuple a -> OneTuple a #
Read a => Read (OneTuple a) # |
Methods readsPrec :: Int -> ReadS (OneTuple a) # readList :: ReadS [OneTuple a] # readPrec :: ReadPrec (OneTuple a) # readListPrec :: ReadPrec [OneTuple a] #
Show a => Show (OneTuple a) # |
Methods showsPrec :: Int -> OneTuple a -> ShowS # show :: OneTuple a -> String # showList :: [OneTuple a] -> ShowS #
Ix a => Ix (OneTuple a) # |
Methods range :: (OneTuple a, OneTuple a) -> [OneTuple a] # index :: (OneTuple a, OneTuple a) -> OneTuple a -> Int # unsafeIndex :: (OneTuple a, OneTuple a) -> OneTuple a -> Int inRange :: (OneTuple a, OneTuple a) -> OneTuple a -> Bool # rangeSize :: (OneTuple a, OneTuple a) -> Int # unsafeRangeSize :: (OneTuple a, OneTuple a) -> Int
Monoid a => Monoid (OneTuple a) # |
Methods mempty :: OneTuple a # mappend :: OneTuple a -> OneTuple a -> OneTuple a # mconcat :: [OneTuple a] -> OneTuple a #

only #

Arguments

:: OneTuple a | takes a singleton tuple argument
-> a | returns the only element in the tuple

The `only` function extracts the OneTuple's only member. (Compare to `fst` and `snd`.)