Opened 2 years ago

Closed 2 years ago

#7785 closed bug (fixed)

Module-local function not specialized with ConstraintKinds

Reported by: akio Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.6.2
Keywords: specialisation Cc: hackage.haskell.org@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case: simplCore/should_compile/T7785
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

In the attached program, 'shared' is not exported and only used with f = [], but it doesn't get specialized in the core. On the other hand, shared', which does not involve ConstraintKinds, gets correctly specialized.

Attachments (1)

spec.hs (1.3 KB) - added by akio 2 years ago.

Download all attachments as: .zip

Change History (6)

Changed 2 years ago by akio

comment:1 Changed 2 years ago by akio

This can be worked around by defining a wrapper class such that the constraint kind no longer directly shows up in the type signatures.

--- spec.hs	2013-03-22 15:41:23.000000000 +0900
+++ spec2.hs	2013-03-22 15:38:30.000000000 +0900
@@ -1,10 +1,12 @@
-{-# LANGUAGE TypeFamilies, ConstraintKinds #-}
+{-# LANGUAGE TypeFamilies, ConstraintKinds, MultiParamTypeClasses, UndecidableInstances, FlexibleContexts, FlexibleInstances #-}
 
 module Foo(foo, bar, foo', bar') where
 
 import GHC.Exts
 
 type family Domain (f :: * -> *) a :: Constraint
+class Domain f a => Domain' (f :: * -> *) a
+instance Domain f a => Domain' f a
 
 type instance Domain [] a = ()
 
@@ -12,9 +14,9 @@
   myfmap = map
 
 class MyFunctor f where
-  myfmap :: (Domain f a, Domain f b) => (a -> b) -> f a -> f b
+  myfmap :: (Domain' f a, Domain' f b) => (a -> b) -> f a -> f b
 
-shared :: (MyFunctor f, Domain f Int) => f Int -> f Int
+shared :: (MyFunctor f, Domain' f Int) => f Int -> f Int
 shared = let
   f = myfmap negate
   in

comment:2 Changed 2 years ago by liyang

  • Cc hackage.haskell.org@… added

comment:3 Changed 2 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1

Thanks for the report.

comment:4 Changed 2 years ago by simonpj@…

commit 5949ff2ddb715c3218c2cb96fd7170bae2ee02db

Author: Simon Peyton Jones <[email protected]>
Date:   Thu May 30 12:22:38 2013 +0100

    Refine 'type_determines_value' in Specialise.  Fix Trac #7785.
    
    See Note [Type determines value] in Specialise.

 compiler/specialise/Specialise.lhs |   40 ++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 8 deletions(-)

comment:5 Changed 2 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to simplCore/should_compile/T7785

Thanks for pointing this out. I've fixed it now.

Simon

Note: See TracTickets for help on using tickets.