{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
module Dovetail.Core.Effect.Random where
import Control.Monad.IO.Class (MonadIO(..))
import Dovetail
import Dovetail.Evaluate (builtIn)
import System.Random (randomRIO)
env :: forall ctx. Env ctx
env :: Env ctx
env = do
let _ModuleName :: ModuleName
_ModuleName = Text -> ModuleName
ModuleName Text
"Effect.Random"
ModuleName -> Text -> (Value ctx -> Eval ctx Double) -> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @(Value ctx -> Eval ctx Double)
ModuleName
_ModuleName Text
"random"
\Value ctx
_ ->
IO Double -> Eval ctx Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO ((Double, Double) -> IO Double
forall a. Random a => (a, a) -> IO a
randomRIO (Double
0.0, Double
1.0))