Skip to content

Commit

Permalink
Move readme changes to mdoc source file
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilquist committed Jan 9, 2024
1 parent 0443294 commit 7d3b97c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Invariant semigroupals are much more general than (covariant) functors, which me

```scala
val fooOrdering = (summon[Ordering[Int]] *: summon[Ordering[String]]).to[Foo]
// fooOrdering: Ordering[Foo] = scala.math.Ordering$$anon$1@39e8f45c
// fooOrdering: Ordering[Foo] = scala.math.Ordering$$anon$1@771e394c
```

## Library Usage
Expand All @@ -66,13 +66,13 @@ object Decoder extends TwiddleSyntax[Decoder] {
}

val int: Decoder[Int] = _ => ???
// int: Decoder[Int] = repl.MdocSession$MdocApp0$$Lambda$14766/0x0000000802b78ee8@47e1cada
// int: Decoder[Int] = repl.MdocSession$MdocApp0$$Lambda$10230/0x000000080244cc90@53758c09
val string: Decoder[String] = _ => ???
// string: Decoder[String] = repl.MdocSession$MdocApp0$$Lambda$14767/0x0000000802b79330@38938c5d
// string: Decoder[String] = repl.MdocSession$MdocApp0$$Lambda$10231/0x000000080244d0d8@320979fc

case class Foo(x: Int, y: String)
val fooDecoder = (int *: string).to[Foo]
// fooDecoder: Decoder[Foo] = repl.MdocSession$$anon$8$$Lambda$14770/0x0000000802b7a000@613596db
// fooDecoder: Decoder[Foo] = repl.MdocSession$$anon$8$$Lambda$10234/0x000000080244df98@3f006c1a
```

In this example, the `Decoder` type has an `Applicative` instance defined in its companion object (and `Applicative` extends `InvariantSemigroupal`), and the companion object extends `TwiddleSyntax`. The latter enables use of `*:` and `to` with `Decoder` values without adding explicit imports (that is, there's no need to import `org.typelevel.twiddles.syntax._` at call sites).
Expand Down
6 changes: 6 additions & 0 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ This library provides the ability to work with twiddle lists for arbitrary types

## Getting Started

Artifacts are published for Scala 2.12, 2.13, and 3 and all platforms (JVM, Scala.js, and Scala Native).

```scala
libraryDependencies += "org.typelevel" %%% "twiddles-core" % "0.6.0" // check Releases for the latest version
```

```scala mdoc
// Enable twiddle syntax for arbitrary types
import org.typelevel.twiddles.syntax._
Expand Down

0 comments on commit 7d3b97c

Please sign in to comment.