Questions tagged [undecidable-instances]

12 questions
28
votes
2 answers

Why does this code using UndecidableInstances compile, then generate a runtime infinite loop?

When writing some code using UndecidableInstances earlier, I ran into something that I found very odd. I managed to unintentionally create some code that typechecks when I believed it should not: {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE…
Alexis King
  • 43,109
  • 15
  • 131
  • 205
7
votes
3 answers

How can undecidable instances actually hang the compiler?

By the time I first read serious criticism on -XUndecidableInstances, I had already completely accustomed to it, seeing it as merely removal of an annoying restriction Haskell98 has to make compilers easier to implement. In fact I've encountered…
leftaroundabout
  • 117,950
  • 5
  • 174
  • 319
2
votes
1 answer

Is it able to avoid UndecidableInstances in this example?

I am trying to implement binary tree as a typeclass: class BinaryTree bt where empty :: bt a -> Bool empty = isNothing . root emptyTree :: bt a branch :: a -> bt a -> bt a -> bt a root :: bt a -> Maybe a lbranch :: bt a ->…
qimokao
  • 93
  • 5
2
votes
2 answers

Transitive 'Subset` class for type-level-sets

I'm working with Dominic Orchard's type-level-sets library, which follows his paper pretty closely. I'm building a DSL for expressing communication between parties during a synchronous concurrent program. One thing I'm going to need is the ability…
2
votes
1 answer

GHC stuck due to UndecidableSuperClasses - expected behaviour or bug?

The following snippet makes GHC (checked with 8.6.2 & 8.4.4) stuck during compilation: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableSuperClasses #-} import GHC.Exts…
2
votes
2 answers

Can I automatically produce typeclass instances for a conversion function without being overly permissive?

Recently, I asked a question about an instance I had created generating a runtime infinite loop, and I got a wonderful answer! Now that I understand what was going on, I have a new question: can I fix my attempt to accomplish my original goal? Let…
Alexis King
  • 43,109
  • 15
  • 131
  • 205
1
vote
0 answers

Example of the undecidability of higher-order unification

Could you demonstrate the undecidability of higher-order unification by one example? For example, please show by one example that unification in lambda-calculus is undecidable.
1
vote
0 answers

Using Barbies' AllBF in an instance head without UndecidableInstances

I'd like to use AllBF from barbies in an instance head, like so: import Barbies import Barbies.Constraints class MyClass a where instance (ConstraintsB b, AllBF MyClass f b) => MyClass (Barbie b f) where This fails because of a hidden…
Cactus
  • 27,075
  • 9
  • 69
  • 149
1
vote
1 answer

Haskell typeclass constraint cannot be resolved due to Paterson's conditions

I'm trying to build an AST with indexed nested annotations. I added a typeclass for peeling the annotation at the top-level and tried to provide default instances that effectively says "if you know how to peel an annotation on its own, then you know…
madgen
  • 747
  • 3
  • 15
1
vote
1 answer

Turing machine decidability ambiguous cases

1) Is a Turing machine M that accepts the language L = {ε}, accepting no entry? In one hand, I think it can be false because the empty word could be an entry, but in another i think this could possibly be an indecidable problem. 2) Is every Turing…
Cmôn
  • 23
  • 2
1
vote
0 answers

Writing generic Monoid over Cofree; undecidable?

I'm trying to write the following Monoid instance for Cofree: instance (Monoid a, Monoid (f (Cofree f a))) => Monoid (Cofree f a) where mempty = mempty :< mempty (a :< rest) `mappend` (b :< rest') = (a `mappend` b) :< (rest `mappend` rest') but…
Chris Penner
  • 1,881
  • 11
  • 15
0
votes
0 answers

Turing Machine for regular languages

Theorem 5.3 from Sipser's TOC book is about decidability of Regular_TM = {M | M is a Turing Machines (TMs) and L(M) is regular languages}. For the sake of reaching a contradiction, TM R is assumed to be a decider for Regular_TM and then R is used to…