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,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • 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
  • #3600

Closed
Open
Opened Oct 20, 2009 by Simon Peyton Jones@simonpjDeveloper

Template Haskell mis-coverting empty list to empty string

Antoine Latter aslatter@gmail.com writes: the program Demo.hs compiles on 6.10, but not on 6.12rc1. The output --ddump-splices for 6.10:

Demo.hs:1:0:
   Demo.hs:1:0: Splicing declarations
       test
     ======>
       Demo.hs:6:2-5
       myFunction[aLQ] = Demo2.testFun []
Ok, modules loaded: Demo2, Main.

In 6.12rc1:

Demo.hs:1:0:
    Demo.hs:1:0: Splicing declarations
        test
      ======>
        Demo.hs:6:2-5
        myFunction[aNX] = testFun ""

Demo.hs:6:2:
    Couldn't match expected type `[Char]' against inferred type `Char'
      Expected type: [String]
      Inferred type: [Char]
    In the first argument of `testFun', namely `""'
    In the expression: testFun ""
Failed, modules loaded: Demo2.

The code is short:

---------- Demo.hs ---------------
{-# LANGUAGE TemplateHaskell #-}
module Demo where
import Demo2
$(test)

---------- Demo2.hs ---------------
{-# LANGUAGE TemplateHaskell #-}
module Demo2 where

import Language.Haskell.TH

test :: Q [Dec]
test = do
     let args = [] :: [String]
         body = [| testFun args |]
     decNm <- newName "myFunction"
     (:[]) `fmap` funD decNm [clause [] (normalB body) []]

testFun :: [String] -> String
testFun _ = "hello"
Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
6.12.1
Milestone
6.12.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#3600