In Haskell, is there a built-in function that creates a list of one element?
haskell, list
Solution
Monadic return:
return x
Or:
(:[]) x
It's less characters, but more shift-key usage, so might be harder to type.
Problem
Looking for a built-in function that will do the following: ``` mklist x = [x] ``` The benefit is that I can use it in a composition to create a list of one element. Understand that (replicate 1) is available but is there a more direct function? Would be useful in situations like this: ``` ["Alice", "Bob", "Charlie"] >>= mklist . ("Hello " ++) ```