Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#8537 closed bug (fixed)

confusing error message for specialize pragma

Reported by: carter Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: simplCore/should_compile/T8537 Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj)

I get the following confusing error/warning about SPECIALIZE

  SPECIALISE pragma for non-overloaded function `$cfmap' 

with the following example module

{-# LANGUAGE PolyKinds   #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Numerical.Types.Shape where

import Control.Applicative
import Data.Foldable 
import Data.Monoid
import Data.Functor
import Prelude (seq, ($!),($),Show(..),Eq(),Int)


data Nat = S !Nat  | Z 

infixr 3 :*
    
data Shape (rank :: Nat) a where 
    Nil  :: Shape Z a
    (:*) ::  !(a) -> !(Shape r a ) -> Shape  (S r) a

instance Functor (Shape Z) where

    fmap  = \ f Nil -> Nil 
    {-# INLINABLE fmap #-}
    
    {-# SPECIALIZE fmap :: (Int ->Int )-> (Shape Z Int)-> (Shape Z Int) #-}

Change History (5)

comment:1 Changed 5 months ago by simonpj

  • Description modified (diff)

The $cfmap part is not very clever, but the actual message is fine isn't it? There isn't any useful specialisation we can do on fmap at type (Shape Z) is there? I suppose you might say that the pattern match is exhaustive so we could omit the test for Nil vs (:*), but that's all.

Simon

comment:2 Changed 5 months ago by Simon Peyton Jones <simonpj@…>

In 7db23406e4162f9925474fc76b7dffd5d302c312/ghc:

Print the correct name when complaining about SPECIALISE pragmas

Fixes Trac #8537

comment:3 Changed 5 months ago by Simon Peyton Jones <simonpj@…>

comment:4 Changed 5 months ago by simonpj

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

Error message improved!

Simon

comment:5 Changed 5 months ago by carter

great!

Note: See TracTickets for help on using tickets.