avatar

Andres Jaimes

Monoid definition and examples

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 …

Creating an sbt project from scratch

Files and project structure

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 …

Sending a message using telegram and scala

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 …

Undoing the Last Git Commit

A command so important, it deserves its own page:

1git reset --soft HEAD~1

The previous command undoes the last commit to git. I think this is one of those commands that I have typed many times during the last year. It’s very important to know …

Testing scala classes and controllers

This article discusses different approaches for testing classes, services, and PlayFramework controllers using scalatest.

Setting up the project dependencies

First step is to add to build.sbt the next dependency:

1"org.scalatest" %% …

Enumerations

Using case object

Unlike other languages, Scala does not have a keyword for enumerations. One way to implement them is by using case objects. For example:

1sealed trait OperatingSystem extends Product with Serializable
2
3object OperatingSystem {
4 …