Ticket #4076 (closed proposal: fixed)

Opened 3 years ago

Last modified 15 months ago

Add Applicative instance for STM

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

Description

I propose adding an Applicative instance for STM.

The first attached patch adds an Applicative instance for STM to base/GHC/Cons.lhs.

Note I had to create a base/Control/Applicative.hs-boot file and import Applicative using {-# SOURCE #-} because I got a "Module imports form a cycle for modules" error.

The second attached patch adds an Applicative instance for the sequential STM to: stm/Control/Sequential/STM.hs

Attachments

stm_applicative-instance-sequential-stm.dpatch Download (1.7 KB) - added by basvandijk 3 years ago.
base_applicative-instance-stm.dpatch Download (33.9 KB) - added by basvandijk 3 years ago.
Adds Applicative and Alternative instances for STM to GHC.Conc
base_add_applicative_and_alternative_instances_for_STM_to_Control.Applicative.dpatch Download (31.6 KB) - added by basvandijk 3 years ago.
An alternative patch for base_applicative-instance-stm.dpatch that adds Applicative and Alternative instances for STM to Control.Applicative.
stm-applicative.diff Download (0.8 KB) - added by Lemming 15 months ago.
orphan Applicative and Alternative instances for GHC before 7.0

Change History

Changed 3 years ago by basvandijk

  Changed 3 years ago by basvandijk

 Thread on libraries@haskell.org

  Changed 3 years ago by basvandijk

In the discussion on the libraries list Ross Paterson suggested moving the MonadPlus? instance for STM from Control.Monad.STM to GHC.Conc to avoid an orphaned instance. I created ticket #4077 for this (including patches)

Changed 3 years ago by basvandijk

Adds Applicative and Alternative instances for STM to GHC.Conc

Changed 3 years ago by basvandijk

An alternative patch for base_applicative-instance-stm.dpatch that adds Applicative and Alternative instances for STM to Control.Applicative.

  Changed 3 years ago by simonmar

  • owner set to simonmar

  Changed 3 years ago by simonmar

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

Done:

Sun May 16 10:17:56 PDT 2010  Bas van Dijk <v.dijk.bas@gmail.com>
  * Added Applicative and Alternative instances for STM

follow-up: ↓ 6   Changed 15 months ago by Lemming

I am still using GHC-6.12.3. How about adding an orphan instance to the stm package that is defined for the GHC versions that do not provide the Applicative instance?

in reply to: ↑ 5 ; follow-up: ↓ 7   Changed 15 months ago by simonmar

  • difficulty set to Unknown

Replying to Lemming:

I am still using GHC-6.12.3. How about adding an orphan instance to the stm package that is defined for the GHC versions that do not provide the Applicative instance?

Patches welcome...

Changed 15 months ago by Lemming

orphan Applicative and Alternative instances for GHC before 7.0

in reply to: ↑ 6   Changed 15 months ago by Lemming

Replying to simonmar:

Patches welcome...

I added a diff with respect to 'git'/HEAD. I tested it with GHC-6.12.3, GHC-7.2.2, GHC-7.4.1. I could not test GHC-7.0.4 however.

Note: See TracTickets for help on using tickets.