Refactoring, and fix a couple of SafeHaskell-related things
Refactoring, and fix a couple of SafeHaskell-related things

When -XSafe is on:
  - ":load M" should default to adding M to the context (rather than *M).
  - "import M" should do the appropriate trust check

Also various refactoring and comments added, hopefully the code is
easier to read now.

acowley/ghc,bitemyapp/ghc,acowley/ghc,sdiehl/ghc,fmthoma/ghc,olsner/ghc,oldmanmike/ghc,GaloisInc/halvm-ghc,lukexi/ghc-7.8-arm64,vikraman/ghc,spacekitteh/smcghc,nomeata/ghc,mfine/ghc,olsner/ghc,gcampax/ghc,spacekitteh/smcghc,sgillespie/ghc,gcampax/ghc,nushio3/ghc,siddhanathan/ghc,tibbe/ghc,sdiehl/ghc,ml9951/ghc,vikraman/ghc,acowley/ghc,fmthoma/ghc,mettekou/ghc,mettekou/ghc,nushio3/ghc,AlexanderPankiv/ghc,elieux/ghc,olsner/ghc,tjakway/ghcjvm,acowley/ghc,vTurbine/ghc,nkaretnikov/ghc,frantisekfarka/ghc-dsi,ryantm/ghc,ryantm/ghc,olsner/ghc,ryantm/ghc,christiaanb/ghc,vTurbine/ghc,mfine/ghc,gridaphobe/ghc,GaloisInc/halvm-ghc,bitemyapp/ghc,wxwxwwxxx/ghc,mfine/ghc,ekmett/ghc,oldmanmike/ghc,nomeata/ghc,da-x/ghc,shlevy/ghc,snoyberg/ghc,sgillespie/ghc,tibbe/ghc,tibbe/ghc,nathyong/microghc-ghc,gridaphobe/ghc,nushio3/ghc,nkaretnikov/ghc,elieux/ghc,jstolarek/ghc,jstolarek/ghc,oldmanmike/ghc,tjakway/ghcjvm,mcschroeder/ghc,bitemyapp/ghc,vikraman/ghc,forked-upstream-packages-for-ghcjs/ghc,gridaphobe/ghc,siddhanathan/ghc,hferreiro/replay,forked-upstream-packages-for-ghcjs/ghc,nathyong/microghc-ghc,mfine/ghc,ezyang/ghc,GaloisInc/halvm-ghc,tjakway/ghcjvm,AlexanderPankiv/ghc,snoyberg/ghc,TomMD/ghc,holzensp/ghc,GaloisInc/halvm-ghc,shlevy/ghc,sgillespie/ghc,green-haskell/ghc,urbanslug/ghc,urbanslug/ghc,TomMD/ghc,ezyang/ghc,nomeata/ghc,mcschroeder/ghc,ml9951/ghc,gcampax/ghc,fmthoma/ghc,shlevy/ghc,green-haskell/ghc,olsner/ghc,ghc-android/ghc,TomMD/ghc,mettekou/ghc,frantisekfarka/ghc-dsi,sgillespie/ghc,sgillespie/ghc,olsner/ghc,nushio3/ghc,wxwxwwxxx/ghc,siddhanathan/ghc,forked-upstream-packages-for-ghcjs/ghc,mettekou/ghc,mfine/ghc,christiaanb/ghc,gcampax/ghc,gcampax/ghc,snoyberg/ghc,vikraman/ghc,jstolarek/ghc,lukexi/ghc,ghc-android/ghc,shlevy/ghc,shlevy/ghc,nkaretnikov/ghc,mfine/ghc,nushio3/ghc,snoyberg/ghc,mettekou/ghc,fmthoma/ghc,tibbe/ghc,nathyong/microghc-ghc,ghc-android/ghc,anton-dessiatov/ghc,vTurbine/ghc,jstolarek/ghc,vikraman/ghc,mcschroeder/ghc,wxwxwwxxx/ghc,mfine/ghc,sdiehl/ghc,urbanslug/ghc,spacekitteh/smcghc,mettekou/ghc,acowley/ghc,lukexi/ghc-7.8-arm64,nkaretnikov/ghc,wxwxwwxxx/ghc,snoyberg/ghc,sdiehl/ghc,ekmett/ghc,nkaretnikov/ghc,da-x/ghc,sgillespie/ghc,bitemyapp/ghc,ml9951/ghc,frantisekfarka/ghc-dsi,forked-upstream-packages-for-ghcjs/ghc,mcschroeder/ghc,TomMD/ghc,lukexi/ghc-7.8-arm64,da-x/ghc,vTurbine/ghc,christiaanb/ghc,ghc-android/ghc,sgillespie/ghc,anton-dessiatov/ghc,siddhanathan/ghc,holzensp/ghc,ghc-android/ghc,nathyong/microghc-ghc,mcschroeder/ghc,ghc-android/ghc,sdiehl/ghc,sdiehl/ghc,AlexanderPankiv/ghc,hferreiro/replay,green-haskell/ghc,holzensp/ghc,elieux/ghc,mettekou/ghc,acowley/ghc,nathyong/microghc-ghc,lukexi/ghc,ezyang/ghc,elieux/ghc,hferreiro/replay,acowley/ghc,snoyberg/ghc,oldmanmike/ghc,vikraman/ghc,urbanslug/ghc,elieux/ghc,TomMD/ghc,gcampax/ghc,anton-dessiatov/ghc,da-x/ghc,ryantm/ghc,jstolarek/ghc,forked-upstream-packages-for-ghcjs/ghc,nkaretnikov/ghc,spacekitteh/smcghc,ml9951/ghc,wxwxwwxxx/ghc,tjakway/ghcjvm,gridaphobe/ghc,siddhanathan/ghc,oldmanmike/ghc,mcschroeder/ghc,urbanslug/ghc,tibbe/ghc,TomMD/ghc,sdiehl/ghc,gcampax/ghc,vTurbine/ghc,bitemyapp/ghc,nkaretnikov/ghc,forked-upstream-packages-for-ghcjs/ghc,vTurbine/ghc,lukexi/ghc,shlevy/ghc,ml9951/ghc,holzensp/ghc,gridaphobe/ghc,forked-upstream-packages-for-ghcjs/ghc,wxwxwwxxx/ghc,siddhanathan/ghc,oldmanmike/ghc,vikraman/ghc,tjakway/ghcjvm,nomeata/ghc,hferreiro/replay,da-x/ghc,tjakway/ghcjvm,spacekitteh/smcghc,urbanslug/ghc,ekmett/ghc,snoyberg/ghc,ekmett/ghc,nushio3/ghc,green-haskell/ghc,nathyong/microghc-ghc,AlexanderPankiv/ghc,da-x/ghc,ezyang/ghc,ghc-android/ghc,lukexi/ghc-7.8-arm64,christiaanb/ghc,ml9951/ghc,vTurbine/ghc,frantisekfarka/ghc-dsi,mcschroeder/ghc,ryantm/ghc,olsner/ghc,lukexi/ghc,nomeata/ghc,GaloisInc/halvm-ghc,elieux/ghc,wxwxwwxxx/ghc,siddhanathan/ghc,nushio3/ghc,GaloisInc/halvm-ghc,christiaanb/ghc,fmthoma/ghc,ml9951/ghc,anton-dessiatov/ghc,fmthoma/ghc,holzensp/ghc,anton-dessiatov/ghc,hferreiro/replay,gridaphobe/ghc,TomMD/ghc,ezyang/ghc,frantisekfarka/ghc-dsi,da-x/ghc,green-haskell/ghc,christiaanb/ghc,lukexi/ghc,oldmanmike/ghc,hferreiro/replay,AlexanderPankiv/ghc,AlexanderPankiv/ghc,ml9951/ghc,elieux/ghc,ekmett/ghc,lukexi/ghc-7.8-arm64,hferreiro/replay,shlevy/ghc,fmthoma/ghc,ezyang/ghc,gridaphobe/ghc,anton-dessiatov/ghc,urbanslug/ghc,GaloisInc/halvm-ghc,tjakway/ghcjvm,ezyang/ghc,nathyong/microghc-ghc,christiaanb/ghc,AlexanderPankiv/ghc,anton-dessiatov/ghc