Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pattern synonyms for IsSequence #250

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classy-prelude-conduit/classy-prelude-conduit.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.7.
-- This file has been generated from package.yaml by hpack version 0.37.0.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -35,7 +35,7 @@ library
build-depends:
base >=4.13 && <5
, bytestring
, classy-prelude ==1.5.0.*
, classy-prelude ==1.5.*
, conduit ==1.3.*
, monad-control
, resourcet
Expand Down
2 changes: 1 addition & 1 deletion classy-prelude-conduit/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library:
- -fno-warn-orphans
dependencies:
- conduit >=1.3 && <1.4
- classy-prelude >=1.5.0 && <1.5.1
- classy-prelude >= 1.5 && < 1.6
- monad-control
- resourcet
- void
Expand Down
4 changes: 2 additions & 2 deletions classy-prelude-yesod/classy-prelude-yesod.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.7.
-- This file has been generated from package.yaml by hpack version 0.37.0.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -34,7 +34,7 @@ library
build-depends:
aeson
, base >=4.13 && <5
, classy-prelude ==1.5.0.*
, classy-prelude ==1.5.*
, classy-prelude-conduit ==1.5.0.*
, data-default
, http-conduit
Expand Down
2 changes: 1 addition & 1 deletion classy-prelude-yesod/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extra-source-files:

dependencies:
- base >= 4.13 && <5
- classy-prelude >=1.5.0 && <1.5.1
- classy-prelude >= 1.5 && < 1.6
- classy-prelude-conduit >=1.5.0 && <1.5.1
- yesod >=1.2
- yesod-newsfeed
Expand Down
4 changes: 4 additions & 0 deletions classy-prelude/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog for classy-prelude

## 1.5.1.0

* Added Empty and Cons pattern synonyms for sequences [#241](https://github.com/snoyberg/mono-traversable/issues/241)

## 1.5.0.3

* Don't import Data.Functor.unzip [#215](https://github.com/snoyberg/mono-traversable/pull/215)
Expand Down
2 changes: 1 addition & 1 deletion classy-prelude/classy-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: classy-prelude
version: 1.5.0.3
version: 1.5.1.0
synopsis: A typeclass-based Prelude.
description: See docs and README at <http://www.stackage.org/package/classy-prelude>
category: Control, Prelude
Expand Down
2 changes: 1 addition & 1 deletion classy-prelude/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: classy-prelude
version: 1.5.0.3
version: 1.5.1.0
synopsis: A typeclass-based Prelude.
description: See docs and README at <http://www.stackage.org/package/classy-prelude>
category: Control, Prelude
Expand Down
19 changes: 19 additions & 0 deletions classy-prelude/src/ClassyPrelude.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module ClassyPrelude
( -- * CorePrelude
module CorePrelude
Expand Down Expand Up @@ -129,6 +131,9 @@ module ClassyPrelude
, DList
, asDList
, applyDList
-- ** Pattern synonyms for sequences
, pattern Empty
, pattern Cons
-- ** Exceptions
, module Control.DeepSeq
-- ** Force types
Expand Down Expand Up @@ -627,6 +632,20 @@ getContents = liftIO LTextIO.getContents
interact :: MonadIO m => (LText -> LText) -> m ()
interact = liftIO . LTextIO.interact

{-# COMPLETE Empty, Cons #-}
-- | Corresponds to [] for List
--
-- @since 1.5.1
pattern Empty :: IsSequence seq => seq
pattern Empty <- (uncons -> Nothing) where
Empty = fromList []

-- | Corresponds to (x : xs) for List
--
-- @since 1.5.1
pattern Cons :: IsSequence seq => Element seq -> seq -> seq
pattern Cons x xs <- (uncons -> Just (x, xs)) where
Cons = cons

#if MIN_VERSION_time(1,10,0)
parseTime
Expand Down
Loading