[Haskell-beginners] First Project: Imperative Algorithm Visualization tool

Elise Huard haskell at elisehuard.be
Mon Nov 10 14:54:07 UTC 2014


Hi Adit,

animations in OpenGL are mostly not exactly trivial - there's several
routes you can take, from simple to not simple at all (buffers,
shaders ...).  But maybe you know the problem space already.
Some example sources for animations in Haskell:
- OpenGL, simple animation with rotations and translations:
https://github.com/haskell-opengl/GLUT/blob/master/examples/Misc/Gears.hs
- SDL2, using sprites:
https://github.com/haskell-game/sdl2/blob/new-api/examples/lazyfoo/Lesson11.hs

As the others said, it's probably better to start with a small
problem, build up to what you want to build, and see if you can
abstract from there ...
Cheers,

Elise

On 10 November 2014 10:26, Daniel Trstenjak <daniel.trstenjak at gmail.com> wrote:
>
> Hi Adit,
>
> On Sun, Nov 09, 2014 at 11:19:48PM +0530, Adit Biswas wrote:
>> So my higher level idea on approaching this problem is:
>> 1. Create a dsl for describing data structures, e.g Link lists,
>>    trees, graphs
>> 2. Create a dsl for describing each step of the algorithms
>>    manipulating the data structures
>> 3. The algorithms would be a monadic composition of the step ADTs
>> 4. Lift the algorithm to some monad which carries out the side
>>    effects of making changes to a visualization.
>
> I would start with defining the data structures which represent
> your algorithm and then defining a function that renders your data.
>
> If you're using OpenGL ist could be as simple as:
>
>    render :: YourData -> IO ()
>
>
> If you've a working version of this, then you could try defining
> a DSL, and if you want a monadic one, then most likely you will
> be using a free monad[1,2], so you don't have to write your own one.
>
> But at the end runnning your DSL will just result into 'YourData'
> and you can reuse your 'render' function.
>
> You don't need any kind of special Monad for the rendering and
> I also don't see any kind of advantage having one.
>
>
> Greetings,
> Daniel
>
> [1] http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html
> [2] https://hackage.haskell.org/package/free
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


More information about the Beginners mailing list