So you want something like this
import Control.Monad
data Op = Plus
| Sub
| Mult
deriving(Eq, Show)
denote :: Op -> (Integer -> Integer -> Integer)
denote Plus = (+)
denote Sub = (-)
denote Mult = (*)
combos :: [Integer] -> Integer -> [[Op]]
So combos [1, 2, 3] 5 == [[Mult, Plus]]
A simple way to go about using this is the list monad.
eval :: [Integer] -> [Op] -> Integer
eval (n1:n2:ns) (o:os) = eval (denote o n1 n2 : ns) os
eval [n1] [] = n1
eval _ _ = error "eval: Length mismatch"
-- Or, with folds
eval' ns os = case foldl step ns os of
[n] -> n
_ -> error "eval: Length mismatch"
where step (n1 : n2 : ns) o = denote o n1 n2 : ns
combos ns target = filter ( (==target) . eval nums) os
where os = replicateM (length ns -1) [Plus, Sub, Mult]
replicateM
will choose return a list of all possible lists of length length ns - 1
made up of Plus, Sub, Mult
. Then we just test them to see if they actually equal the correct value. This isn't terribly fast, but it's quite simple to understand.
So we generate this list of operators separately. And now using this it's easy to generate the RPN, since this looks like homework, I'll leave that part to you :)