Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Fast [co]product types with a clean syntax. For Cats & Scalaz.

License

NotificationsYou must be signed in to change notification settings

frees-io/iota

Repository files navigation

Build StatusMaven CentralLicenseLatest versionScala.jsGitHub Issues

Iota

Introduction

Iota is a tiny library for fast coproduct types with a syntaxthat cleanly supports the disjunction of any number of types.

Traditional coproduct implementations are implemented as binary treesor linked lists at both the type and value level. The syntax fortraditional coproducts frequently becomes unwieldy as the number ofdisjunct types grows.

// a coproduct of types using scala.util.EithertypeEitherFoo=Either[Int,Either[String,Double]]// a coproduct of type constructors using cats.data.EitherKimportcats.data.EitherKtypeEitherKBar0[A]=EitherK[List,Seq,A]typeEitherKBar[A]=EitherK[Option,EitherKBar0,A]// a coproduct of type constructors using scalaz.Coproductimportscalaz.CoproducttypeCoproductKBar0[A]=Coproduct[List,Seq,A]typeCoproductKBar[A]=Coproduct[Option,CoproductKBar0,A]

Iota coproducts are linked lists at the type level. At the value level,Iota stores the index of the disjunct value's type for quick andconstant time access of the values. This syntax scales cleanly tosupport any number of disjunct types.

// for catsimportiota._importTList.::importTListK.:::// a coproduct of typestypeFoo=Cop[Int::String::Double::TNil]// a coproduct of type constructorstypeBar[A]=CopK[Option:::List:::Seq:::TNilK,A]
// for scalazimportiotaz._importTList.::importTListK.:::// a coproduct of typestypeFoo=Cop[Int::String::Double::TNil]// a coproduct of type constructorstypeBar[A]=CopK[Option:::List:::Seq:::TNilK,A]

Installation

To get started with SBT, simply add the following to your build.sbt file.

For Scala 2.11.x and 2.12.x:

libraryDependencies+="io.frees"%%"iota-core"%"0.3.10"// for catslibraryDependencies+="io.frees"%%"iotaz-core"%"0.3.10"// for scalaz

Or, if using Scala.js (0.6.x):

libraryDependencies+="io.frees"%%%"iota-core"%"0.3.10"// for catslibraryDependencies+="io.frees"%%%"iotaz-core"%"0.3.10"// for scalaz

Cats vs Scalaz

Iota requires either Cats or Scalaz. If you're using Scalaz, use the "iotaz"modules and import from theiotaz package (instead ofiota).

Cats friendly terminology (such as "FunctionK") is used in the iotamodules while Scalaz friendly terminology (such as"NaturalTransformation") is used in the iotaz modules. If you find anissue or inconsistency, please file a GitHub issue and it will be fixed.

The Cats examples will work against Scalaz, and vise versa, so long as thelibrary specific terminology is adjusted. Expect more Scalaz examples as theIota library evolves.

Documentation

Seedocs/cats.md for the Cats specific documentation anddocs/scalaz.md for the Scalaz specific documentation.

Iota in the wild

If you wish to add your library here please consider a PR to include it in the list below.

Commercial Support

47 Degrees offers commercial support for the iota library and associated technologies. To find out more, visit47 Degrees' Open Source Support.

Copyright

Iota is designed and developed by 47 Degrees

Copyright (C) 2016-2018 47 Degrees.http://47deg.com


[8]ページ先頭

©2009-2025 Movatter.jp