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
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
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
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
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
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
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
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) >>=