summaryrefslogtreecommitdiff
path: root/doc/todo/use_ghc_8.0_custom_compile_errors.mdwn
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-05-23 11:25:41 -0400
committerJoey Hess <joeyh@joeyh.name>2016-05-23 11:25:41 -0400
commit9435ca9d7916c59fa37e2e4c3983dcd6eb20d8c0 (patch)
treec7cea9fad8eb237f3aee7543fbcbc81b368cf7ef /doc/todo/use_ghc_8.0_custom_compile_errors.mdwn
parent7869b471f953c16fa73bc45f3651dba6138a1af6 (diff)
parent864d47361ba34d851a9bbb34a6242854c042e556 (diff)
Merge branch 'master' into joeyconfig
Diffstat (limited to 'doc/todo/use_ghc_8.0_custom_compile_errors.mdwn')
-rw-r--r--doc/todo/use_ghc_8.0_custom_compile_errors.mdwn27
1 files changed, 27 insertions, 0 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
new file mode 100644
index 00000000..7eed443a
--- /dev/null
+++ b/doc/todo/use_ghc_8.0_custom_compile_errors.mdwn
@@ -0,0 +1,27 @@
+<https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/glasgow_exts.html#custom-errors>
+
+This could be used in propellor to improve compile time errors.
+
+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.
+
+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.
+
+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.)
+
+[[!tag user/joey]]