|
Re: Initial (term) algebra for a state monad: msg#00051lang.haskell.cafe
In article <20050105201737.s24g48oo0w8w4occ@xxxxxxxxxxxxxxxxxxx>, ajb@xxxxxxxxxxx wrote: > Logical if-then-else has this signature: > > mif :: LogicT m a -> (a -> LogicT m b) -> LogicT m b -> LogicT m b > > Intuitively, this takes three arguments: the "condition", the "then" > case and the "else" case. This obeys the "obvious" laws of if-then-else: > > mif (return a) t e = t a > mif (mzero) t e = e > mif (mif c t' e') t e = mif c (\x -> mif (t' x) t e) (mif e' t e) > > plus the "soft cut" law: > > mif (return a `mplus` m) t e = t a `mplus` (m >>= t) > > The soft cut law is the one that stuffs up the more obvious candidates > for the passed context, because of this non-identity: > > mif (c1 `mplus` c2) t e /= mif c1 t e `mplus` mif c2 t e Is mif reducible to some "melse" with mif c t e = do ma <- (c >>= return . Just) `melse` (return Nothing) case ma of Just a -> t a Nothing -> e ...? -- Ashley Yakeley, Seattle WA |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Begginer question: 00051, Maurício |
|---|---|
| Next by Date: | Re: Begginer question: 00051, Jules Bean |
| Previous by Thread: | Re: Initial (term) algebra for a state monadi: 00051, ajb |
| Next by Thread: | RE: [Haskell-cafe] GHC for .NET?: 00051, Simon Peyton-Jones |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |