Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Haskell
Wiki community
Recent changes
Random page
HaskellWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
POV-Ray SDL project
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== The problems == Well... almost. There are one or two little glitches. First of all, every object conceptually has a 'shape' property. This could be a plane, sphere, cylinder, etc. Do we make 'shape' a type or a class? If we make it a class, then we instantly have problems. A sphere and a cylinder both have a 'radius'. Unless you're going to start writing ugly and tedious constructions like 'cylRadius' and 'sphRadius', you're going to hit a name-clash problem. On top of that, there are situations where you might very well want to process a ''list'' of shapes. If 'shape' is a class, all the elements of the list must be the exact same shape type. Alternatively, we can make 'shape' a type. Then we avoid the name clash problem, and 'radius' will work as expected. Also, we can now construct a list of shapes containing all different kinds of shape. The problem now is the reverse: we might want to demand that a list contains ''only'' spheres, for example. There is now no way to force this though the type system. On balance, shape = type seems to work best. There's still a slight problem though. Some shapes have a 'radius'. However, spotlights also have a 'radius'. Some shapes have a 'normal'. But so too does the 'gradient' texture type. There isn't an obvious way to fix this. (Aside from making a class 'HasRadius' with a single method 'radius'. And likewise for every other clashing name...) Also, in SDL you add things to the scene by just writing them out. To make the SDL into valid Haskell you would have to assign them to some kind of top-level identifier or some such. A minor issue... Next, Haskell's named-field syntax very closely matches POV-Ray's SDL (though not exactly), but there are still problems. Declaring a field named <hask>abc</hask> neatly defines a new query function <hask>abc :: TypeX -> TypeY</hask>. However, it does not define any update function. The only way to update is by the curiose syntactical construct <hask>my_x {abc = foo}</hask>. Last time I checked, that's not a function, and you can't pass it around the way the <hask>abc</hask> function can be passed. I did experiment with a construction such as <haskell> type Property a b = (a -> b, b -> a -> b) get = fst set = snd radius = (get_radius, set_radius) :: Property </haskell> With this done, <hask>get radius</hask> fetches the radius and <hask>set radius</hask> sets it. It proved to be a little unwieldy though.
Summary:
Please note that all contributions to HaskellWiki are considered to be released under simple permissive license (see
HaskellWiki:Copyrights
for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!
Cancel
Editing help
(opens in new window)
Toggle limited content width