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
[*Rules of Hooks*](https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level).
99
-
That is why `Hook` is an indexed monad; because
99
+
That is why `Hook` is an indexed monad; because
100
100
Madeline Trotter noticed that
101
101
the algebraic structure of the indexed monad matches neatly with
102
102
the *Rules of Hooks*, so she created the `Hook` indexed monad.
@@ -215,8 +215,8 @@ type ArtworksResponse = ArtworksData & ErrorHandling;
215
215
We can use PureScript [Row Polymorphism](https://github.com/purescript/documentation/blob/master/language/Types.md#row-polymorphism) to create equivalent PureScript types
216
216
with the same runtime representation.
217
217
218
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
219
-
```typescript
218
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
219
+
```haskell
220
220
typeErrorHandlingRowr=
221
221
( success::Boolean
222
222
, error::Nullable { message::String }
@@ -237,7 +237,7 @@ Suppose we have this TypeScript React component, and we want to wrap it
237
237
so that we can call it from PureScript.
238
238
239
239
__src/Tags.tsx__
240
-
```typescript
240
+
```haskell
241
241
export interface Props_tags {
242
242
tags: [string]
243
243
}
@@ -250,8 +250,8 @@ To wrap the foreign `Tags` component in PureScript,
250
250
create files `Tags_.purs` and `Tags_.js`.
251
251
252
252
__src/Tags_.purs__
253
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
254
-
```typescript
253
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
254
+
```haskell
255
255
moduleTags (tsxTags) where
256
256
257
257
importReact.Basic (ReactComponent)
@@ -276,8 +276,8 @@ files are foreign.)
276
276
277
277
Then we can use the foreign component:
278
278
279
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
280
-
```typescript
279
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
280
+
```haskell
281
281
importReact.Basic.DOM (div_)
282
282
importReact.Basic.Hooks (element)
283
283
importTags (tsxTags)
@@ -288,7 +288,7 @@ div_ [ element tsxTags {tags:["one"]} ]
288
288
### React diffing algorithm and `foreign import`
289
289
290
290
Here is more helpful advice from [Robert Porter](https://github.com/robertdp),
291
-
about typeclass
291
+
about typeclass
292
292
constraints on foreign imports of React components. Recent versions of PureScript
293
293
have [deprecated typeclass constraints on foreign import](https://github.com/purescript/purescript/pull/3829),
294
294
so you probably don't have to worry about this, but here it is just in case.
@@ -370,8 +370,8 @@ so that we can `push` to a __react-router-dom__ `History` object.
370
370
371
371
A bit tricky, so here is [the trick](https://lobste.rs/s/wa99yt/coming_purescript_from_haskell_reflex#c_faof1j):
372
372
373
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
374
-
```typescript
373
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
Suppose we want to remove an icon after a 20-second vanishing animation.
398
398
399
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
400
-
```typescript
399
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
400
+
```haskell
401
401
React.do
402
402
403
403
icon /\ setIcon <- useState true
@@ -439,8 +439,8 @@ The classic essay on the general problem of how to read unstructured untyped dat
439
439
440
440
The [`decodeJson`](https://pursuit.purescript.org/packages/purescript-argonaut/docs/Data.Argonaut#t:DecodeJson) function from __argonaut__ can infer the structure of the JSON you're expecting from the type of the data that you want to cast it to. If the structure of the JSON doesn't match the type, then it returns an error in `Left`.
441
441
442
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
443
-
```typescript
442
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
443
+
```haskell
444
444
show$do
445
445
x ::Array {a::Int,b::String} <- decodeJson =<< parseJson """[{"a":2,"b":"stuff"}]"""
446
446
pure x
@@ -466,12 +466,12 @@ The automatic decoding in `Simple.JSON` is based on the[`ReadForeign`](https://p
466
466
467
467
#### 3. F Monad
468
468
469
-
Themostpowerfulandgeneralwaytoreadforeigndataisbywritingmonadicparsersforthe [`F`monad](https://pursuit.purescript.org/packages/purescript-foreign/docs/Foreign#t:F). You run the parser with [`runExcept`](https://pursuit.purescript.org/packages/purescript-transformers/docs/Control.Monad.Except#v:runExcept).
469
+
The most powerful and general way to read foreign data is by writing monadic parsers for the [`F` monad](https://pursuit.purescript.org/packages/purescript-foreign/docs/Foreign#t:F). You run the parser with [`runExcept`](https://pursuit.purescript.org/packages/purescript-transformers/docs/Control.Monad.Except#v:runExcept).
470
470
471
471
If `blob :: Foreign` is a JSON object which we expect to be an array of records, each with a string field named `"thing"`, then we can parse it into PureScript with the `F` monad like this:
472
472
473
-
[//]: # as of 2022.07.30 Jekyll highligher rouge does not support purescript. So typescript is used instead below. Adding purescript.rb in plugins will not work
474
-
```typescript
473
+
<!--as of 2022.07.30 Jekyll highligher rouge does not support purescript. So haskell is used instead below. Adding purescript.rb in plugins will not work-->
| Loader for WebPack ||[__purs-loader__](https://github.com/ethul/purs-loader)[__craco-purscript-loader__](https://github.com/andys8/craco-purescript-loader)|
573
573
| State Management |[__@types/react-redux__](https://www.npmjs.com/package/@types/react-redux)| React is already a state management framework, you don’t need __redux__ or anything else. Use a State Hook instead.|
0 commit comments