[Haskell-cafe] Re: Getting WriterT log lazily

2009-05-07 Thread Ertugrul Soeylemez
Ertugrul Soeylemez wrote: > There are two issues with unsafePerformIO: [...] Of course I meant unsafeInterleaveIO, sorry. There are a lot more than two issues with unsafePerformIO. =) Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog

[Haskell-cafe] Re: Getting WriterT log lazily

2009-05-07 Thread Ertugrul Soeylemez
Stephen Hicks wrote: > Magnus Therning wrote: > > Martijn van Steenbergen wrote: > >> > >> Otherwise, you can use unsafeInterleaveIO: no unsafePerformIO or seq > >> needed, but there's still "unsafe" in that name there. This works for me: > ... > > Thanks, that does indeed work, but it still requ

[Haskell-cafe] Re: Getting WriterT log lazily

2009-05-03 Thread Ertugrul Soeylemez
Hello Magnus, although your approach is a bit more pragmatic, I always prefer to use concurrency to implement predictable logging. This is a bit more code, but works much nicer and a lot more predictable: {-# LANGUAGE ExistentialQuantification #-} module Main where import Control.Concurr

[Haskell-cafe] Re: Functor and Haskell

2009-04-21 Thread Ertugrul Soeylemez
Daryoush Mehrtash wrote: > In category theory functors are defined between two category of C and > D where every object and morphism from C is mapped to D. > > I am trying to make sense of the above definition with functor class > in Haskell. Let say I am dealing with List type. When I define L

[Haskell-cafe] Re: how to implement daemon start and stop directives?

2009-01-23 Thread Ertugrul Soeylemez
Eugene Kirpichov wrote: > >> daemon :: IO () -> IO (IO ()) > >> daemon action = do > >> stopvar <- newIORef False > >> let run = do > >> stop <- readIORef stopvar > >> if stop then return () else (action >> run) > >> forkIO run > >> return (writeIORef stopvar T

[Haskell-cafe] Re: Is it possible to model eventually consistent side effects?

2009-01-23 Thread Ertugrul Soeylemez
Daryoush Mehrtash wrote: > I am trying to figure out if there is a way to model cloud computing > computations in Haskell. > > My specific problems is that in cloud computing, as in Amazon > WebServices, side effects (writes to storage, simple database, queue) > follow the eventually consistent m

[Haskell-cafe] Re: how to implement daemon start and stop directives?

2009-01-22 Thread Ertugrul Soeylemez
Luke Palmer wrote: > On Thu, Jan 22, 2009 at 9:04 AM, Ertugrul Soeylemez wrote: > > > Sometimes this is inevitable, but I've never seen a case, where > > IORefs couldn't be replaced by a more elegant State/StateT-based > > solution. And if you need to do

[Haskell-cafe] Re: how to implement daemon start and stop directives?

2009-01-22 Thread Ertugrul Soeylemez
Luke Palmer wrote: > On Thu, Jan 22, 2009 at 5:48 AM, Ertugrul Soeylemez wrote: > > > Luke Palmer wrote: > > > > > TVars are overkill here, actually, an IORef would be just fine, I > > > think. > > > > Using IORefs is generally a sign of bad sty

[Haskell-cafe] Re: how to implement daemon start and stop directives?

2009-01-22 Thread Ertugrul Soeylemez
Luke Palmer wrote: > TVars are overkill here, actually, an IORef would be just fine, I > think. Using IORefs is generally a sign of bad style. But MVars would perfectly suffice here. They would be essentially the same, but without 'atomically'. Greets, Ertugrul. -- nightmare = unsafePerfo

[Haskell-cafe] Re: Does readFile "/proc/mounts" hang for you?

2009-01-21 Thread Ertugrul Soeylemez
David Fox wrote: > I posted a bug about this > (http://hackage.haskell.org/trac/ghc/ticket/2971) but its so odd I had > to ask here. Using ghc 6.10.1, both readFile "/proc/mounts" and > Data.ByteString.Lazy.Char8.readFile "/proc/mounts" hang on an amd64 > machine running Linux. Also, Data.ByteS

[Haskell-cafe] Re: Pure Haskell implementation of Float type?

2009-01-21 Thread Ertugrul Soeylemez
"Tim Chevalier" wrote: > Is there a pure Haskell implementation of Floats, i.e., one that > (unlike GHC.Float) doesn't use foreign calls for things like > isFloatNegativeZero? I don't care about performance; I'm just looking > for something that doesn't use foreign calls. You can easily do it yo

[Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-18 Thread Ertugrul Soeylemez
Andrew Coppin wrote: > Ertugrul Soeylemez wrote: > > Andrew Coppin wrote: > > > >> I would suggest that ExistentiallyQuantifiedTypeVariables would be > >> an improvement [...] > > > > That must be a joke. Typing the long extension names in LANGUAGE

[Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-17 Thread Ertugrul Soeylemez
Andrew Coppin wrote: > I would suggest that ExistentiallyQuantifiedTypeVariables would be an > improvement [...] That must be a joke. Typing the long extension names in LANGUAGE pragmas over and over again is tiring and annoying enough already. We really don't need even longer names, and your

[Haskell-cafe] Re: Simplification of this function?

2009-01-16 Thread Ertugrul Soeylemez
"Andrew Wagner" wrote: > I've been playing around with this, but haven't been able to come up > with anything. > myFunc f (a,b) (c,d) = (f a c, f b d) > > It feels as if there should be a nice simple version of this using > some combination of {un,}curry, "on", &&&, ***, or something else. > > An

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-15 Thread Ertugrul Soeylemez
"Apfelmus, Heinrich" wrote: > [...] but this is very different from using a particular monad like > the state monad and hoping that using it somehow gives an insight into > the problem domain. You're right, mostly. However, there are a lot of problems, where you cannot provide any useful abstra

[Haskell-cafe] Re: The problem with Monads...

2009-01-13 Thread Ertugrul Soeylemez
Jonathan Cast wrote: > On Tue, 2009-01-13 at 12:56 -0200, Rafael Gustavo da Cunha Pereira Pinto > wrote: > > > Inspired by the paper "Functional Programming with Overloading and > > Higher-Order Polymorphism", > > Mark P Jones > > (http://web.cecs.pdx.edu/~mpj/pubs/springschool.html) > >

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-11 Thread Ertugrul Soeylemez
Ertugrul Soeylemez wrote: > Personally I prefer this: > > somethingWithRandomsM :: (Monad m, Random a) => m a -> Something a Of course, there is something missing here: somethingWithRandomsM :: (Monad m, Random a) => m a -> m (Something a) Sorry. Greets, Ertu

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-11 Thread Ertugrul Soeylemez
"Apfelmus, Heinrich" wrote: > Ertugrul Soeylemez wrote: > > > Let me tell you that usually 90% of my code is monadic and there is > > really nothing wrong with that. I use especially State monads and > > StateT transformers very often, because they are c

[Haskell-cafe] Monads aren't evil

2009-01-08 Thread Ertugrul Soeylemez
Hello fellow Haskellers, When I read questions from Haskell beginners, it somehow seems like they try to avoid monads and view them as a last resort, if there is no easy non-monadic way. I'm really sure that the cause for this is that most tutorials deal with monads very sparingly and mostly in t

[Haskell-cafe] Re: How to give unique name/id to nodes outside any monad ?

2009-01-08 Thread Ertugrul Soeylemez
"minh thu" wrote: > Nothing, simply the notation. Now, with the remark of Luke, I'm > wondering how bad it is to use makeStableName/hashStableName to "copy" > the data structure in a similar one with explicit reference (that is, > using pointer or keys in a map or whatever). Probably you're misu

[Haskell-cafe] Re: What are side effects in Haskell?

2009-01-02 Thread Ertugrul Soeylemez
Adrian Neumann wrote: > Am 23.12.2008 um 15:16 schrieb Hans van Thiel: > > > I just saw somewhere that one of the purposes of monads is to > > capture side effects. I understand what a side effect is in C, for > > example. Say you want to switch the contents of two variables. Then > > you need a

[Haskell-cafe] Re: Request for feedback: Understanding Haskell Monads

2008-12-28 Thread Ertugrul Soeylemez
Hans van Thiel wrote: > On Sat, 2008-12-27 at 02:35 +0100, Ertugrul Soeylemez wrote: > > > In the last few weeks I have written a comprehensive tutorial about > > Haskell monads [1], and I was hoping to get some constructive > > feedback. I'd appreciate any wel

[Haskell-cafe] Re: Request for feedback: Understanding Haskell Monads

2008-12-28 Thread Ertugrul Soeylemez
Ertugrul Soeylemez wrote: > In the last few weeks I have written a comprehensive tutorial about > Haskell monads [1], and I was hoping to get some constructive > feedback. I'd appreciate any well meant criticism. > > [1] http://ertes.de/articles/monads.html Thank you a

[Haskell-cafe] Request for feedback: Understanding Haskell Monads

2008-12-26 Thread Ertugrul Soeylemez
Hello fellow Haskellers, In the last few weeks I have written a comprehensive tutorial about Haskell monads [1], and I was hoping to get some constructive feedback. I'd appreciate any well meant criticism. [1] http://ertes.de/articles/monads.html Greets, Ertugrul. -- nightmare = unsafePerfor

<    1   2   3