HCL 1.1 → 1.2
raw patch · 3 files changed
+17/−10 lines, 3 filesdep −regex-compat
Dependencies removed: regex-compat
Files
- HCL.cabal +3/−3
- HCL.hs +13/−6
- hangman/Hangman.hs +1/−1
HCL.cabal view
@@ -1,11 +1,11 @@ Name: HCL-Version: 1.1+Version: 1.2 License: BSD3 Author: Justin Bailey Homepage: Maintainer: jgbailey _ gmail _ com Category: User Interfaces-Build-Depends: base, QuickCheck, regex-compat, mtl+Build-Depends: base, QuickCheck, mtl Synopsis: High-level library for building command line interfaces. Description: This module provides a set of functions for building simple command-line@@ -15,7 +15,7 @@ control. It is oriented towards line-based interfaces. Exposed-modules: HCL Hs-Source-Dirs: .-Data-files: hangman\2of12.txt+Data-files: hangman/2of12.txt Executable: hangman Main-Is: Hangman.hs
HCL.hs view
@@ -47,7 +47,7 @@ * 'prompt' - Displays a message and gets a response. If the message ends in a space, it is assumed that input should be typed on the same line. Otherwise, a newline is printed and input is then gathered. - * 'promptWithDefault' -- Simple way to ask for a response and provide a default. + * 'prompt1' -- Simple way to ask for a response and provide a default. * 'promptAgree' -- Simple way to ask for a yes\/no response. @@ -292,7 +292,7 @@ -- * Menus reqMenu, reqMenuItem, reqMenuEnd, reqSubMenu, reqMenuExit, -- * Prompting - prompt, promptWithDefault, promptAgree + prompt, promptWithDefault, prompt1, promptAgree ) where import Data.Char (isSpace, toLower, isPrint) @@ -752,15 +752,19 @@ Displays a message prompt and a default choice in a common way. If the user doesn't provide a choice or enters bad data, the default value provided is returned. Otherwise, the value entered is returned. -} -promptWithDefault :: (Show a) => String -- ^ Message to display. Follows conventions of 'prompt'. +prompt1 :: (Show a) => String -- ^ Message to display. Follows conventions of 'prompt'. -> Request a -- ^ Request to evaluate. -> a -- ^ Default value to use if necessary. -> Request a -- ^ Result. -promptWithDefault msg req def = +prompt1 msg req def = let msgWithDefault = msg ++ " [" ++ show def ++ "] " in prompt msgWithDefault (reqDefault req def) - + +-- ^ Deprecated name for prompt1. +promptWithDefault :: (Show a) => String -> Request a -> a -> Request a +promptWithDefault = prompt1 + {- | Prints a message, displays defaults (if any), and turns a @Request String@ into a @Request Bool@. If @@ -799,7 +803,8 @@ do val <- arbitrary return (RandomRequest $ random val) - + coarbitrary = undefined + {- | Creates a request which will return a random value or Nothing. The request returns the same value every time it is evaluated. -} @@ -811,6 +816,7 @@ if rnd then return $ Request (return (Just val)) else return $ Request (return Nothing) + coarbitrary = undefined -- | QuickCheck does not define arbitrary for Chars for some reason ... instance Arbitrary Char where @@ -823,6 +829,7 @@ if isPrint val then return val else choose' + coarbitrary = undefined -- | Show for random requests. instance (Show a) => Show (RandomRequest a) where
hangman/Hangman.hs view
@@ -26,7 +26,7 @@ selectWord :: IO String selectWord = do - wordFile <- Path.getDataFileName "hangman\\2of12.txt" + wordFile <- Path.getDataFileName "hangman/2of12.txt" bracket (openFile wordFile ReadMode) hClose getWord where -- Select a word from the file. Start with file size / 2