A mini Scala utility library. Compatible with functional programming beginners. For the JVM and Scala.js.
Currently, Hamsters supports :
- Validation
- Monad transformers
- Enum typeclass
- Default values for options (orEmpty)
- HLists
- Union types
- NonEmptyList
- Show
- mapN
- Memoization
- Retry
With SBT :
libraryDependencies ++= Seq(
"io.github.scala-hamsters" %% "hamsters" % "2.5.0"
)
With Maven :
<dependency>
<groupId>io.github.scala-hamsters</groupId>
<artifactId>hamsters_${scala.version}</artifactId>
<version>2.5.0</version>
</dependency>
For Scala.js :
libraryDependencies ++= Seq(
"io.github.scala-hamsters" %%% "hamsters" % "2.5.0"
)
You can try quickly and easily Hamsters with ScalaFiddle.
Example : https://scalafiddle.io/sf/BDm8W4U/0
Alternatively, a REPL script is provided. try-hamster.sh
script downloads and installs
Coursier, Ammonite REPL and Hamsters dependency.
No dependencies needed other than a JDK.
PS: The macros don't work with the REPL
curl -s https://raw.githubusercontent.com/scala-hamsters/hamsters/master/scripts/try-hamsters.sh | bash
Loading...
Welcome to the Ammonite Repl 1.0.1
(Scala 2.12.3 Java 1.8.0_151)
@ val noneString: Option[String] = None
noneString: Option[String] = None
@ noneString.orEmpty
res1: String = ""
@ val hlist1: Double :: String :: HNil = 2.0 :: "hi" :: HNil
hlist1: Double :: String :: HNil = HCons(2.0, HCons("hi", HNIL))
@ exit
Bye!
Validation.result
has been renamed to Validation.run
.
See hamsters-extensions for more information.
You can find the API documentation here.
To Laurencebeillaux who created the Hamsters logo.