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,249
    • Issues 4,249
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 393
    • Merge Requests 393
  • 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
  • #14605

Closed
Open
Opened Dec 21, 2017 by Icelandjack@IcelandjackReporter

Core Lint error

This piece of code fails when run with ghci -ignore-dot-ghci -fdefer-type-errors -dcore-lint bug.hs, maybe same as my previous #14584 (closed).

{-# Language DerivingStrategies #-}
{-# Language GeneralizedNewtypeDeriving #-}
{-# Language InstanceSigs #-}
{-# Language KindSignatures #-}
{-# Language PolyKinds #-}
{-# Language ScopedTypeVariables #-}
{-# Language TypeApplications #-}
{-# Language TypeFamilies #-}
{-# Language TypeInType #-}
{-# Language TypeOperators #-}
{-# Language UndecidableInstances #-}

import Data.Kind
import Data.Functor.Identity
import Data.Functor.Product

type a <-> b = a -> b -> Type

class Iso (iso :: a <-> b) where
  iso :: a -> b
  osi :: b -> a

data Iso_Bool :: Either () () <-> Bool

instance Iso Iso_Bool where

class Representable f where
  type Rep f :: Type

  index    :: f a -> (Rep f -> a)
  tabulate :: (Rep f -> a) -> f a

class Comonad w where
  extract   :: w a -> a
  duplicate :: w a -> w (w a)

newtype Co f a = Co (f a) deriving newtype (Functor, Representable)

instance (Representable f, Monoid (Rep f)) => Comonad (Co f) where
  extract = (`index` mempty)

newtype WRAP (iso::old <-> new) f a = WRAP (f a)

instance (Representable f, Rep f ~ old, Iso iso) => Representable (WRAP (iso :: old <-> new) f) where
  type Rep (WRAP (iso :: old <-> new) f) = new

  index :: WRAP iso f a -> (new -> a)
  index (WRAP fa) = index fa . osi @old @new @iso

  tabulate :: (new -> a) -> WRAP iso f a
  tabulate gen = WRAP $ 
    tabulate (gen . iso @old @new @iso)

newtype PAIR a = PAIR (Co (WRAP Iso_Bool (Product Identity Identity)) a)
  deriving newtype
    Comonad 

I unfortunately don't have time to find a more minimal example. Core linter vomits a lot of errors on 8.2.1 & 8.3.20171208.

Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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#14605