With the release of the Hooks API into React new opportunities arise to eliminate even more boilerplate. The one I want to talk about here is Suspense.

Kind of a V3 if you ask me

If you don’t know it, you should check out the official page. To describe it shortly, it’s a component, like any other, which takes two props :

  • The Promise of a component to render, once it’s available.
  • A loader component to display until the promise is fulfilled.

The use case most people write about involves the import(...) syntax. But that’s not what I’m after here. …


Type refinement is the process of specifying a type. In vanilla Scala this can be done using the with keyword. It combines two types into one, returning their intersection.

In this example, the UserAndClient is the intersection of User and Client .

So, what about it? Well, some days ago I was writing something like this :

Note that the return type of product is T1 with T2 . Therefore, the compiler should be able to resolve implicitly any combination of existing IntGenerator right? A IntGenerator[Client with User] for example?

Nope, compiler can’t find it. Except if I…


Are you working in a limited environment? You cannot choose your build system ? Or maybe you are a fan of maven? Even so, you still want to build an application in Scala with Play Framework 2? This article is for YOU.

Let’s begin by defining a very simple pom.xml.

First, let’s add Scala :

Then I’ll add sbt to maven :

Yes, this plugin will ask maven to run SBT. We need this as play cannot work without SBT plugins.

Next is play himself :

The play plugin adds maven goals to execute play commands.


Note: more details about intersection type in my previous article.

The intersection of several types creates a new type from existing one.

The newly created type can hold values matching its components definition and can use the functions from all types it was created from. Following the example: a FlyingFish will be a Bird and a Fish and can use swim and fly .

Do it in Scala

If you are interested in Scala you may have heard of Scala 3 additions. One of the most welcomed is Union Types.

But no one is talking about its complement: the Intersection type. Maybe it’s…


Do you now about union and intersection types? They are widely used but rarely named. The only programming language I know about containing these features and daring to call them this way is Typescript.

A simple definition of Union and Intersection Types

In Typescript, union and intersection are defined in the Advanced Types section.

An intersection type combines multiple types into one.

A union type describes a value that can be one of several types.

Usage and notation are quite simple, the & symbol is used to build an intersection while the | symbol is for union.

If you have some history in programming, you may notice these…


Since I published my article Reduce the domain of your types with Refined I received some thank’s and a lot of questions of the “wtf is this library” kind. In this article I aim to answer these questions and to help you understand the benefits and drawbacks of Refined.

So, what is Refined ?

Refined is a Scala library, a port of an Haskell library. It aims at helping developers constrain types.

In the above example I defined a PositiveInt type. Its possible values range from 0 to Int.MaxValue. Now, if I want a function to take a positive integer as its input, I…


Some days ago one of my coworker asked me about Refined. He said he couldn’t find any explanation about what Refined does. After some thinking I came back with this : Refined let you reduce the domain of your Types.

Refined

But first, what is Refined ? Refined is a Scala library. More precisely it’s a port of an Haskell library to Scala. Even if it came from Haskell, it’s not complicated to use. It is complicated under the hood but that’s out of this article’s scope. Let’s just say Refined let you write this:

It’s pretty self-explaining but let’s…

Methrat0n

Lead Dev && Aspiring Software Craftsman

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store