[vector] #101: Monad instance should define "fail"

vector vector at projects.haskell.org
Thu Jul 18 21:24:31 BST 2013


#101: Monad instance should define "fail"
----------------------------+-----------------------------------------------
Reporter:  evincarofautumn  |       Owner:     
    Type:  defect           |      Status:  new
Priority:  major            |   Milestone:     
 Version:                   |    Keywords:     
----------------------------+-----------------------------------------------
 The `Monad` instance for Vector is inconvenient to use with `do` and
 `-XMonadComprehensions` because it uses the default `fail`, which calls
 `error`. This disallows things like:

 {{{
 {-# LANGUAGE MonadComprehensions #-}

 mapMaybe :: (a -> Maybe b) -> Vector a -> Vector b
 mapMaybe f v = [x | Just x <- v]
 }}}

 The correct implementation is:

 {{{
 {-# INLINE fail #-}
 fail _ = empty
 }}}

-- 
Ticket URL: <http://trac.haskell.org/vector/ticket/101>
vector <http://trac.haskell.org/vector>
Package vector


More information about the vector mailing list