Skip to content

Instantly share code, notes, and snippets.

@pakoito
Last active May 10, 2017 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pakoito/84f8c60d30ac10e42d15818319b3e53c to your computer and use it in GitHub Desktop.
Save pakoito/84f8c60d30ac10e42d15818319b3e53c to your computer and use it in GitHub Desktop.
data ComponentR a = ComponentR
{ entity :: EntityId
, info :: InfoR a
}
data InfoR a = InfoR
{ get :: a
}
data World = World
{ configuration :: WConfig
, componentsOfSingleType :: ??? -> ???
, componentOfSingleTypeForId :: EntityId -> ??? -> ???
}
data WConfig = WConfig
{ components :: [ComponentR]
, systems :: [[ComponentR] -> ComponentR] -- Parameter is an heterogeneous list
, -- other stuff
}
-- Client code
newtype HealthR =
HealthR Int
newtype StaminaR =
StaminaR Int
healths =
[ ComponentR {entity = 1, info = InfoR {get = HealthR 1}}
, ComponentR {entity = 2, info = InfoR {get = HealthR 1}}
]
staminas = [ComponentR {entity = 1, info = InfoR {get = StaminaR 1}}]
myConfig = WConfig {components = healths ++ staminas} -- Error, obvious type mismatch
myWorld =
World
{ configuration = myConfig
, componentsOfSingleType = ???
, componentOfSingleTypeForId = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment