How to capture various applications using a linked library?

I am trying to use the Edward bound library to model the level graph in my game - at least the levels, since they are stored representatively before they are implemented as OpenGL objects.

A level consists of a bunch of vertices, whereby we can form a wall between pairs of vertices. Vertices are also used to create simple polygons - sectors (rooms). The sector owns walls, but also has some material properties. There is a lot of exchange between peaks, walls, sectors, and materials, so to use a graph-like nature, I turned to the bound library.

Code so far,

 -- Vertices live alone and aren't influenced by anything else. Perhaps these -- should still be a functor, but act like Const? data Vertex = Vertex { vertexPos :: V2 CFloat } -- Textures also live alone, and are simply a wrapper around the path to the -- texture. data Texture = Texture { texturePath :: FilePath } -- A Material needs to refer to one (or more) textures. data Material a = Material { materialDiffuseTexture :: a , materialNormalMap :: Maybe a } -- A Sector needs to refer to materials *and* vertices. How do I reference two -- types of variables? data Sector a = Sector { sectorFloorMaterial :: a , sectorWallMaterial :: a , sectorCeilingMaterial :: a , sectorVertices :: Vector a -- How do we guarantee these aren't material ids? , sectorFloorLevel :: Double , sectorCeilingLevel :: Double } -- A wall points to the sectors on either side of the wall, but also its start -- and end vertices. The same problem with 'Sector' appears here too. data Wall a = Wall { wallFront :: a -- This should be a sector , wallBack :: Maybe a -- This should also be a sector , wallV1 :: a -- But this is a vertex , wallV2 :: a -- This is also a vertex } -- Level ties this all together, with the various expressions making up the -- vertices, the walls between them, the sectors, and the materials. data Level = Level { levelVertices :: IntMap.IntMap Vertex , levelSectors :: Vector (Scope Int Sector ()) , levelWalls :: Vector (Scope Int Wall ()) , levelMaterials :: Vector (Scope Int Material ()) , levelTextures :: Vector (Scope Int Texture ()) } 

However, I am not sure if I am collecting the pieces correctly. For example, I have Sector a , where I use a to identify both vertices and materials. However, it is important that I use the correct identifier in the right place!

I would like to hear feedback on whether I am going in the right direction, simulating this somewhat limited AST through bound .

+7
haskell
source share

No one has answered this question yet.

See related questions:

674
What's the difference between. (dot) and $ (dollar sign)?
550
How can a time function exist in functional programming?
261
How fundamentally different are push-pull and jib FRP?
8
Why does pattern matching on this GADT seem to introduce ambiguity in type control?
6
Performing a single switch in a reactive banana
4
How to ensure the correct edges in the graph
3
Duplicate linear directional multigraph of duplicate dependencies
one
Haskell Long Path Algorithm Implementation
one
Representation and construction of a cyclic abstract syntax tree
0
Creating a directed acyclic graph in haskell with lists and sets

All Articles