Ticket #1464 (closed proposal: fixed)

Opened 5 years ago

Last modified 3 years ago

Proposal: add dropPrefix to Data.List

Reported by: igloo Owned by:
Priority: normal Milestone: Not GHC
Component: libraries/base Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I seem to have a copy of this function in everything I write sooner or later, so I'd like to propose its addition to Data.List. It strips a prefix from a list and, if successful, returns the tail. I often use it with pattern guards:

foo :: String -> IO ()
foo x
 | Just y <- dropPrefix "foo=" = putStrLn ("foo is " ++ show y)
foo _ = putStrLn "Unknown"

but you can of course achieve the same by using case etc.

Let's try 11 July for a discussion deadline.

Attachments

1464.1.dpatch Download (59.4 KB) - added by igloo 5 years ago.

Change History

Changed 5 years ago by igloo

Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Fixed by:

Sun Jul 15 00:52:04 BST 2007  Ian Lynagh <igloo@earth.li>
  * Define stripPrefix; fixes trac #1464

For the gory details the thread starts at  http://www.haskell.org/pipermail/libraries/2007-June/007657.html

There was general agreement that this should go in. A couple of more general variants were discussed, but concensus was that the simple, specific function should go in regardless.

There was no real concensus on what the name should be, but stripPrefix seems to have at least as much support as anything else. dropPrefix was disliked as it returned a Maybe type, unlike all other drop* functions.

Changed 3 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 3 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.