Probably the best way to do this is a more cross-platform way, which could be turned into a nice little package to load into a .ghci file or something like that, but the quick and dirty way using haskeline pretty simple. You can just read the ghci_history file for your system, mine is located in C:/Users/bheklilr/AppData/Roaming/ghc/ghci_history , but I believe that in the * nix system it should be in ~/.ghci_history . Choose the right one for your system.
> import System.Console.Haskeline.History > hist <- fmap $ readHistory "path/to/ghci_history" > putStrLn $ unlines hist
Unfortunately, at least for me, it seems that the history file is not updated until GHCi exits, so for a specific session, hist should be the same (provided that you only have one instance of GHCi). In my opinion, this is a rather limited API, I think it would not be too difficult to reset the history of each command, or at least every pair of commands, but this has not been done.
Alternatively, you can use CTRL-R and several other commands to find your story, this is much more useful. This is especially useful because it will look for appropriate subtext.
bheklilr
source share