(選択肢文字列,値)のリストをとって、ユーザーに選択肢を提示し、番号を入力して選んでもらった値を返す関数
choice :: [(String, a)] -> IO a
を作ってください。
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| import Control.Applicative | |
| import qualified Data.Vector as V | |
| import Prelude hiding (zipWith) | |
| class Zippable f where | |
| zipWith :: (a->b->c) -> f a -> f b -> f c |
| main = print "hi" |
| #!/usr/bin/env runhaskell | |
| {-# LANGUAGE NoImplicitPrelude, RecordWildCards #-} | |
| {-# OPTIONS -Wall #-} | |
| module Main where | |
| import Data.Maybe | |
| import Data.Tensor.TypeLevel | |
| import GTA.Data.JoinList | |
| import GTA.Core hiding (items) | |
| import NumericPrelude |
| recMapM :: forall a b m. (Data a, Data b, Monad m) => (b -> m b) -> a -> m a | |
| recMapM f x = do | |
| let recurse = gmapM (recMapM f) x | |
| case cast x of | |
| Nothing -> recurse | |
| Just bx -> do | |
| z <- f bx | |
| case cast z of | |
| Nothing -> recurse | |
| Just az -> return az |
| {-# OPTIONS -Wall #-} | |
| import Control.Monad | |
| import Control.Monad.Random | |
| import Data.List | |
| sumDice :: (MonadRandom m) => Int -> m Int | |
| sumDice n = liftM sum $ replicateM n $ getRandomR (1,6) | |
| statDice :: (MonadRandom m) => Int -> m [(Int,Int)] | |
| statDice n = do |
| main = putStrLn "Hello" |