I defined the following datatype which shall provide 2 functions:
data Problem = Prob { result :: State -> Action -> State
, stepCost :: State -> Action -> Integer
}
How can I instantiate this type? I tried this:
let mcp = Prob { result _ _ = (False, (1,1)), stepCost _ _ = 1 } in True
however I get:
ERROR – Syntax error in expression (unexpected `_’)
I managed to instantiate a similar datatype with the exception that its members take only 1 argument:
data Lala = La { omg :: State
, gee :: Integer
}
let mcp = La { omg = (False, (1,1)), gee = 1 } in True
returns True.
But the point is that I want to instantiate the datatype Problem with its specific result and stepcost function. Of course, these functions depend on their arguments. So how can I pass them some arguments?
You need to instantiate it with a lambda expression; you can’t treat it as a name that takes parameters directly.