Visualising Haskell function execution

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Visualising Haskell function execution

Jan Paul Posma
Hey all,

Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: https://stevekrouse.github.io/hs.js/

To see it in action, scroll a bit down to the red bordered box, and click on "map", and then keep clicking on each new line.

I hope it can be useful to someone.

Cheers, JP

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

Dominick Samperi
If I recall correctly the Leksah IDE shows GHC reduction step-by-step
(using GHC debug info). Unfortunately, the last update was in 2012, so
it appears
that it has not been following the latest GHC releases.

On Fri, Aug 8, 2014 at 1:30 AM, Jan Paul Posma <[hidden email]> wrote:

> Hey all,
>
> Last weekend my friend Steve and I did a small project for visualising
> Haskell function execution in the browser. It's meant to be used in
> education, and uses a tiny custom parser. I figured it could be of interest
> for anyone here learning or teaching Haskell:
> https://stevekrouse.github.io/hs.js/
>
> To see it in action, scroll a bit down to the red bordered box, and click on
> "map", and then keep clicking on each new line.
>
> I hope it can be useful to someone.
>
> Cheers, JP
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

Kim-Ee Yeoh
Administrator
In reply to this post by Jan Paul Posma

On Fri, Aug 8, 2014 at 12:30 PM, Jan Paul Posma <[hidden email]> wrote:
Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: https://stevekrouse.github.io/hs.js/

Mind if I suggest posting to the haskell reddit /r/haskell ?

Tons of people would find it useful there and share it forward.

-- Kim-Ee

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

Jan Paul Posma
Of course, thanks!

Also, the code is open source and can easily be used in other courses, that page is just our example.

JP


On Fri, Aug 8, 2014 at 2:35 PM, Kim-Ee Yeoh <[hidden email]> wrote:

On Fri, Aug 8, 2014 at 12:30 PM, Jan Paul Posma <[hidden email]> wrote:
Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: https://stevekrouse.github.io/hs.js/

Mind if I suggest posting to the haskell reddit /r/haskell ?

Tons of people would find it useful there and share it forward.

-- Kim-Ee


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

Jerzy Karczmarczuk
Jan Paul Posma <[hidden email]> wrote:

Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: https://stevekrouse.github.io/hs.js/

Indeed, this is a nice, and potentially useful initiative, thanks.

I have some observations, though.

1. Before its "wide distribution" as suggested by Kim-Ee, it would be nice to provide a minimum documentation on the project page.

2. It is not always clear what is the relation between the work of the system, the expression expansion, and what Haskell REALLY does.
For, say: (foldr plus 0 [1 2 3 4 5]) the development/reduction depends on what you click. You may get

(plus 1 (plus 2 (foldr plus 0 [3 4 5])))   or
(1 + (foldr plus 0 [2 3 4 5]))

and a beginner might have serious problems to understand what really happens in a true Haskell program.

3. The system accepts typing abominations, say,
(foldl plus [] [1 2 3 4 5]) and joyfully develops the structure, which cannot be finally reduced.

4. 
I don't understand the relation between the typing and the behaviour. I tested foldl with my own function put into the function editor: const x y = x without type declaration.
The expression is expanded, but never reduced, const remains in the final expression. When const type is declared, it is reduced.

5.  I tried to define my own recursive function (a factorial) and test it replacing one of the standard examples. This breaks the system. If it is not allowed, please say so explicitly. If I did something silly, please see my point (1).

My best regards, and thank you once more.

Jerzy Karczmarczuk
Caen, France



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

gdweber
On 2014-Aug-09, Jerzy Karczmarczuk wrote:

> Jan Paul Posma <[hidden email] <mailto:[hidden email]>> wrote:
>
> >    Last weekend my friend Steve and I did a small project for
> >    visualising Haskell function execution in the browser. It's meant
> >    to be used in education, and uses a tiny custom parser. I figured
> >    it could be of interest for anyone here learning or teaching
> >    Haskell: https://stevekrouse.github.io/hs.js/
> >
>
> Indeed, this is a nice, and potentially useful initiative, thanks.
>
> I have some observations, though.
>
> 1. Before its "wide distribution" as suggested by Kim-Ee, it would
> be nice to provide a minimum documentation on the project page.
>
> 2. It is not always clear what is the relation between the work of
> the system, the expression expansion, and what Haskell REALLY does.
> For, say: (foldr plus 0 [1 2 3 4 5]) the development/reduction
> depends on what you click. You may get
>
> (plus1(plus2(foldrplus0[3 45]))) or
> (1+(foldrplus0[2 345]))
>
> and a beginner might have serious problems to understand what really
> happens in a true Haskell program.
>
> 3. The system accepts typing abominations, say, (foldlplus[][1 234
> 5]) and joyfully develops the structure, which cannot be finally
> reduced.
>
> 4. I don't understand the relation between the typing and the
> behaviour. I tested foldl with my own function put into the function
> editor: const x y = x without type declaration.
> The expression is expanded, but never reduced, const remains in the
> final expression. When const type is declared, it is reduced.
>
> 5.  I tried to define my own recursive function (a factorial) and
> test it replacing one of the standard examples. This breaks the
> system. If it is not allowed, please say so explicitly. If I did
> something silly, please see my point (1).

From the pink error messages I'm seeing today (though I don't remember
seeing them yesterday when I tried something similar), it looks like
the * operator is not supported; the only numerical operators are + and -

>
> My best regards, and thank you once more.
>
> Jerzy Karczmarczuk
> Caen, France
>
>

> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe


--
Gregory D. Weber, Ph. D.                  http://mypage.iu.edu/~gdweber/
Associate Professor of Informatics        Tel (765) 973-8420
Indiana University East                   FAX (765) 973-8550

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

Bob Ippolito
In reply to this post by Jan Paul Posma
On Thu, Aug 7, 2014 at 10:30 PM, Jan Paul Posma <[hidden email]> wrote:
Hey all,

Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: https://stevekrouse.github.io/hs.js/

To see it in action, scroll a bit down to the red bordered box, and click on "map", and then keep clicking on each new line.

I hope it can be useful to someone.

Thanks for posting this! It looks potentially quite useful, especially in an educational context. I think the part that's missing for me is that it doesn't make it so explicit that pattern matching is what typically forces evaluation, here you simply decide where to evaluate by clicking on that part of the term. Maybe there could be an implicit "print" forcing evaluation or something like that could be useful?

-bob
 

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Visualising Haskell function execution

Henk-Jan van Tuyl
In reply to this post by Dominick Samperi
On Fri, 08 Aug 2014 17:52:38 +0200, Dominick Samperi <[hidden email]>  
wrote:

> If I recall correctly the Leksah IDE shows GHC reduction step-by-step
> (using GHC debug info). Unfortunately, the last update was in 2012, so
> it appears
> that it has not been following the latest GHC releases.

Leksah still works, but it is not finished; it is only possible to step  
per (sub)expression, no stepping to the end of a function. The debugger  
has therefore a very limited use. I hope that a group of people will  
continue the development, an application like that is too big for one  
person.

Regards,
Henk-Jan van Tuyl


--
Folding@home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe