[Haskell-cafe] using Haskell more like scripting language

Dennis Raddle dennis.raddle at gmail.com
Sat Jul 28 22:04:54 UTC 2018


I'm actually working in Purescript, but the issue is pretty much the same
as one would encounter in Haskell.

My application (animation of math-related ideas) is changing constantly.
It's research, and I don't know where I'll be with it next week, or even
tomorrow.

For instance, the kinds of "objects" I'm animating (numbers, equations) and
the way they move and interact with each other is a research project, and
I'm constantly ripping out parts of my application and scavenging them for
variations on a theme.

My objects need state. At this point I'm thinking of just putting the state
into a map with strings as keys and some kind of sum type to represent each
data item I might need.

So if I want to represent that an object has a particular color and
position and velocity,

itemState = M.fromList
  [("color"   , DataColor  blue       )
  ,("position", DataPoint  500.0 100.0)
  ,("velocity", DataVector 50.0 45.0  ) ]

Which starts to look more like a dynamically-typed scripting language. But
it's not hard to work with. I can uses lenses/prisms to inspect and update
state, and it's okay if my program crashes on encountering malformed state.

What this lets me do is create new objects that mix and match parts of old
objects, and copy and paste a lot of the code.

Is there a better way to do this? Is there a compromise I can make that
will allow the compiler to help me out more with finding errors at compile
time?

D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180728/cd82cb03/attachment.html>


More information about the Haskell-Cafe mailing list