blob: c2d0fc62559d346d2bd87872ea66dc78eb65fb2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
{-# LANGUAGE PatternSynonyms, ExistentialQuantification, GADTSyntax, TypeFamilies #-}
module T11010 where
data Expr a where
Fun :: String -> (a -> b) -> (Expr a -> Expr b)
pattern IntFun :: (a ~ Int) => String -> (a -> b) -> (Expr a -> Expr b)
pattern IntFun str f x = Fun str f x
-- Alternative syntax for pattern synonyms:
-- pattern
-- Suc :: () => (a ~ Int) => Expr a -> Expr Int
-- Suc n <- IntFun _ _ n where
-- Suc n = IntFun "suc" (+ 1) n
pattern Suc :: (a ~ Int) => Expr a -> Expr Int
pattern Suc n <- IntFun _ _ n where
Suc n = IntFun "suc" (+ 1) n
|