Quick notes on functors
Functors
A functor is a design pattern that allows us to apply a function to a contextualized (wrapped) type. This is accomplished by implementing the map function:
1fmap :: (a -> b) -> f a -> f b
A functor is a design pattern that allows us to apply a function to a contextualized (wrapped) type. This is accomplished by implementing the map function:
1fmap :: (a -> b) -> f a -> f b
Lazy evaluation is a strategy that delays expression evaluation until their value is needed. It also avoids repeated evaluations by returning previously computed results by storing them in a lookup table.
Why isn’t lazy evaluation used …
This implementation is based on the work of Malcolm, and exists because it provides the cleanest use of similar monads.
The base monad wraps an Either class in a Future class:
1import scala.concurrent.{ExecutionContext, Future}
2import scala.util.{ …Generate a random string using the command line:
1cat /dev/urandom | tr -cd [:graph:] | head -c 32
On OSX, the previous command might return a tr: Illegal byte sequence error, so try:
1export LC_ALL=C; cat /dev/urandom | tr -cd [:graph:] | head -c 32 …We start by adding our imports.
1import java.nio.charset.StandardCharsets
2import java.security.Key
3import java.util.Base64
4import javax.crypto.Cipher
5import javax.crypto.spec.SecretKeySpec
For this example we’re going to use the CBC (Cipher …
In this article we are going to set up dynamodb on our local development environment. A short description of a couple of easy-to-use management tools is included.
Start by downloading the DynamoDB development version. Uncompress the file and …
We are going to cite the definition of a Monoid found on this post:
Conceptually, a monoid is anything that:
- Has a "zero-value": `mempty`, e.g., `0`
- Can be "appended" together: `mappend`, e.g., `+`
- Has an identity with the …
sbt projects use the same structure as Maven. Creating a project from scratch involve the following steps:
1mkdir some-new-project
2cd some-new-project
3mkdir -p src/{main,test}/{resources,scala}
4mkdir project
Create a …
In this article we are going to use scala to send a message via Telegram. The process is very simple and pretty much involves setting up a bot and making a GET request to Telegram’s api.
The Telegram app on the phone has more features than its …
A fat jar is a jar file that contains any dependencies required by a Java or Scala program. Deployment becomes an easy task if we only have to deal with one single file. In this article we’ll go through the steps required to create a fat jar …