Skip to content

Commit

Permalink
Include corrections by @MaureenElsberry in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Gómez committed May 24, 2016
1 parent 75062ea commit 2da7562
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions docs/src/tut/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Or, if using Scala.js (0.6.x):

## Remote data

Fetch is a library for making access to data both simple & efficient. Fetch is specially useful when querying data that
Fetch is a library for making access to data both simple & efficient. Fetch is especially useful when querying data that
has a latency cost, such as databases or web services.

## Define your data sources

For telling `Fetch` how to get the data you want, you must implement the `DataSource` typeclass. Data sources have a `fetch` method that
To tell Fetch how to get the data you want, you must implement the `DataSource` typeclass. Data sources have a `fetch` method that
defines how to fetch such a piece of data.

Data Sources take two type parameters:
Expand All @@ -45,7 +45,7 @@ trait DataSource[Identity, Result]{
}
```

We'll implement a dummy data source that can convert integers to strings. For convenience we define a `fetchString` function that lifts identities (`Int` in our dummy data source) to a `Fetch`.
We'll implement a dummy data source that can convert integers to strings. For convenience, we define a `fetchString` function that lifts identities (`Int` in our dummy data source) to a `Fetch`.

```tut:silent
import cats.Eval
Expand Down Expand Up @@ -87,7 +87,7 @@ As you can see in the previous example, the `ToStringSource` is queried once to

## Batching

Multiple fetches to the same data source are automatically batched. For ilustrating it, we are going to compose three indepent fetch results as a tuple.
Multiple fetches to the same data source are automatically batched. For illustrating it, we are going to compose three independent fetch results as a tuple.

```tut:silent
import cats.syntax.cartesian._
Expand All @@ -103,7 +103,7 @@ val result: (String, String, String) = fetchThree.runA[Eval].value

## Concurrency

If we combine two independent fetches from different data sources, the fetches will be run concurrently. Let's first add a data source that fetches a string's size.
If we combine two independent fetches from different data sources, the fetches will be run concurrently. First, let's add a data source that fetches a string's size.

```tut:silent
implicit object LengthSource extends DataSource[String, Int]{
Expand All @@ -118,7 +118,7 @@ implicit object LengthSource extends DataSource[String, Int]{
def fetchLength(s: String): Fetch[Int] = Fetch(s)
```

And now we can easily data from the two sources in a single fetch.
And now we can easily receive data from the two sources in a single fetch.

```tut:silent
val fetchMulti: Fetch[(String, Int)] = (fetchString(1) |@| fetchLength("one")).tupled
Expand All @@ -132,7 +132,7 @@ val result: (String, Int) = fetchMulti.runA[Eval].value

## Caching

When fetching an identity, subsequents fetches for the same identity are cached. Let's try creating a fetch that asks for the same identity twice.
When fetching an identity, subsequent fetches for the same identity are cached. Let's try creating a fetch that asks for the same identity twice.

```tut:silent
val fetchTwice: Fetch[(String, String)] = for {
Expand All @@ -141,7 +141,7 @@ val fetchTwice: Fetch[(String, String)] = for {
} yield (one, two)
```

When running it, notice that the data source is only queried once. The next time the identity is requested it's served from the cache.
While running it, notice that the data source is only queried once. The next time the identity is requested it's served from the cache.

```tut:book
val result: (String, String) = fetchTwice.runA[Eval].value
Expand Down
20 changes: 10 additions & 10 deletions tut/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Or, if using Scala.js:
"com.fortysevendeg" %%% "fetch" %% "0.2.0"
```

### Supported versions
Fetch is available for the following Scala and Scala.js versions:

- Scala: 2.11.x
- Scala.js: 0.6.x
- Scala 2.11.x
- Scala.js 0.6.x

## Remote data

Fetch is a library for making access to data both simple & efficient. Fetch is specially useful when querying data that
Fetch is a library for making access to data both simple & efficient. Fetch is especially useful when querying data that
has a latency cost, such as databases or web services.

## Define your data sources
Expand All @@ -49,7 +49,7 @@ trait DataSource[Identity, Result]{
}
```

We'll implement a dummy data source that can convert integers to strings. For convenience we define a `fetchString` function that lifts identities (`Int` in our dummy data source) to a `Fetch`.
We'll implement a dummy data source that can convert integers to strings. For convenience, we define a `fetchString` function that lifts identities (`Int` in our dummy data source) to a `Fetch`.

```tut:silent
import cats.Eval
Expand Down Expand Up @@ -91,7 +91,7 @@ As you can see in the previous example, the `ToStringSource` is queried once to

## Batching

Multiple fetches to the same data source are automatically batched. For ilustrating it, we are going to compose three indepent fetch results as a tuple.
Multiple fetches to the same data source are automatically batched. For illustrating it, we are going to compose three independent fetch results as a tuple.

```tut:silent
import cats.syntax.cartesian._
Expand All @@ -107,7 +107,7 @@ val result: (String, String, String) = fetchThree.runA[Eval].value

## Concurrency

If we combine two independent fetches from different data sources, the fetches will be run concurrently. Let's first add a data source that fetches a string's size.
If we combine two independent fetches from different data sources, the fetches will be run concurrently. First, let's add a data source that fetches a string's size.

```tut:silent
implicit object LengthSource extends DataSource[String, Int]{
Expand All @@ -122,7 +122,7 @@ implicit object LengthSource extends DataSource[String, Int]{
def fetchLength(s: String): Fetch[Int] = Fetch(s)
```

And now we can easily data from the two sources in a single fetch.
And now we can easily receive data from the two sources in a single fetch.

```tut:silent
val fetchMulti: Fetch[(String, Int)] = (fetchString(1) |@| fetchLength("one")).tupled
Expand All @@ -136,7 +136,7 @@ val result: (String, Int) = fetchMulti.runA[Eval].value

## Caching

When fetching an identity, subsequents fetches for the same identity are cached. Let's try creating a fetch that asks for the same identity twice.
When fetching an identity, subsequent fetches for the same identity are cached. Let's try creating a fetch that asks for the same identity twice.

```tut:silent
val fetchTwice: Fetch[(String, String)] = for {
Expand All @@ -145,7 +145,7 @@ val fetchTwice: Fetch[(String, String)] = for {
} yield (one, two)
```

When running it, notice that the data source is only queried once. The next time the identity is requested it's served from the cache.
While running it, notice that the data source is only queried once. The next time the identity is requested it's served from the cache.

```tut:book
val result: (String, String) = fetchTwice.runA[Eval].value
Expand Down

0 comments on commit 2da7562

Please sign in to comment.