[Haskell-cafe] language proposal: ad-hoc overloading
Marc Weber
marco-oweber at gmx.de
Sun Aug 31 22:22:51 EDT 2008
On Sun, Aug 31, 2008 at 11:21:44AM -0700, Ryan Ingram wrote:
> [..]
> Any thoughts?
> -- ryan
Nice problem, nice idea..
Maybe the time is better spend on IDEs than extending the (or all)
compilers..
Right now I've something like this in my vim script files:
function! vl#dev#haskell#qffixfixable#AddMissingExtensions()
let addExt=''
let alreadyAsked = {}
for qfitem in reverse(getqflist())
let match = matchstr(qfitem['text']
\ , '(use -X\zs[^)]*\ze)\|(-X\zs[^ ]*\ze permits this)\|(Use \zs[^ ]*\ze to lift this restriction)'
\ .'\|(Use -X\zs[^ ]*\ze to allow operators in types)'
\ .'\|(Use -X\zs[^ ]*\ze to suppress this message)'
\ .'\|Use -X\zs[^ ]*\ze if you want to disable this'
\ .'\|Use -X\zs[^ ]*\ze to permit this'
\ .'\|(Use -X\zs[^ ]*\ze to allow multi-parameter classes)'
\ .'\|([Uu]se -X\zs[^ ]*\ze)'
\ .'\|or use \zs[^ ]*\ze'
\ .'\|(Use \zs[^ ]*\ze to permit this)'
\ .'\|Use -X\zs[^ ]*\ze to permit it'
\ .'\|Use -X\zs[^ ]*\ze if you want to allow more.)'
\ )
let replace = {
\ '-fno-monomorphism-restriction' : 'NoMonomorphismRestriction'
\ , '-fallow-undecidable-instances' : 'UndecidableInstances'
\ }
let match = get(replace, match, match)
if match != ''
let addExt = match
endif
getting many information out of error message asking me wether I want to
add the used extension to the {#- LANGUAGE .. #-} pragma.
So what about enhancing ghc so that it prints a message such as
============= hs file ===============================================
import qualified Data.Set as S
import qualified Data.Map as M
[..]
============= error message ==========================================
file.hs: line col: not in scope foo. Maybe you meant
M.empty
or S.empty
or without qualified
file.hs: line col: ambiguous occurence of empty, Maybe you meant
M.empty
or S.empty
then it woulde be easy to ask the editor to do the right thing, give you
a choice ?
I'd say this is not as perfect as your proposal, but it can be
implemented much more easily.
Sincerly
Marc Weber
More information about the Haskell-Cafe
mailing list