Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,322
    • Issues 4,322
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 367
    • Merge Requests 367
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10608

Closed
Open
Opened Jul 06, 2015 by Herbert Valerio Riedel@hvr🕺Maintainer

Compile error regression from GHC 7.10 to 7.11

Consider the following program,

{-# LANGUAGE OverloadedStrings #-}
-- {-# LANGUAGE FlexibleContexts #-}

chunksOf :: Int -> String -> [String]
chunksOf n = go
  where
    -- go :: String -> [String]
    go "" = []
    go s@(_:_) = a : go b
      where
        (a,b) = splitAt n s

when compiled with GHC 7.8.4:

GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( chunksof.hs, interpreted )

chunksof.hs:8:5: Warning:
    Pattern match(es) are overlapped
    In an equation for ‘go’: go s@(_ : _) = ...
Ok, modules loaded: Main.
λ:2> 

when compiled with GHC 7.10:

GHCi, version 7.10.1.20150630: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( chunksof.hs, interpreted )

chunksof.hs:8:5:
    Non type-variable argument in the constraint: Data.String.IsString [t]
    (Use FlexibleContexts to permit this)
    When checking that ‘go’ has the inferred type
      go :: forall t. (Eq t, Data.String.IsString [t]) => [t] -> [[t]]
    In an equation for ‘chunksOf’:
        chunksOf n
          = go
          where
              go "" = []
              go s@(_ : _)
                = a : go b
                where
                    (a, b) = splitAt n s
Failed, modules loaded: none.

NB: FlexibleContexts is rightly suggested!

However, when compiled with GHC HEAD:

GHCi, version 7.11.20150630: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( chunksof.hs, interpreted )

chunksof.hs:8:8: error:
    Could not deduce (IsString [t]) arising from the literal ‘""’
    from the context: Eq t bound by the inferred type of go :: Eq t => [t] -> [[t]] at chunksof.hs:(8,5)-(11,27)
    In the pattern: ""
    In an equation for ‘go’: go "" = []
    In an equation for ‘chunksOf’:
        chunksOf n
          = go
          where
              go "" = []
              go s@(_ : _)
                = a : go b
                where
                    (a, b) = splitAt n s
Failed, modules loaded: none.
Trac metadata
Trac field Value
Version 7.11
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.0.1
Milestone
8.0.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#10608