summaryrefslogtreecommitdiff
path: root/testsuite/tests/patsyn/should_compile/T22328.hs
blob: 02830b829014f68ddc87dcc41626a854618c3b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{-# LANGUAGE TypeApplications, PatternSynonyms, GADTs, ViewPatterns #-}

module T22328 where

import Data.Typeable

data Gadt x y where
  ExistentialInGadt :: Typeable a => a -> Gadt x x

pattern CastGadt :: Typeable a => x ~ y => a -> Gadt x y
pattern CastGadt a <- ExistentialInGadt (cast -> Just a)

test :: Gadt i o -> Bool
test gadt = case gadt of
  CastGadt @Bool a -> a
  _ -> False