Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,248
    • Issues 5,248
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 562
    • Merge requests 562
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9768
Closed
Open
Issue created Nov 04, 2014 by Alexander Vershilov@qnikstReporter

Declarations processed in unexpected order in the presence of TH declaration splices

In ghc-7.8 reify returns only first data type that have an instance, here is a code:

Test.hs

{-# LANGUAGE TemplateHaskell #-}
module Test where

import Language.Haskell.TH

class C a

inner :: ExpQ
inner = do
  ClassI _ instances <- reify ''C
  let sh = show instances
  [| sh |]

def :: String -> DecsQ
def x =
  let dn = mkName x
  in do dt <- dataD (cxt []) dn [] [] [] 
        i <- instanceD (cxt []) (appT (conT ''C) (conT dn)) [] -- [d| instance C $(cn) |]
        return [dt,i]

test :: ExpQ
test = [| print $inner |]

test.hs

{-# LANGUAGE TemplateHaskell #-}

import Test

def "A"
def "B"

main = $(test)

running test returns:

"[InstanceD [] (AppT (ConT Test.C) (ConT Main.A)) []]"

under 7.6 test returns:

"[InstanceD [] (AppT (ConT Test.C) (ContT Main.B) [], InstanceD [] (AppT (ConT Test.C) (ConT Main.A) []]"

Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited Mar 09, 2019 by Richard Eisenberg
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking