Hugging to bits
Anthony Clayden <[email protected]> Sat, 28 Jul 2018 12:35:14 +1200
| Newsgroups | gmane.comp.lang.haskell.hugs.user |
|---|---|
| Message-ID | <CAM7nRYQ+SNaPa9=iibsCxVomQEZLtaBa9j-tguu8tp4jOiCefA@mail.gmail.com> |
--===============8635829754322619236== Content-Type: multipart/alternative; boundary="00000000000084256b05720467fb" --00000000000084256b05720467fb Content-Type: text/plain; charset="UTF-8" Thank you for the encouraging words to my previous thread. I can report Hugs is indeed easy to hack. Getting to build from source was only mildly painful. (Mostly due to my total ignorance of Unix.) After being so used to Functional thinking, it is a wrench going back to programming in procedural code (C/C++) with side-effects and global variables. But I'm only tweaking the logic, not building anything from the ground up. (I've not before programmed in earnest in C, but it seems close enough to BCPL from my varsity days.) Chiefly, as I suspected, Hugs has a very firm foundation to start from. There's a deal of static type/class/instance analysis built up from the program text, which means I can easily detect the conditions under which I want to relax some of Hugs well-principled rules. (I'm implementing well-principled but more subtle rules.) So I have a modified version of the FD consistency rules, that supports expressing a type-level type equality test, but avoids the bogusness in GHC Trac #10675. With the equality test I can now express all the examples in the HList paper [2004] -- those guys abandoned Hugs. I have a better version of the instance overlap rules, determined statically from examining instance heads. IMO GHC's deferred checking is far too shonky: you think your instances are OK then many moons later you (or more likely somebody using your library) gets puzzling rejections to do with overlaps. A quick q in case anybody's listening: Hugs used to have something called 'Multi-instance' overlap resolution. There's references to it in the code and older documentation. But it's broken and was withdrawn. Anybody know what it was trying to do or where I can find docos? It seems it was trying to defer checking much like GHC, in which case I won't pursue it. I'm now working through an approach for my 'Instance Apartness Guards' proposal https://github.com/AntC2/ghc-proposals/blob/instance-apartness-guards/proposals/0000-instance-apartness-guards.rst I can express all the examples there, including the very awkward Andy A-M one (using classes/instances with FunDeps rather than type families). But it needs inserting extra instances and lots of instance constraints for type improvement. So my next hack is to change the rules for overlap resolution where there's also FunDep(s). Again this can all be done at static analysis time: Hugs determines the sequence to try instances as it processes/validates each instance. It is a joy to work in a version of Haskell that has what I want; and not a load of cruft I don't want, but which causes continual obfuscation. Thank you again to the Hugs team. AntC --00000000000084256b05720467fb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">Thank you for the encouraging words to my previous thread= . I can report Hugs is indeed easy to hack.</div><div dir=3D"auto"><br></di= v><div dir=3D"auto">Getting to build from source was only mildly painful. (= Mostly due to my total ignorance of Unix.)</div><div dir=3D"auto"><br></div= ><div dir=3D"auto">After being so used to Functional thinking, it is a wren= ch going back to programming in procedural code (C/C++) with side-effects a= nd global variables. But I'm only tweaking the logic, not building anyt= hing from the ground up. (I've not before programmed in earnest in C, b= ut it seems close enough to BCPL from my varsity days.)</div><div dir=3D"au= to"><br></div><div dir=3D"auto">Chiefly, as I suspected, Hugs has a very fi= rm foundation to start from. There's a deal of static type/class/instan= ce analysis built up from the program text, which means I can easily detect= the conditions under which I want to relax some of Hugs well-principled ru= les. (I'm implementing well-principled but more subtle rules.)</div><di= v dir=3D"auto"><br></div><div dir=3D"auto">So I have a modified version of = the FD consistency rules, that supports expressing a type-level type equali= ty test, but avoids the bogusness in GHC Trac #10675. With the equality tes= t I can now express all the examples in the HList paper [2004] -- those guy= s abandoned Hugs.</div><div dir=3D"auto"><br></div><div dir=3D"auto">I have= a better version of the instance overlap rules, determined statically from= examining instance heads. IMO GHC's deferred checking is far too shonk= y: you think your instances are OK then many moons later you (or more likel= y somebody using your library) gets puzzling rejections to do with overlaps= .</div><div dir=3D"auto"><br></div><div dir=3D"auto">A quick q in case anyb= ody's listening: Hugs used to have something called 'Multi-instance= ' overlap resolution. There's references to it in the code and olde= r documentation. But it's broken and was withdrawn. Anybody know what i= t was trying to do or where I can find docos? It seems it was trying to def= er checking much like GHC, in which case I won't pursue it.</div><div d= ir=3D"auto"><br></div><div dir=3D"auto">I'm now working through an appr= oach for my 'Instance Apartness Guards' proposal<div><a href=3D"htt= ps://github.com/AntC2/ghc-proposals/blob/instance-apartness-guards/proposal= s/0000-instance-apartness-guards.rst">https://github.com/AntC2/ghc-proposal= s/blob/instance-apartness-guards/proposals/0000-instance-apartness-guards.r= st</a></div><div><br></div><div dir=3D"auto">I can express all the examples= there, including the very awkward Andy A-M one (using classes/instances wi= th FunDeps rather than type families). But it needs inserting extra instanc= es and lots of instance constraints for type improvement.</div><div dir=3D"= auto"><br></div><div dir=3D"auto">So my next hack is to change the rules fo= r overlap resolution where there's also FunDep(s). Again this can all b= e done at static analysis time: Hugs determines the sequence to try instanc= es as it processes/validates each instance.</div><div dir=3D"auto"><br></di= v><div dir=3D"auto">It is a joy to work in a version of Haskell that has wh= at I want; and not a load of cruft I don't want, but which causes conti= nual obfuscation. Thank you again to the Hugs team.</div><div dir=3D"auto">= <br></div><div dir=3D"auto">AntC</div></div> --00000000000084256b05720467fb-- --===============8635829754322619236== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1Vc2Vy cyBtYWlsaW5nIGxpc3QKSHVncy1Vc2Vyc0BoYXNrZWxsLm9yZwpodHRwOi8vbWFpbC5oYXNrZWxs Lm9yZy9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vaHVncy11c2Vycwo= --===============8635829754322619236==--