
3 Jul
2010
3 Jul
'10
4:06 p.m.
On Saturday 03 July 2010 3:57:34 pm Thomas Hartman wrote:
When I load up Control.Applicative in ghci and try, eg
many [1,2] or many (Just 1) or some [1,2] or some (Just 1)
this never returns.
What are the practical uses of these combinators, or for using the Alternative class in general?
import Control.Applicative import Control.Monad import Control.Monad.State type M = StateT [Int] [] pluck :: M Int pluck = do l <- get case l of [] -> empty x:xs -> put xs *> pure x {- *Main> runStateT (many pluck) [1..4] [([1,2,3,4],[]),([1,2,3],[4]),([1,2],[3,4]),([1],[2,3,4]),([],[1,2,3,4])] -} -- Dan