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,331
    • Issues 4,331
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 370
    • Merge Requests 370
  • 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
  • #189

Closed
Open
Opened Oct 09, 2003 by jcast@trac-jcast

Malformed Predicate w/ Template Haskell

The following two modules:

 --- Cut ---

module ScratchTemplates where

import Language.Haskell.THSyntax

newtype Interaction a = Interaction a deriving Show

ret = Interaction

instance Monad Interaction where
  return = Interaction
  Interaction x >>= f = f x

instance Functor Interaction where
  fmap f x = x >>= return . f

interactionT t = tcon (TconName "Interaction") `tapp` t

class Flatten a b | a -> b where
  flatten :: a -> b

flattenT :: TypQ -> TypQ -> TypQ
flattenT t t' = tvar "Flatten" `tapp` t `tapp` t

baseType t = sequence [
  inst (return []) (flattenT t t)
       [val (pvar "flatten") (normal (var "id")) []],
  inst (return []) (flattenT (interactionT t)
(interactionT t))
       [val (pvar "flatten") (normal (var "id")) []]]

instance Flatten a b =>
         Flatten (Interaction (Interaction a))
(Interaction b) where
  flatten a = a >>= id >>= return . flatten

module Main where

import Monad
import ScratchTemplates
import Language.Haskell.THSyntax

$(baseType (tcon (Tuple 0)))

instance Flatten String String where
  flatten a = a

instance Flatten (Interaction String) (Interaction
String) where
  flatten a = a

instance Flatten b c => Combine String b (String, c) where
  combine a b = liftM2 (,) a (fmap flatten b)

instance Flatten Int Int where
  flatten a = a

class Combine a b c | a b -> c where
  combine :: Interaction a -> Interaction b ->
Interaction c

instance Combine () b b where
  combine a b = b

instance Flatten b c => Combine Int b (Int, c) where
  combine a b = do
    x <- a
    y <- fmap flatten b
    return (x, y)

instance (Flatten b c, Combine a c d) =>
          Flatten (Interaction a, Interaction b)
(Interaction d) where
  flatten (a, b) = combine a (fmap flatten b)

main = main

 --- Cut here ---

loaded into ghci -fglasgow-exts produce the following
error message:

Compiling ScratchTemplates ( ScratchTemplates.hs,
interpreted )
Compiling Main             ( scratch.hs, interpreted )
ghc-6.0.1: panic! (the `impossible' happened, GHC
version 6.0.1):
	Malformed predicate

Please report it as a compiler bug to
glasgow-haskell-bugs@haskell.org,
or http://sourceforge.net/projects/ghc/.
Trac metadata
Trac field Value
Version 6.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#189