úÎ!6P5ôSafe list-singletonO(1)5 Create a non-empty list with a single element in it.singleton "pepperoni""pepperoni" :| []RIf you want to create a regular list with a single element in it, consider using  from Data.List.Singleton.Safe5èlist-singletonO(1)+ Create a list with a single element in it.singleton "pepperoni" ["pepperoni"]NThere are many other ways to construct lists, so why might you prefer to use 1? Here's a comparison with a few popular methods:6If you already have the element as a named value like x-, you can wrap it up in a list literal: [x]/. You should prefer doing that to calling . -- Instead of this: " x -- Consider this instead: [x] ^If you don't already have the element named, you can introduce a name by using a lambda:  (\ x -> [x])Ü. This is perhaps the most common way to create a singleton list, but it focuses more on mechanics than intent. Also it can be get little noisy, especially with identifiers longer than single letters like x. H-- Instead of this: g . (\ x -> [x]) . f -- Consider this instead: g .  . f TIf you don't want to introduce a name at all, you can use an operator section: (: [])Æ. This is more advanced because it requires familiarity with operator sections, list constructors, and how lists are desugared. (If you're not familiar with those concepts, the expression (: []) is the same as (\ x -> x : []), which is the same as  (\ x -> [x])~.) While those concepts are perhaps fundamental to understanding Haskell, you can get surprisingly far without them. B-- Instead of this: g . (: []) . f -- Consider this instead: g .  . f TIf you want to avoid lambdas, lists, and operators completely, you can use the  method from the E type class. This has a lot of upsides: it's short, it's in the PreludeŒ, and it's easy to search for. Unfortunately it has one downside: it's polymorphic. That means it can return any type that has an  instance, like  or . By comparison H is monomorphic and can only produce a list. Usually the fact that [ is polymorphic isn't a problem, but sometimes it can produce confusing errors. Using @ can be a good way to force polymorphic code to use a list.import Data.Char (chr)print (pure (chr 72))...<interactive>:2:8: error:? * Ambiguous type variable `f0' arising from a use of `pure'C prevents the constraint `(Applicative f0)' from being solved.I Probable fix: use a type annotation to specify what `f0' should be....print (singleton (chr 72))"H" -- Instead of this: g . $ . f -- Consider this instead: g .  . f fThe name "singleton" was chosen to mirror similar functions provided by other libraries. For example: \https://hackage.haskell.org/package/binary-0.8.7.0/docs/Data-Binary-Builder.html#v:singletonData.Binary.Builder.singleton ^https://hackage.haskell.org/package/bytestring-0.10.10.0/docs/Data-ByteString.html#v:singletonData.ByteString.singleton Zhttps://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Sequence.html#v:singletonData.Sequence.singleton Phttps://hackage.haskell.org/package/text-1.2.4.0/docs/Data-Text.html#v:singletonData.Text.singleton Note that  is lazy in its argument.length (singleton undefined)1If you want to create a 3 list with a single element in it, consider using  from Data.List.NonEmpty.Singleton.   -list-singleton-1.0.0.1-2dlpWyrMnPw4thMeVH8M97Data.List.NonEmpty.SingletonData.List.Singleton singletonData.List.NonEmptyNonEmptybaseGHC.Basepure Applicative GHC.MaybeMaybeghc-prim GHC.TypesIO