You already noticed that the extension ScopedTypeVariablesallows you to add type annotations to templates. But for the main purpose of the extension, so that the type variable is locally bounded so that you can reference it inside the function, you must also declare it with forall in the type declaration, for example:
uselessFunction :: forall a g. (RandomGen g, Random a) => g -> [a]
, GHC, .