Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,248
    • Issues 4,248
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #12828

Closed
Open
Opened Nov 12, 2016 by Icelandjack@IcelandjackReporter

Generalize functions from Data.Maybe (‘catMaybes’, ‘mapMaybe’)

Opening a ticket for discussion. As mentioned in this comment, more functions can be generalized to Foldable

catMaybes   :: Foldable f => f (Maybe a) -> [a]
mapMaybe    :: Foldable f => (a -> Maybe b) -> (f a -> [b])
listToMaybe :: Foldable f => f a -> Maybe a

I think catMaybes and mapMaybe are fine candidates. The comment offers more extreme changes,

catMaybes :: (Foldable f, Foldable g) => f (g a) -> [a]
mapMaybe  :: (Foldable f, Foldable g) => (a -> f b) -> (f a -> [b])
Edited Mar 10, 2019 by Icelandjack
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#12828