【发布时间】:2012-12-31 02:17:58
【问题描述】:
我一直在尝试从序列中提取随机元素。我要定义的功能如下:
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
有谁知道如何解决这个问题,或者,有没有人建议一种有效的方法来从序列中获取随机元素(无需替换)?
【问题讨论】:
标签: haskell random sequence monads