insert

The insert function takes an element and a list and inserts the element into the list at the first position where it is less than or equal to the next element. In particular, if the list is sorted before the call, the result will also be sorted. It is a special case of insertBy, which allows the programmer to supply their own comparison function.

Examples

>>> insert (-1) [1, 2, 3]
[-1,1,2,3]
>>> insert 'd' "abcefg"
"abcdefg"
>>> insert 4 [1, 2, 3, 5, 6, 7]
[1,2,3,4,5,6,7]
insert x xs inserts x into the last position in xs where it is still less than or equal to the next element. In particular, if the list is sorted beforehand, the result will also be sorted.
Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value, i.e. insert is equivalent to insertWith const.
insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
insert 5 'x' empty                         == singleton 5 'x'
Add a value to the set. There is no left- or right bias for IntSets.
Insert a new key and value in the map. If the key is already present in the map, the associated value is replaced with the supplied value. insert is equivalent to insertWith const.
insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
insert 5 'x' empty                         == singleton 5 'x'
Insert an element in a set. If the set already contains an element equal to the given value, it is replaced with the new value.
Associate the specified value with the specified key in this map. If this map previously contained a mapping for the key, the old value is replaced.
Associate the specified value with the specified key in this map. If this map previously contained a mapping for the key, the old value is replaced.
Insert an element at the given position in this array, increasing its size by one.
Add the specified value to this set.
>>> HashSet.insert 1 HashSet.empty
fromList [1]
Inserts a single package into the index. This is equivalent to (but slightly quicker than) using mappend or merge with a singleton index.
Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value, i.e. insert is equivalent to insertWith const.
insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
insert 5 'x' empty                         == singleton 5 'x'
Add a value to the set. There is no left- or right bias for Word64Sets.
Create a new record in the database, returning an automatically created key (in SQL an auto-increment id).

Example usage

Using schema-1 and dataset-1, let's insert a new user John.
insertJohn :: MonadIO m => ReaderT SqlBackend m (Key User)
insertJohn = insert $ User "John" 30
johnId <- insertJohn
The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id   |name  |age  |
+-----+------+-----+
|1    |SPJ   |40   |
+-----+------+-----+
|2    |Simon |41   |
+-----+------+-----+
|3    |John  |30   |
+-----+------+-----+
Insert an element in the metadatas, if an element with the same key is present, it is overwritten.
A synonym for &, to avoid conflicts with the similarly named operator in Data.Function.
Insert a key-value pair into the headers map. If the key already exists in the map, the values are catenated with ", ". Example:
ghci> :set -XOverloadedStrings
ghci> let hdrs = H.insert "Accept" "text/plain" $ H.empty
ghci> hdrs
H {unH = [("accept","text/plain")]}
ghci> H.insert "Accept" "text/html" $ hdrs
H {unH = [("accept","text/plain,text/html")]}
Inserts a key/value mapping into a hash table, replacing any existing mapping for that key. O(n) worst case, O(1) amortized.
See the documentation for this function in insert.