Ticket #5699 (closed feature request: fixed)

Opened 18 months ago

Last modified 16 months ago

Use sharing in the Alternative instance of Maybe

Reported by: basvandijk Owned by:
Priority: normal Milestone: 7.6.1
Component: libraries/base Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The <|> method of the Alternative instance of Maybe does not share its first argument when it could:

instance Alternative Maybe where
    empty = Nothing
    Nothing <|> p = p
    Just x  <|> _ = Just x

I propose to share this argument:

instance Alternative Maybe where
    empty = Nothing
    Nothing <|> r = r
    l       <|> _ = l

Attachments

Change History

Changed 18 months ago by basvandijk

Changed 17 months ago by igloo

  • status changed from new to patch
  • difficulty set to Unknown
  • milestone set to 7.6.1

Changed 16 months ago by igloo

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

Applied:

commit 1d97ad10283d23b6dfb698a38ae57c29accd6ada
Author: Bas van Dijk <v.dijk.bas@gmail.com>
Date:   Wed Dec 14 12:24:38 2011 +0100

    Use sharing in the Alternative instance of Maybe
Note: See TracTickets for help on using tickets.