You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -440,7 +440,7 @@ type BlogPost =
440
440
}
441
441
```
442
442
443
-
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.
443
+
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.
444
444
445
445
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.
446
446
@@ -456,7 +456,7 @@ decodeJsonAuthor maybeUsername json = do
456
456
-- user is logged in and is the author
457
457
Just (Username username) | author == username -> You
458
458
-- user is not the author, or no one is logged in, so use the `following` flag
459
-
otherwise -> author # if following then Following else NotFollowing
459
+
_ -> author # if following then Following else NotFollowing
460
460
461
461
decodeJsonBlogPost :: Maybe Username -> Json -> Either JsonDecodeError BlogPost
0 commit comments