The Show typeclass abstracts the ability to obtain a String representation of any object.

It can be considered the typeclass equivalent of Java’s Object#toString.

import arrow.*
import arrow.core.extensions.* { }
// 1

Main Combinators


Given an instance of F, it returns the String representation of this instance.

fun String


Arrow provides ShowLaws in the form of test cases for internal verification of lawful instances and third party apps creating their own Show instances.

Creating your own Show instances

Show provides one special instance that potentially can be applicable to most datatypes. It uses Kotlin’s toString method to get an object’s literal representation. This will work well in many cases, specially for data classes.

import arrow.core.*
import arrow.typeclasses.*

// Option is a data class with a single value
Show.any().run { Option.just(1).show() }
// Some(1)
// using invoke constructor
class Person(val firstName: String, val lastName: String)
val personShow = Show<Person> { "Hello $firstName $lastName" }

See Deriving and creating custom typeclass to provide your own Show instances for custom datatypes.

Data types

Module Data types
arrow.core Const, Either, Id, Ior, ListK, MapK, NonEmptyList, Option, SequenceK, SetK, Try, Tuple10, Tuple2, Tuple3, Tuple4, Tuple5, Tuple6, Tuple7, Tuple8, Tuple9, Validated

Type Class Hierarchy

Do you like Arrow?

Arrow Org