how do I abstract this pattern ?

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Wed May 21 16:55:32 EDT 2008


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 monad:
>
> combine p1 p2 p3 x= do x1 <- p1 x
>                       x2 <- p2 x1
>                       x3 <- p3 x2
>                       return x3

S/He's not passing on r (the result), but s (the argument).  Monad ((- 
 >) r)?

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Glasgow-haskell-users mailing list