Skip to content

Instantly share code, notes, and snippets.

@haitlahcen
Last active December 20, 2018 16:23
Show Gist options
  • Select an option

  • Save haitlahcen/1dcc8363cef48e554685f1ee8aded69b to your computer and use it in GitHub Desktop.

Select an option

Save haitlahcen/1dcc8363cef48e554685f1ee8aded69b to your computer and use it in GitHub Desktop.
ViewPattern + PatternSynonyms
pattern (:-) :: Char -> T.Text -> T.Text
pattern x :- xs <- (T.uncons -> Just (x, xs))
where x :- xs = T.cons x xs
infixr 5 :-
-- No need for (Just (x, (Just (y, ys)), it automatically uncons + desugar
t :: T.Text -> T.Text
t (x :- y :- ys) = ys
t _ = ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment