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)
Associated types
type family OneItem xType of a single element of the structure.
Instances14One, …
One ByteStringDefined in relude-1.2.0.0 · Relude.Container.OneCreate singleton strict ByteString.
Example1 expression one 97 :: ByteString"a"
law> length (one x) ≡ 1One ByteStringDefined in relude-1.2.0.0 · Relude.Container.OneOne ShortByteStringDefined in relude-1.2.0.0 · Relude.Container.OneCreate singleton ShortByteString.
Example1 expression one 97 :: ShortByteString"a"
law> length (one x) ≡ 1One IntSetDefined in relude-1.2.0.0 · Relude.Container.OneOne TextDefined in relude-1.2.0.0 · Relude.Container.OneOne TextDefined in relude-1.2.0.0 · Relude.Container.OneHashable a => One (HashSet a)Defined in relude-1.2.0.0 · Relude.Container.OneOne (IntMap v)Defined in relude-1.2.0.0 · Relude.Container.OneOne (Seq a)Defined in relude-1.2.0.0 · Relude.Container.OneOne (Set a)Defined in relude-1.2.0.0 · Relude.Container.OneOne (NonEmpty a)Defined in relude-1.2.0.0 · Relude.Container.OneOne [a]Defined in relude-1.2.0.0 · Relude.Container.OneHashable k => One (HashMap k v)Defined in relude-1.2.0.0 · Relude.Container.OneOne (Map k v)Defined in relude-1.2.0.0 · Relude.Container.One