Re: [Haskell-cafe] Hi I need help for very simple question!

2007-03-02 Thread Bryan Donlan
Taillefer, Troy (EXP) wrote: Hi there 1. First of all never forget your base case for exiting your recursion 2. you need to break up the problem like so import Char -- get the first word word :: String -> String word [] = [] word ( x : x1 : xs ) | isSpace x = [] | isSpace x1 =

Re: [Haskell-cafe] Strings in Haskell

2007-01-22 Thread Bryan Donlan
Neil Mitchell wrote: > Hi Alexy, > >> Now I'm reading a >> Haskell book which states the same. Is there a more efficient Haskell >> string-handling method? Which functional language is the most >> suitable for text processing? > > There are the Data.ByteString things, which are great, and have m

Re: [Haskell-cafe] Type infer

2007-01-24 Thread Bryan Donlan
Marco TĂșlio Gontijo e Silva wrote: Hello, I'm trying to define a partition__ function that is like Data.Set.partition, but use State Monad: import Data.Set import Control.Monad.State partition__ f = do snapshot <- get let (firsts, rest) = Set.partition f snapshot put

Re: [Haskell-cafe] Re: DevRandom

2007-01-30 Thread Bryan Donlan
Yitzchak Gale wrote: It's short, so I'll post it here. Any comments? readDev :: Storable a => FilePath -> BlockingMode -> IO (Maybe a) readDev dev mode = do h <- openFile dev ReadMode hSetBuffering h NoBuffering alloca $ getMaybe h undefined where getMaybe :: Storable a => Handle

Re: [Haskell-cafe] are Monads with slightly stricter types in instances still Monads?

2007-01-30 Thread Bryan Donlan
Julien Oster wrote: Hello, The type of the monadic bind function in the Monad class is Monad m => m a -> (a -> m b) -> m b Now, would it be possible to create a monad with a slightly stricter type, like StrictMonat m => m a -> (a -> m a) -> m a and, accepting that all steps of the computat

Re: [Haskell-cafe] Replacing [a] with (Set c a) in Monad instance.

2007-01-30 Thread Bryan Donlan
Daniel McAllansmith wrote: Hello. Given: newtype Dist a = D {unD :: [(a,Int)]} instance Monad Dist where return x = D [(x,1)] d >>= f = D [(y,q*p) | (x,p) <- unD d, (y,q) <- unD (f x)] fail _ = D [] How would one change Dist to wrap an instance of the (Data.Edison.Set c a) typeclas

Re: [Haskell-cafe] Re: DevRandom

2007-01-31 Thread Bryan Donlan
Yitzchak Gale wrote: Bryan Donlan wrote: This re-opens the device every time we need it. How about opening once, when it's first needed? Good idea. hDevRandom :: Handle {-# NOINLINE hDevRandom #-} hDevRandom = unsafePerformIO $ openFile "/dev/random" ReadMode hDevUR

Re: [Haskell-cafe] List operation question

2007-02-04 Thread Bryan Donlan
Eric Olander wrote: Hi, I'm still somewhat new to Haskell, so I'm wondering if there are better ways I could implement the following functions, especially shiftl: >> moves the first element to the end of the list shiftr :: [a] -> [a] shiftr [] = [] shiftr (x:y) = y ++ [x]

Re: [Haskell-cafe] nested maybes

2007-02-05 Thread Bryan Donlan
Martin DeMello wrote: On 2/5/07, Bulat Ziganshin <[EMAIL PROTECTED]> wrote: Hello J., Sunday, February 4, 2007, 11:46:57 PM, you wrote: > exists s wmap = isJust $ find (==s) . snd =<< Map.lookup (sort s) wmap exists s wmap = Map.lookup (sort s) wmap >>== snd

[Haskell-cafe] Control.Exception.evaluate - 'correct definition' not so correct

2008-05-03 Thread Bryan Donlan
mented somewhere (or is it?). Otherwise Control.Exception's docs should be updated to provide a more correct example and/or the caveat that >>= must not be left-strict for the example implementation to be correct. Thanks, Bryan Donlan signature.asc Description: Digital signature _

[Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types

2008-07-28 Thread Bryan Donlan
urrent implementation? (Note, I'm testing with GHC 6.8.2, so it's possible this might be fixed in trunk already...) Thanks, Bryan Donlan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] carry "state" around ....

2008-07-28 Thread Bryan Donlan
On Mon, Jul 28, 2008 at 08:48:23PM -0500, Galchin, Vasili wrote: > what does a datatype with no constructors mean? > > E.g. > > data RSAStruct > data EVP_PKEY > data EVP_CIPHER > data EVP_CIPHER_CTX > data EVP_MD_CTX > data EVP_MD > data BIGNUM It's simply a datatype that can never have a value