Hoogle Search
Within LTS Haskell 24.45 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
persistent-mysql Database.Persist.MySQL Do a bulk insert on the given records in the first parameter. In the event that a key conflicts with a record currently in the database, the second and third parameters determine what will happen. The second parameter is a list of fields to copy from the original value. This allows you to specify which fields to copy from the record you're trying to insert into the database to the preexisting row. The third parameter is a list of updates to perform that are independent of the value that is provided. You can use this to increment a counter value. These updates only occur if the original record is present in the database.
More details on HandleUpdateCollision usage
The [HandleUpdateCollision] parameter allows you to specify which fields (and under which conditions) will be copied from the inserted rows. For a brief example, consider the following data model and existing data set:Item name Text description Text price Double Maybe quantity Int Maybe Primary name
items: +------+-------------+-------+----------+ | name | description | price | quantity | +------+-------------+-------+----------+ | foo | very good | | 3 | | bar | | 3.99 | | +------+-------------+-------+----------+
This record type has a single natural key on itemName. Let's suppose that we download a CSV of new items to store into the database. Here's our CSV:name,description,price,quantity foo,,2.50,6 bar,even better,,5 yes,wow,,
We parse that into a list of Haskell records:records = [ Item { itemName = "foo", itemDescription = "" , itemPrice = Just 2.50, itemQuantity = Just 6 } , Item "bar" "even better" Nothing (Just 5) , Item "yes" "wow" Nothing Nothing ]The new CSV data is partial. It only includes updates from the upstream vendor. Our CSV library parses the missing description field as an empty string. We don't want to override the existing description. So we can use the copyUnlessEmpty function to say: "Don't update when the value is empty." Likewise, the new row for bar includes a quantity, but no price. We do not want to overwrite the existing price in the database with a NULL value. So we can use copyUnlessNull to only copy the existing values in. The final code looks like this: insertManyOnDuplicateKeyUpdate records [ copyUnlessEmpty ItemDescription , copyUnlessNull ItemPrice , copyUnlessNull ItemQuantity ] [] Once we run that code on the database, the new data set looks like this:items: +------+-------------+-------+----------+ | name | description | price | quantity | +------+-------------+-------+----------+ | foo | very good | 2.50 | 6 | | bar | even better | 3.99 | 5 | | yes | wow | | | +------+-------------+-------+----------+
AllOpAnyOperator :: AllOp -> AnyOperatorpostgresql-syntax PostgresqlSyntax.Ast No documentation available.
QualifiedAnyOperator :: ColId -> AnyOperator -> AnyOperatorpostgresql-syntax PostgresqlSyntax.Ast No documentation available.
customizedAnyName :: HeadedParsec Void Text Ident -> HeadedParsec Void Text AnyNamepostgresql-syntax PostgresqlSyntax.Parsing No documentation available.
filteredAnyName :: Foldable t => t Text -> HeadedParsec Void Text AnyNamepostgresql-syntax PostgresqlSyntax.Parsing No documentation available.
ticksFromAny :: (Quantity a, Timed m) => T m t a -> m (T m t Ticks)reactive-midyim Reactive.Banana.MIDI.Time No documentation available.
-
recover-rtti Debug.RecoverRTTI Add level of indirection on the heap (Advanced users only, for most use cases this should not be necessary.) Type recovery in recover-rtti (through classify) works by looking at the values on the heap. For example, if we see a list, we then look at the first element of that list (if any), and if that element happens to be an Int, the inferred type is [Int]. When we show such a list (anythingToString), every element of the list is interpreted as an Int, without doing further type recovery. This works for normal use cases, but fails in low-level code that uses Any to squeeze values of different types into a data structure not designed for that purpose. For example, consider
data T f = T [f Any]
If we call anythingToString on a T value with elements of different types in the list, we get some unexpected results:anythingToString (T [unsafeCoerce (1 :: Int), unsafeCoerce False]) == "T [1,14355032]"
The reason is that the type of the list was inferred as [Int], and hence the Bool was subsequently also interpreted as an Int. BoxAnything helps to resolve the problem. There are ways in which it can be used. First, we can derive the following entirely reasonable Show instance for T:deriving instance Show a => Show (T (K a))
We then getshow (T [K $ BoxAnything (1 :: Int), K $ BoxAnything False]) == "T [K 1,K False]"
Alternatively, we can omit the Show instance for T, to getanythingToString (T [K $ BoxAnything (1 :: Int), K $ BoxAnything False]) == "T [BoxAnything 1,BoxAnything False]"
For this second use case to work, it is critical that BoxAnything is a datatype, not a newtype, so that it actually appears on the heap. BoxAnything :: a -> BoxAnythingrecover-rtti Debug.RecoverRTTI No documentation available.
-
recover-rtti Debug.RecoverRTTI Like traceShow, but using anythingToString
-
recover-rtti Debug.RecoverRTTI Like traceShowId, but using anythingToString