我一直在尝试从序列中提取随机元素。我试图定义的功能如下:
getRandomInts :: Seq Int -> PureMT -> ((Seq Int, Int), PureMT)
getRandomInts ints gen = sampleState (fromJust $ choiceExtractSeq ints) gen
这是我得到的错误:
Overlapping instances for Data.Random.Lift.Lift
transformers-0.3.0.0:Data.Functor.Identity.Identity
(StateT PureMT transformers-0.3.0.0:Data.Functor.Identity.Identity)
arising from a use of `sampleState'
Matching instances:
instance [incoherent] (Monad m, MonadTrans t) =>
Data.Random.Lift.Lift m (t m)
-- Defined in `Data.Random.Lift'
instance [incoherent] Monad m =>
Data.Random.Lift.Lift
transformers-0.3.0.0:Data.Functor.Identity.Identity m
-- Defined in `Data.Random.Lift'
In the expression:
sampleState (fromJust $ choiceExtractSeq ints) gen
In an equation for `getRandomInt':
getRandomInt ints gen
= sampleState (fromJust $ choiceExtractSeq ints) gen
有谁知道如何解决这个问题,或者,有一种从序列中获取随机元素(无需替换)的有效方法的建议?