
#10963: Beginner-targeted language extension -------------------------------------+------------------------------------- Reporter: kanetw | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I very much like your general idea here, but I have different suggestions as to the particulars. Here is my counter-proposal: * Extend `-XExtendedDefaultRules` to allow defaulting when one of the classes involved is `Foldable` or `Traversable`. (See the current rules [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide /interactive-evaluation.html#extended-default-rules here].) This will mean, essentially, that there will be two lists of default types, one list at kind `*` and one at kind `* -> *`. Both lists should be settable by the user by the `default` directive. (GHC can figure out which list is being set quite easily.) The default `default` list for `* -> *` will be `[]`. * Add a new command to GHCi, `:binfo` (for "beginner info") (please suggest a better name) that is like `:info` but presents different information. It suppresses in-scope instances, but attempts to specialize a function's type and presents specializations, using heuristics. So when we say `:binfo find`, we'll see `Foldable t => (a -> Bool) -> t a -> Maybe a` but also `(a -> Bool) -> [a] -> Maybe a`. Would this address your use-case? One advantage to my counter-proposal is it means that you don't actually need students to specify a language extension, because `-XExtendedDefaultRules` is on by default in GHCi. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10963#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler