summaryrefslogtreecommitdiff
path: root/doc/todo
diff options
context:
space:
mode:
authorJoey Hess2019-07-02 00:43:40 -0400
committerJoey Hess2019-07-02 00:43:40 -0400
commit665ea0d3d9e1b0e90278fd659dee0ef8642030da (patch)
tree9969435c0c78c046c4dcc45ec9726229025701ed /doc/todo
parente20662e6a8881db55394a6366be17ca4e509bc2a (diff)
Revert "custom type error messages"
This reverts commits 14f6ae30809d8bbdb10b91cc59757e865a365df8 de21ef26861db458b0dfb0212cf501f9f8ed459b e20662e6a8881db55394a6366be17ca4e509bc2a Until this bug is resolved, these custom error types hide more basic errors. https://gitlab.haskell.org/ghc/ghc/issues/16894
Diffstat (limited to 'doc/todo')
-rw-r--r--doc/todo/use_ghc_8.0_custom_compile_errors.mdwn36
1 files changed, 19 insertions, 17 deletions
diff --git a/doc/todo/use_ghc_8.0_custom_compile_errors.mdwn b/doc/todo/use_ghc_8.0_custom_compile_errors.mdwn
index 8c2ed77a..95f86143 100644
--- a/doc/todo/use_ghc_8.0_custom_compile_errors.mdwn
+++ b/doc/todo/use_ghc_8.0_custom_compile_errors.mdwn
@@ -6,25 +6,27 @@ For example, a RevertableProperty is sometimes used where only a regular
Property is accepted. In this case, the error could suggest that the user
apply `setupRevertableProperty` to extract the setup side of the RevertableProperty.
-> I tried this, it didn't seem worth the complication however. --[[Joey]]
-
And, when a Property HasInfo is provided to ensureProperty, propellor could
explain, in the compile error, why it can't let the user do that.
-> Done this and also used custom errors when properties' types don't let
-> them be combined. --[[Joey]]
-
-The new type-errors library builds a lot of stuff on top of this.
-Its ability to detect "stuckness" seems like it may be able to catch
-the very long type errors that we sometimes see when using propellor, and
-whittle them down to a more useful error. --[[Joey]]
-
-> > Actually I think the stuckness would not help with that, though it
-> > could help with other mistakes. In particular, forgetting to provide
-> > a parameter to a property constructor can lead to a massive
-> > error message that leaks type family stuff from MetaTypes, due to
-> > the type checker getting stuck. Detecting that and replacing it with
-> > a simpler error would be a big improvement. Such large error messages
-> > can make ghc use an excessive amount of memory. --[[Joey]]
+Custom errors need a type class to be used. So, could do something like this:
+
+ class NeedsProperty a where
+ withProperty :: (Property metatype -> b) -> b
+
+ instance NeedsProperty (Property metatype) where withProperty = id
+
+ instance TypeError (Text "Use setupRevertableProperty ...")
+ => NeedsProperty RevertableProperty where
+ withProperty = error "unreachable"
+
+(While propellor needs to be buildable with older versions of ghc,
+the `instance TypeError` can just be wrapped in an ifdef to make it only be
+used by the new ghc.)
+
+> The new type-errors library builds a lot of stuff on top of this.
+> Its ability to detect "stuckness" seems like it may be able to catch
+> the very long type errors that we sometimes see when using propellor, and
+> whittle them down to a more useful error. --[[Joey]]
[[!tag user/joey]]