You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I Didn't Know about Functional Programming until 2021
A hom-functor is usually implemented in Scala as the reader functor. The type itself is essentially a hom-set, but if we fix the domain to a particular type, we get a functor:
// A hom-set Hom(A, X)typeReader[A, X] =A=>X
// A hom-functor X => Hom(String, X) or Hom(String, -)
What I Didn't Know about Functional Programming until 2020
What I Didn't Know about Functional Programming until 2020
Programming using a series of transformations and aggregations, something I've been doing for years, is known as programming in the map/reduce style.
The more abstract the type is, the greater its cardinality, and the smaller the set of operations it supports. So make use of universal quantifiers, particularly by implementing fully parametric functions. They guide you on how to implement their term-level definitions by narrowing down the number of possible implementations. In other words, the type system of Scala (or Haskell, for that matter) is not only great for capturing compile-time errors, but is also capable of leading you to the correct solution.
You can encode union types by combining different Scala features such as type constructors, subtyping and implicits, and by taking advantage of the Curry-Howard Isomorphism and De Morgan's Laws for neg
Greg Beech wrote an article on Akka HTTP Entity Validation.
This post is on the same topic, except we are going to use typeclass instances, as opposed to subtyping, for form validations.
Sample Problem: User Regsitration
To start with, let us suppose that we are working on some sort of user management service using Scala/Akka. However, here we are only going to focus on the registration part, in which the client is expected to send a user data, in JSON format; and the server needs to validate them, and save the user if the validations succeed, or reject the request with all the errors detected. That said, we should keep in mind that our validations may be used through out the entire codebase, not just in the user registration endpoint.