Solution (source code)

= Solution

Use arbitrary-precision <integers> for positions, avoiding overflow on infinite sequences:
``
type Seq a = a -> [Integer]

rep :: Eq a => [a] -> Seq a
rep xs v = [i | (i,x) <- zip [0..] xs, x == v]
``
The <type synonym> `Seq a` needs no equality constraint; the <equality test> is required specifically by `rep`. The <list comprehension> visits input positions in increasing order, so the output is an increasing <list> of precisely the matching positions. For finite inputs this includes a terminating empty list when the value is absent. Infinite inputs require the additional <productivity> distinctions discussed below. This is an <occurrence-position representation of a sequence>.