ku-fpg / hermit-shell

HERMIT with GHCi shell
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Highlight difference between steps #32

Open roboguy13 opened 9 years ago

roboguy13 commented 9 years ago

This might be quite a bit more trouble than it would be worth (implementation-wise), but it would be nice if you could turn on an option to highlight the difference between the results of each consecutive pair of steps in a script:

($) ▲ ▲ send
    (($) ▲ ▲ loop
         ((>>=) ▲ $fMonadR ▲ ▲ (buttonE (I# 0))
                (λ r →
                   (>>=) ▲ $fMonadR ▲ ▲
                         ((λ x → return ▲ $fMonadR ▲ (unLit x)) r)
                         (λ b →
                            (>>) ▲ $fMonadR ▲ ▲ (ledE (I# 0) (lit b))
                                 ((>>) ▲ $fMonadR ▲ ▲
                                       (ledE (I# 1) (lit (not b)))
                                       (wait (I# 100)))))))
[Done]

($) ▲ ▲ send
    (($) ▲ ▲ loop
         ((>>=) ▲ $fMonadR ▲ ▲ (buttonE (I# 0))
                (λ r →
                   (>>=) ▲ $fMonadR ▲ ▲
                         ((λ x → return ▲ $fMonadR ▲ (unLit x)) r)
                         (λ b →
                            (>>) ▲ $fMonadR ▲ ▲ (ledE (I# 0) (lit b))
                                 ((>>) ▲ $fMonadR ▲ ▲
                                       (ledE (I# 1) (notE (lit b)))
                                       (wait (I# 100)))))))
[Done]

This would also work together with #30 well, if we decide to implement that.

xich commented 9 years ago

The old shell had the command diff for this. If you gave it two AST ids (the number printed in the hermit prompt... hermit<30> means you are transforming AST id 30), it would show the diff between the pretty printed output. If you want this always, you could use set-pp-diffonly True.

It's not the greatest diff (it diffs by line), but I used it quite a bit. I have an idea for using the fold machinery to do semantic diff, but haven't gotten around to it yet.

andygill commented 9 years ago

We have a plan here. Because we (will) return the HDoc by default to the Shell, there can be a function

diff :: HDoc -> HDoc -> IO HDoc