-
A functional wrapper around the .net AWS DynamoDB SDK
2019-11-29
We’re going to take a tour of some F# capabilities and use them to enforce the constraints of the DynamoDB client. We’ll look at domain modeling with discriminated unions, data access using the reader applicative, and error handling with the result type. DynamoDB and Data Types Before we get started, let’s summarise DynamoDB and its supported types. DynamoDB is a key-value & document database. DynamoDB tables are schemaless so each record can contain a different number of attributes. A record attribute has a string name and a value that is one of three types: Scalar, Set, and Document. A Scalar is a single value of a particular primitive type: string, number, boolean, binary or null. Number and binary values require string conversion before being sent over the network. …
-
Combining monads
2019-08-02
The F# Result<'a,'b> type allows for concise control flow syntax. The async { ... } computation expression similarly minimizes the noise of asynchrony. Throw in the Writer monad for logging minus the intrinsic IO statements. How do you get the benefits of all three together? You need to combine… Source code gist. Writer The Result and Async types are core types in F# but Writer is not so we need a bit of boilerplate to get going. We define a single case union type in which the single case is parameterized with a function. The function expects a unit and returns a tuple. See this post for details. …