You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Choose
import Data.Fin
import Data.Vect
import Effects
import Effect.Random
randomElement : (l : List a) -> {ok : NonEmpty l} -> Eff a [RND]
randomElement [] {ok} = absurd ok
randomElement (h::t) {ok} = do
let vl = fromList (h::t)
fin <- rndFin $ length t
pure $ index fin vl
data ChooseEffect : Effect where
Choose : (l : List a) -> {ok : NonEmpty l} -> sig ChooseEffect a ()
CHOOSE : EFFECT
CHOOSE = MkEff () ChooseEffect
choose : (l : List a) -> {ok : NonEmpty l} -> Eff a [CHOOSE]
choose l {ok} = call $ Choose l {ok}
[chooseRandom] Handler ChooseEffect IO where
handle () (Choose l {ok}) k = do
a <- run $ randomElement l {ok}
k a ()
produces this error:
|
25 | handle () (Choose l {ok}) k = do
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...
Effects.Choose.chooseRandom, method handle is not total as there are missing cases due to Prelude.Interfaces.case block in divBigInt at ./Prelude/Interfaces.idr:341:22-27
I'm a beginner to Idris, but this error seems spurious to me.
The text was updated successfully, but these errors were encountered:
The following code:
produces this error:
I'm a beginner to Idris, but this error seems spurious to me.
The text was updated successfully, but these errors were encountered: