| Copyright | (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 Kowainik |
|---|---|
| License | MIT |
| Maintainer | Kowainik <xrom.xkov@gmail.com> |
| Stability | Stable |
| Portability | Portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Relude.Container.One
Description
One is a typeclass for creating structures from a singleton element.
It has three main goals:
- Give a shorter name for the construction: uses
oneinstead of commonsingleton. - Work with monomorphic structures like
TextorIntSet. - Give a clearer and less scary name for cases where you can use
pureor(:[]).
Since: 0.1.0
Documentation
Typeclass for data types that can be created from one element. E.g. lists, non-empty containers, maps.
>>>one True :: [Bool][True]>>>one 'a' :: Text"a">>>one (3, "hello") :: HashMap Int StringfromList [(3,"hello")]
Laws:
single-size:∀ x . size (one x) ≡ 1
(where size is a specific function for each container that returns the size of
this container)
Instances
| One ByteString Source # | Create singleton strict
law> |
Defined in Relude.Container.One Associated Types type OneItem ByteString Source # Methods one :: OneItem ByteString -> ByteString Source # | |
| One ByteString Source # | Create singleton lazy
law> |
Defined in Relude.Container.One Associated Types type OneItem ByteString Source # Methods one :: OneItem ByteString -> ByteString Source # | |
| One ShortByteString Source # | Create singleton
law> |
| One IntSet Source # | Create singleton
law> |
| One Text Source # | Create singleton strict
law> |
| One Text Source # | Create singleton lazy
law> |
| One (NonEmpty a) Source # | Allows to create singleton
law> |
| One (IntMap v) Source # | Create singleton
law> |
| One (Seq a) Source # | Create singleton
law> |
| One (Set a) Source # | Create singleton
law> |
| Hashable a => One (HashSet a) Source # | Create singleton
law> |
| One [a] Source # | Allows to create a singleton list. You might prefer function with name
law> |
| One (Map k v) Source # | Create singleton
law> |
| Hashable k => One (HashMap k v) Source # | Create singleton
law> |