Skip to content

Commit a31b965

Browse files
Update guide for forall proxy recommendation (#439)
1 parent b52bb5c commit a31b965

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

migration-guides/0.15-Migration-Guide.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,10 @@ case foo of
427427
### Changes affecting multiple libraries
428428

429429
- Migrated all FFI to ES modules and dropped support for CommonJS modules.
430+
- Removed deprecated `MonadZero` type class and all of its deprecated instances.
430431
- Removed all kind-specific Proxy types (e.g. `SProxy`, `Proxy2`, `Proxy3`, `RLProxy`, etc.)
431432
- Replace usage of such types with `Type.Proxy (Proxy(..))`.
432-
- Removed deprecated `MonadZero` type class and all of its deprecated instances.
433+
- See the recommendation about updating the `forall proxy.` workaround at the bottom of this file.
433434

434435
### Removal of deprecated things and their replacements
435436

@@ -848,6 +849,39 @@ These three functions were defined in `purescript-web-dom` and duplicated in the
848849

849850
## Other Recommendations
850851

852+
### Removing the `forall proxy.` workaround
853+
854+
In `0.13.x`, we did not have a kind-polymorphic `Proxy` type (e.g. `data Proxy :: forall k. k -> Type`). So, each kind needed its own `Proxy` type, producing a zoo of such types:
855+
- `SProxy` - `Proxy` for kind `Symbol`
856+
- `RProxy` - `Proxy` for kind `Row`
857+
- `RLProxy` - `Proxy` for kind `RowList`
858+
- ... etc.
859+
860+
```purs
861+
-- 0.13.x
862+
foo :: forall sym. IsSymbol sym => SProxy sym -> ...
863+
864+
bar :: forall row. RowCons "foo" Int () row => RProxy row -> ...
865+
```
866+
867+
In `0.14.0`, when polykinds were implemented, we got a kind-generic `Proxy` type. Thus, the zoo of `Proxy` types were no longer needed. However, to reduce breakage, we used a `forall proxy.` workaround so that both the kind-specific and kind-generic version worked.
868+
869+
```purs
870+
-- 0.14.x
871+
-- `forall proxy.` workaround:
872+
foo :: forall proxy sym. IsSymbol sym => proxy sym -> ...
873+
874+
foo (SProxy :: SProxy "a") -- kind-specific Proxy type works!
875+
foo (Proxy :: Proxy "a") -- kind-generic Proxy type also works!
876+
```
877+
878+
In `0.15.x`, the zoo of `Proxy` types were removed. **Thus, the `forall proxy.` workaround SHOULD be removed in all libraries as doing so improves type inference.**
879+
```diff
880+
-foo :: forall proxy sym. IsSymbol sym => proxy sym -> ...
881+
+import Type.Proxy (Proxy(..))
882+
+foo :: forall sym. IsSymbol sym => Proxy sym -> ...
883+
```
884+
851885
### Discouraging usage of `F` and `FT`
852886

853887
**To fix:**

0 commit comments

Comments
 (0)