I think this utility is pretty useful since it means you can run GHCi scripts quickly.
The core functionality should be:
- Wrap all code blocks (blocks separated by empty lines) in
:{...:}
- Separate declaration from usage
- Top level I/O actions, groups of imports, and template Haskell should be in their own blocks.
- Group ghci directives together.
- It should contain some default extensions (overloaded strings, type applications, maybe template Haskell etc).
1) Separate declaration from usage
Should be:
:{
x = 5
:}
:{
print x
:}
2) Separate I/O action
Should be:
:{
x <- pure 5
:}
:{
print x
:}
3) Group signature and bindings
f :: Int -> Int
f x = x + 1
print (f 5)
Should be:
:{
f :: Int -> Int
f x = x + 1
:}
:{
print (f 5)
:}
3) Separate imports
import Data.List
ys = sort [5,4,3,2,1]
print (f 5)
Should be:
:{
import Data.List
:}
:{
ys = sort [5,4,3,2,1]
:}
:{
print ys
:}
4) Template Haskell splices should converted to GHCi template haskell format.
$(F.declareColumns df)
print (df |> D.filterWhere (x .> 5))
Should be:
-- include template haskell extension since we know it's in the script.
:{
:set -XTemplateHaskell
:}
:{
_ = (); F.declareColumns df
:}
:{
print (df |> D.filterWhere (x .> 5))
:}
5) Group GHCI directives (or have them in their own blocks if t.
:set -XScopedTYpeVariables
:set -XOverloadedLabels
print 4
Should be:
:{
:set -XScopedTYpeVariables
:}
:{
:set -XOverloadedLabels
:}
:{
print 4
:}
I think this utility is pretty useful since it means you can run GHCi scripts quickly.
The core functionality should be:
:{...:}1) Separate declaration from usage
Should be:
2) Separate I/O action
Should be:
3) Group signature and bindings
Should be:
3) Separate imports
Should be:
4) Template Haskell splices should converted to GHCi template haskell format.
Should be:
5) Group GHCI directives (or have them in their own blocks if t.
Should be: