Re: [Haskell-cafe] Re: Allowing hyphens in identifiers
On Thu, Dec 10, 2009 at 12:54 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote: Given the amazinglyUglyAndUnreadably baStudlyCaps namingStyle that went into Haskell forNoApparentReasonThatIHaveEverHeardOf Compare: someCoolFunc fstParam sndParam fooBarBazQuux some_cool_func fst_param snd_param foo_bar_baz_quux In the first one, it's easy to see that there are 4 identifiers. But, at least for me, the second one is significantly harder to read; spaces and underscored are too similar. So, while underscores more clearly separate words in a single *identifier* and make it easier to read, in some cases I think they make *code* with many identifiers harder to read for exactly the same reason. In languages where function application looks like f(x,y,z) instead of f x y z this isn't a problem and I often use underscores. -- Johannes Laire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ?
On Wed, May 20, 2009 at 3:40 AM, z_a...@163.com z_a...@163.com wrote: Hi, friends rollDice :: Word8 - IO Word8 rollDice n = do bracket (openFile /dev/random ReadMode) (hClose) (\hd - do v - fmap B.unpack (B.hGet hd 1) let v1 = Data.List.head v return $ (v1 `mod` n) + 1) . blueIdx - rollDice $ length [1..33] Couldn't match expected type `Word8' against inferred type `Int' In the second argument of `($)', namely `length yesBlue I know length [1..33] is Int not Word8, but Word8 is enough here. Sincerely! Word8 is an instance of Num, so you could use Data.List.genericLength, which has the type: genericLength :: Num i = [b] - i http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#26 -- Johannes Laire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error: Improperly terminated character constant
Single quotes are for characters, double quotes are for strings. So change 'es' to es. -- Johannes Laire 2008/5/11 Ivan Amarquaye [EMAIL PROTECTED]: I'm writing a function dRop to accept words ending in 'es' and drop the last two characters i.e. 'es'.eg. mangoes - mongo but i keep on getting this error: Improperly terminated character constant after running this code which i have left below. Can i get any form of help from anyone in here...? - dRop :: String - String dRop word = if drop (length word - 2) word == 'es' then take (length word - 2) word else word -- regards Amarquaye.Ivan Connect to the next generation of MSN Messenger Get it now! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe