The problem is that your function d_v_ds
isn't taking in account lists with many elements but only the empty list []
and the list with one element [(v, xAexp)]
. I think you misunderstood Haskell syntax because you are using tail [(v,xAexp)]
to take the tail of a list of one element.
I don't know what envV'
and sto'
are, but if I understood correctly what you want to do, that is working on each element of the list, your function can be rewritten:
d_v_ds :: DecV -> (EnvV, Store) -> (EnvV, Store)
d_v_ds [] (envV, sto) = (envV, sto)
d_v_ds ((v, xAexp):xs) (envV, sto) = d_v_ds xs (envV', sto')
The match ((v,xAexp):xs)
contains all you need: (v,xAexp)
is the head of the list, xs
is the tail of the list and (v,xAexp):xs
says that you are waiting for a list composed by at least one element (xs
can be empty).