Skip to content

Miror clarifications to multi-arg example #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ type BlogPost =
}
```

Our API tells us the author of the blog post as a string and whether we follow them as a boolean. This admits more cases than are actually possible -- you can't follow yourself, for example -- so we are more precise and model an `Author` as a sum type.
Our API sends us the author of the blog post as a string and whether we follow them as a boolean. This admits more cases than are actually possible -- you can't follow yourself, for example -- so we are more precise and model an `Author` as a sum type.

When our application is running we know who the currently-authenticated user is, and we can use that information to determine the `Author` type. That means we can't decode an `Author` from `Json` alone -- we need more information.

Expand All @@ -456,7 +456,7 @@ decodeJsonAuthor maybeUsername json = do
-- user is logged in and is the author
Just (Username username) | author == username -> You
-- user is not the author, or no one is logged in, so use the `following` flag
otherwise -> author # if following then Following else NotFollowing
_ -> author # if following then Following else NotFollowing

decodeJsonBlogPost :: Maybe Username -> Json -> Either JsonDecodeError BlogPost
decodeJsonBlogPost username json = do
Expand Down