-
-
Save pakoito/84f8c60d30ac10e42d15818319b3e53c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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