shuffle xs g = val : shuffle rest g'
    where (idx,g') = randomR (0,length xs - 1) g
          val = xs !! idx
          bef = take idx xs
          aft = drop (idx+1) xs
          rest = bef ++ aft
shuffle xs g = val : shuffle rest g'
    where (idx,g') = randomR (0,length xs - 1) g
          val = xs !! idx
          bef = take idx xs
          aft = drop (idx+1) xs
          rest = bef ++ aft
shuffle xs g = val : shuffle rest g'
    where (idx,g') = randomR (0,length xs - 1) g
          val = xs !! idx
          bef = take idx xs
          aft = drop (idx+1) xs
          rest = bef ++ aft