Skip to content

Allow promotion of one-to-one pattern synonyms

{-# LANGUAGE PatternSynonyms, DataKinds #-}

import Data.Proxy
import Data.Kind

pattern JustJust :: a -> Maybe (Maybe a)
pattern JustJust x = Just (Just x)

p :: Proxy (JustJust Type)
p = Proxy

is rejected because of

    • Pattern synonym ‘JustJust’ cannot be used here
        (pattern synonyms cannot be promoted)

but I don't see why not.

This issue allows to distinguish between pattern synonym and real constructor, e.g. a pattern synonym like

pattern Some :: a -> Maybe a
pattern Some x = Just x

cannot be used to provide backwards compatibility when renaming constructors! (e.g. upcoming Solo to MkSolo is a real example).

Edited by Oleg Grenrus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information