preliminary Complex and Ratio Storable instances for Base
ClosedPublic

Authored by carter on Nov 21 2014, 7:51 PM.

Details

Summary

adding Storable instances for Complex and Ratio

Test Plan

still need to add tests (base seems to have NO storable tests ..)

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Branch
complex-storable
Lint
Lint WarningsExcuse: ignore
SeverityLocationCodeMessage
Warninglibraries/base/Data/Complex.hs:39TXT3Line Too Long
Unit
No Unit Test Coverage
Build Status
Buildable 2220
Build 2230: GHC Patch Validation (amd64/Linux)
carter updated this revision to Diff 1657.Nov 21 2014, 7:51 PM
carter retitled this revision from to preliminary Complex and Ratio Storable instances for Base.
carter updated this object.
carter edited the test plan for this revision. (Show Details)
carter added a reviewer: ekmett.
carter updated the Trac tickets for this revision.
hvr edited edge metadata.EditedNov 22 2014, 3:23 AM

@carter, please hurry up; the grace period for the GHC 7.10 freeze is rather short...

carter updated this revision to Diff 1660.Nov 22 2014, 10:05 AM
carter edited edge metadata.
  • fixup parsing error in definitions
carter updated this revision to Diff 1661.Nov 22 2014, 11:47 AM
  • drop using the realPart operations to get the fields
carter updated this revision to Diff 1662.Nov 22 2014, 2:03 PM
  • add changelog notes and tweak Ratio instance typesetting
carter updated this revision to Diff 1664.Nov 22 2014, 3:55 PM
  • adding basic test case for ratio and complex storable instances
ekmett requested changes to this revision.Nov 22 2014, 3:59 PM
ekmett edited edge metadata.
ekmett added inline comments.
libraries/base/Data/Complex.hs
40

Does adding these imports change SafeHaskell status?

libraries/base/Foreign/Storable.hs
219

This needs to use (%) here to prevent invariant violations.

This means the instance needs to pick up an Integral a => constraint.

This revision now requires changes to proceed.Nov 22 2014, 3:59 PM
carter updated this revision to Diff 1665.Nov 22 2014, 4:03 PM
carter edited edge metadata.
  • make sure invariants of ratio are maintained on peaks
carter updated this revision to Diff 1666.Nov 22 2014, 4:08 PM
carter edited edge metadata.
  • shifting to using Foreign.Safe to make it clearer that Data.Complex stays safe

Fixed up the Ratio instance with the % and Integral a, as suggested,

To make the safe inferrred clearer, I've shifted Data.Complex to using Foreign.Safe

ekmett accepted this revision.Nov 22 2014, 4:11 PM
ekmett edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 22 2014, 4:11 PM
carter updated this revision to Diff 1670.Nov 22 2014, 8:25 PM
carter edited edge metadata.
  • derp, forgot to import storable class
carter updated this revision to Diff 1673.Nov 22 2014, 9:19 PM
  • using Foreign rather than Foreign.Safe
carter updated this revision to Diff 1674.Nov 22 2014, 10:47 PM
  • futzing with stdout
carter updated this revision to Diff 1675.Nov 22 2014, 10:50 PM
  • woops, typo in test suite

for other reasons validate seems to be broken on os x, so i'm having a bit of trouble tracking down this bug

having trouble getting validate to work locally on my mac, but trying to track down whats wrong with the test suite

carter updated this revision to Diff 1676.Nov 23 2014, 12:24 AM
  • rewrote test to use operations exposed in base lib
  • making the instances correctly lazy in the proxy args
carter updated this revision to Diff 1678.Nov 23 2014, 12:39 AM
  • use the realPart function to avoid needing the scoped type variables extension

wooot, it validates

and just to be clear, it has a test!

This revision was automatically updated to reflect the committed changes.