Search code examples
haskelltypesundefinedghctype-kinds

Undefined at the type level


Often when I'm playing with Haskell code, I stub things out with a type annotation and undefined.

foo :: String -> Int
foo = undefined

Is there a type-level "undefined" that I could use in a similar way?

(Ideally, in conjunction with a kind annotation)

type Foo :: * -> *
type Foo = Undefined

Further thought on the same thread: is there a way for me to stub out typeclass instances for types created this way? An even easier way than the following theoretical way?

instance Monad Foo where
  return = undefined
  (>>=) = undefined

Solution

  • This question was asked and answered a long time ago; best practices have evolved since.

    These days, instead of undefined, for stubbing out code you should be using typed holes, and their type-level analogue, partial type signatures.