You can't really do this in the way you describe. Because Player
takes an argument (pName
), the type of Player
itself is String -> Object
, so it won't fit in your Table
type properly.
As suggested in your edit, you should probably make a separate enumeration type without arguments specifically for Table
:
data ObjectType = PlayerType | MonsterType | ...
Depending on how the other constructors of Object
will be defined, you might be able to avoid duplication, e.g.
data Object = Object { objectType :: ObjectType, name :: String }
but that does assume that every kind of Object
will have exactly one name
argument and nothing else.
EDIT:
On reflection, I wonder if having a lookup table structure makes sense in the first place. You could replace the table with this:
lookupPath :: Object -> String
lookupPath (Player {}) = "data/players"
lookupPath (Monster {}) = "data/mons"
...
This format will make it harder to do things like persisting the table to disk, but does exactly capture your intention of wanting to match on the object without its parameters.
(The Player {}
format for the match is the best way to match on constructors that may acquire more arguments in future, as it saves you from having to update the matching code when this happens.)