Skip to content

Commit c4ee75b

Browse files
palascarbolymer
andauthored
Remove unnecessary usage of GADTs
Co-authored-by: Mateusz Galazyn <[email protected]>
1 parent 5582a19 commit c4ee75b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

docs/ADR-10-Callstacks-for-API-errors.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ class Error e where
6565
getErrorCallStack :: e -> CallStack
6666
```
6767

68-
We need a `Content` wrapper as a `GADT`, to prevent the type of the `ErrorContent` from propagating to the type of `Error`, while ensuring that it is indeed an `ErrorContent`.
69-
68+
We need `e` in `Content` wrapper to be an existential type, to prevent the type of the `ErrorContent` from propagating to the type of `Error`, while ensuring that it is indeed an `ErrorContent`.
7069
If we do this, we could define two generic functions for every `Error e`.
7170

7271
One to print the original error, without a stack-trace:
@@ -172,7 +171,7 @@ But, other than that, it comes down to adding a space for the stack-trace in the
172171

173172
At least, we can have a reusable wrapper for errors (that must now implement the `ErrorContent` class).
174173

175-
So we can define an `ErrorWithStack` data type using a `GADT` as follows:
174+
So we can define an `ErrorWithStack` data type:
176175

177176
```haskell
178177
data ErrorWithStack e where

0 commit comments

Comments
 (0)