[GHC] #13037: educational purpose 2

#13037: educational purpose 2 -------------------------------------+------------------------------------- Reporter: vanto | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The goal is to have, in GHCi, the interim results provided by the function before the end result by a command available from the prompt, like this: for example:[[BR]] Prelude> g op n [] = n ; g op n (h:t) = h `op` g op n t[[BR]] Prelude> :stp[[BR]] Prelude> g (*) 2 [1..3][[BR]] 1* (*) 2 [2,3][[BR]] 1*2 (*) 2 [3][[BR]] 1*2*3 (*) 2 [][[BR]] 1*2*3*2[[BR]] 12[[BR]] Prelude>[[BR]] And to quit the mode we write from the prompt a command like this[[BR]] Prelude> :quitstp -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13037 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13037: Single-Stepping evaluation in GHCi -------------------------------------+------------------------------------- Reporter: vanto | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => closed * resolution: => invalid Comment: As great as it would be to have this, I believe it is unrealistic within the scope of GHC. The code that is run by GHC has little resemblance with the original source code, and `[1..3]` does not step to `[2,3]`, for example. The closest support for this is the GHCi debugger, see the user’s guide for it. But it is more suited for experienced developers. There might be dedicated tools for teaching out there that do that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13037#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13037: Single-Stepping evaluation in GHCi -------------------------------------+------------------------------------- Reporter: vanto | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): You can get somewhat close using libraries like [https://hackage.haskell.org/package/simple-reflect-0.3.2/docs/Debug- SimpleReflect.html simple-reflect] (or [https://hackage.haskell.org/package/ap-reflect ap-reflect]) {{{
import Debug.SimpleReflect g op n [] = n ; g op n (h:t) = h `op` g op n t g (*) 2 [1..3] :: Expr 1 * (2 * (3 * 2)) }}}
you can even `reduce` {{{
reduce (g (*) 2 [1..3]) 1 * (2 * 6) reduce (reduce (g (*) 2 [1..3])) 1 * 12 reduce (reduce (reduce (g (*) 2 [1..3]))) 12 }}}
{{{
traverse_ print $ reduction (g (*) 2 [1..3]) 1 * (2 * (3 * 2)) 1 * (2 * 6) 1 * 12 12 }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13037#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC