summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/twins.hs
blob: 99c77aa7968ebb2a6fdac17183ad804f5b350e9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
{-# LANGUAGE RankNTypes, LiberalTypeSynonyms #-}

-- This test checks that deep skolemisation and deep
-- instantiation work right.  A buggy prototype
-- of GHC 7.0, where the type checker generated wrong
-- code, sent applyTypeToArgs into a loop.

module Twins where

import Data.Data

type GenericQ r = forall a. Data a => a -> r
type GenericM m = forall a. Data a => a -> m a

gzip :: GenericQ (GenericM Maybe) -> GenericQ (GenericM Maybe)
gzip f x y
  = f x y
     `orElse`
    if toConstr x == toConstr y
    then gzipWithM (gzip f) x y
    else Nothing

gzipWithM :: Monad m => GenericQ (GenericM m) -> GenericQ (GenericM m)
gzipWithM _ = error "urk"

orElse :: Maybe a -> Maybe a -> Maybe a
orElse = error "urk"