Re: [Haskell-cafe] Motion to unify all the string data types

2012-11-10 Thread Tobias Brandt
On 10 November 2012 04:00, Johan Tibell wrote: > As for type classes, I don't think we use them enough. Perhaps because > Haskell wasn't developed as an engineering language, some good software > engineering principles (code against an interface, not a concrete > implementation) aren't used in ou

Re: [Haskell-cafe] Is there a generic way to detect "mzero"?

2012-03-26 Thread Tobias Brandt
On 26 March 2012 20:33, Ting Lei wrote: > can :: (MonadPlus m) => (a -> m b) -> a -> Bool > can f x = case f x of >     mzero -> False >     _ -> True In the first pattern `mzero' is just a variable and matches anything, as does `_'. So, naturally, both patterns overlap. I don't

Re: [Haskell-cafe] variable definition according to input

2010-09-05 Thread Tobias Brandt
On 5 September 2010 21:04, Maria Merit wrote: > Is it possible to define variable names according to input data? For > instance: You can do arbitrary IO in TemplateHaskell. So, theoretically yes, you can define variables depending on input. But it has to be input during compilation/interpretation

Re: [Haskell-cafe] Restricted type classes

2010-09-03 Thread Tobias Brandt
On 3 September 2010 06:16, Ivan Lazar Miljenovic wrote: > 2c) Should I keep the classes as-is, or should I explicitly put in the > constraints mentioned in the Typeclassopedia (e.g. make Applicative an > explicit superclass of Monad, and define return = pure for > compatability reasons)? I also o

[Haskell-cafe] Re: Error in enumerator when using interpreter instead of compiler

2010-08-22 Thread Tobias Brandt
I forgot to mention that the file "bar" is created but empty. So it seems the Iteratee opens it and then closes it prematurely. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Error in enumerator when using interpreter instead of compiler

2010-08-22 Thread Tobias Brandt
Hi all, I was trying out the enumerator package. I wanted to copy the contents of one file to another: module Main where import Data.Enumerator import Data.Enumerator.IO main = run (enumFile "foo" $$ iterFile "bar") If I compile this code with GHC, it works as expected. But if I run it with runh

Re: [Haskell-cafe] Random this! ;-)

2010-07-25 Thread Tobias Brandt
Look for the function replicateM in the module Control.Monad. On 25 July 2010 17:39, michael rice wrote: > Hi All, > > From: http://en.wikibooks.org/wiki/Haskell/Understanding_monads/State > >Exercises > >1. Implement a function rollNDiceIO :: Int -> IO [Int] that

Re: [Haskell-cafe] Type problems

2010-07-24 Thread Tobias Brandt
You have to fix the type of 1 and 6, e.g. by writing x <- randomRIO (1, 6) :: IO Int or x <- randomRIO (1, 6 :: Int) GHCi defaults integral numbers to Int, that's why it works there. On 24 July 2010 21:36, michael rice wrote: > This works: > > Prelude System.Random> do { randomRIO (1,6) >>=