Skip to main content

Home/ Haskell/ Group items tagged Haskell

Rss Feed Group items tagged

J.A. Alonso

A tour of the Haskell monad functions - 1 views

  • ap module: Control.Monad type: ap :: (Monad m) => m (a -> b) -> m a -> m b
Javier Neira

Monads in 15 minutes: Backtracking and Maybe - 0 views

  • type Choice a = [a] choose :: [a] -> Choice a choose xs = xs
  • Because Haskell doesn’t compute answers until we ask for them, we get the actual backtracking for free!
  • The missing function is almost too trivial to mention: Given a single value of type a, we need a convenient way to construct a value of type Choice a:
  • ...5 more annotations...
  • More math trivia: return is also known as unit and η. That’s a lot of names for a very simple idea.)
  • makePairs = choose [1,2,3] >>= (\x -> choose [4,5,6] >>= (\y -> return (x,y)))
  • makePairs' = do x <- choose [1,2,3] y <- choose [4,5,6] return (x,y)
  • Every monad has three pieces: return, map and join.
  • Backtracking: The lazy way to code
Xiaobin Huang

'Cannot justify constraints in explicitly typed binding ', Hugs complained. - 10 views

Now I know, it should be 'permutation :: Eq a => [a]->[[a]]'. Xiaobin Huang wrote: > hi all, > > I'm new to Haskell. > > I wrote a permutation prog. > > permutation [] = [[]] > p...

« First ‹ Previous 101 - 120 of 157 Next › Last »
Showing 20 items per page