{`Option`}
48 | {JSON.stringify(avatarOpt, null, 2)}
49 | Request Status
50 | {JSON.stringify(reqStatus, null, 2)}
51 | >
52 | )
53 | }
54 |
--------------------------------------------------------------------------------
/src/1st-episode-ADTs/index.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * The two most common ADT types are "product" and "sum".
3 | * Whether or not the data type is a product or sum can be derived
4 | * by counting the "inhabitants" or (values) of a given type.
5 | */
6 |
7 | // ******* Option ********
8 | type Option = { _tag: 'None' } | { _tag: 'Some'; value: A }
9 |
10 | // ******* Either ********
11 | //#region Either
12 | interface Left
50 | {JSON.stringify(userProfiles, null, 2)}
51 |
52 |
60 | {JSON.stringify(sortedProfilesByDateCreated(userProfiles), null, 2)}
61 |
62 |
177 | {JSON.stringify(validationErrors, null, 2)}
178 |
179 | tag 177 | */ 178 | const PersonName = ({ person, onClick }: PersonNameProps) => ( 179 |
{person.name}
180 | ) 181 | 182 | /** 183 | * Our view of a single person that has been selected from the list 184 | */ 185 | const PersonView = ({ person, goBack }: PersonViewProps) => { 186 | // Create a place to track a person's films 187 | const [matchFilms, getFilms] = useTaskEitherLoading...
242 | 243 | /** 244 | * Constructs a TaskEither that is capable of making a GET request that 245 | * will use the provided Decoder to validate the current type. Optionally 246 | * and AbortSignal can be passed along to support cancelation of the fetch request. 247 | */ 248 | function makeRequest( 249 | url: string, 250 | decoder: D.Decoder