Skip to content
This repository was archived by the owner on Jun 13, 2020. It is now read-only.

Latest commit

 

History

History
16 lines (12 loc) · 466 Bytes

2013603.md

File metadata and controls

16 lines (12 loc) · 466 Bytes
title
Pattern Synonym on multiple constructors

ViewPatterns can be used to define a pattern synonym matching on more than one constructor. An example:

pattern Foo s <- 
  ((\case { SomeConstr1 _ s -> Just s; SomeConstr2 s -> Just s; _ -> Nothing }
   ) -> Just s
  )

lexi.lambda writes:

The Maybe wrapping is there to communicate that the pattern-matcher should backtrack on anything other than SomeConstr1 and SomeConstr2