Re: how do I abstract this pattern ?

2008-05-21 Thread Brandon S. Allbery KF8NH
On 2008 May 21, at 12:31, Bulat Ziganshin wrote: Wednesday, May 21, 2008, 8:11:56 PM, you wrote: Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False. if they return Just result or Nothing - yes, use Maybe as mona

Re: how do I abstract this pattern ?

2008-05-21 Thread HP Wei
Thanks to all who has replied in such a short time. >From your reponses, I looked at the definition of `mplus` Nothing `mplus` ys = ys xs `mplus` _ = xs It catches the essence of what I am trying to do! Later, if pn grows in number, I can scale up by using some-kind-of-zero with so

Re: how do I abstract this pattern ?

2008-05-21 Thread C.M.Brown
On further thought, better to use the Maybe afterall. You can use Nothing to signify your False and Just to signify your result. case p1 s of Just result -> result Nothing -> case p2 s of ... That's probably more intuitive to what you were intending. Chris. On Wed, 21 May 2008, C.M.Brown wr

Re: how do I abstract this pattern ?

2008-05-21 Thread C.M.Brown
On Wed, 21 May 2008, HP Wei wrote: > > Suppose p1, p2, p3 are 3 predicates > that take an input -- say, a String. > They return either (True, result) > or False. > > I want to get an effect like in this expression: > > case p1 s of >(True, r) -> r >False -> case p2 s of >

Re: how do I abstract this pattern ?

2008-05-21 Thread Daniel Fischer
Am Mittwoch, 21. Mai 2008 18:31 schrieb Bulat Ziganshin: > Hello HP, > > Wednesday, May 21, 2008, 8:11:56 PM, you wrote: > > Suppose p1, p2, p3 are 3 predicates > > that take an input -- say, a String. > > They return either (True, result) > > or False. > > impossible because these

Re: ghc compiler <--- ld -R ?

2008-05-21 Thread Bulat Ziganshin
Hello HP, Wednesday, May 21, 2008, 8:21:01 PM, you wrote: > In the linker ld, there is a -R option example of passing option to ld: ghc ... -optl-Xlinker -optl--large-address-aware -optl-Xlinker may be optional -- Best regards, Bulatmailto:[EMAIL PROTECTED] __

Re: how do I abstract this pattern ?

2008-05-21 Thread Bulat Ziganshin
Hello HP, Wednesday, May 21, 2008, 8:11:56 PM, you wrote: > Suppose p1, p2, p3 are 3 predicates > that take an input -- say, a String. > They return either (True, result) > or False. impossible because these are different types :)) if they return Just result or Nothing - yes, us

ghc compiler <--- ld -R ?

2008-05-21 Thread HP Wei
In the linker ld, there is a -R option to encode lib-search-directories into the object file. Can we not do that in compiling this ghc -o foo --make foo.hs ??? Thanks HP ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org h

how do I abstract this pattern ?

2008-05-21 Thread HP Wei
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False. I want to get an effect like in this expression: case p1 s of (True, r) -> r False -> case p2 s of (True, r) -> r False -> ca