From 7c930ebe5194c7cc804bddf32a3b13c891fb292d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Mayer?= <a-mikmay@microsoft.com> Date: Mon, 21 Dec 2015 16:22:13 +0100 Subject: [PATCH] Added Either[A, B] in the leon Library --- library/lang/Either.scala | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 library/lang/Either.scala diff --git a/library/lang/Either.scala b/library/lang/Either.scala new file mode 100644 index 000000000..9cc2ea4e9 --- /dev/null +++ b/library/lang/Either.scala @@ -0,0 +1,27 @@ +/* Copyright 2009-2015 EPFL, Lausanne */ + +package leon.lang + +import leon.annotation._ + +/** + * @author Viktor + */ +@library +sealed abstract class Either[A,B] { + def isLeft : Boolean + def isRight : Boolean + def swap : Either[B,A] +} +@library +case class Left[A,B](content: A) extends Either[A,B] { + def isLeft = true + def isRight = false + def swap = Right[B,A](content) +} +@library +case class Right[A,B](content: B) extends Either[A,B] { + def isLeft = false + def isRight = true + def swap = Left[B,A](content) +} \ No newline at end of file -- GitLab