Hello community,
here is the log from the commit of package ghc-monad-skeleton for
openSUSE:Factory checked in at 2017-04-14 13:38:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-monad-skeleton (Old)
and /work/SRC/openSUSE:Factory/.ghc-monad-skeleton.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-monad-skeleton"
Fri Apr 14 13:38:32 2017 rev:2 rq:485146 version:0.1.3.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-monad-skeleton/ghc-monad-skeleton.changes
2016-10-22 13:12:45.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-monad-skeleton.new/ghc-monad-skeleton.changes
2017-04-14 13:38:33.004361556 +0200
@@ -1,0 +2,10 @@
+Mon Mar 27 12:37:17 UTC 2017 - [email protected]
+
+- Update to version 0.1.3.2 with cabal2obs.
+
+-------------------------------------------------------------------
+Tue Mar 7 11:19:25 UTC 2017 - [email protected]
+
+- Update to version 0.1.3 with cabal2obs.
+
+-------------------------------------------------------------------
Old:
----
monad-skeleton-0.1.2.2.tar.gz
New:
----
monad-skeleton-0.1.3.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-monad-skeleton.spec ++++++
--- /var/tmp/diff_new_pack.NMfpZ3/_old 2017-04-14 13:38:33.976224203 +0200
+++ /var/tmp/diff_new_pack.NMfpZ3/_new 2017-04-14 13:38:33.976224203 +0200
@@ -1,7 +1,7 @@
#
# spec file for package ghc-monad-skeleton
#
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,22 +18,19 @@
%global pkg_name monad-skeleton
Name: ghc-%{pkg_name}
-Version: 0.1.2.2
+Version: 0.1.3.2
Release: 0
-Summary: An undead monad
+Summary: Monads of program skeleta
License: BSD-3-Clause
-Group: System/Libraries
+Group: Development/Languages/Other
Url: https://hackage.haskell.org/package/%{pkg_name}
Source0:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
BuildRequires: ghc-Cabal-devel
-# Begin cabal-rpm deps:
-BuildRequires: ghc-containers-devel
BuildRequires: ghc-rpm-macros
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-# End cabal-rpm deps
%description
-A simple operational monad based on Reflection without Remorse.
+Fast operational monad library.
%package devel
Summary: Haskell %{pkg_name} library development files
@@ -49,15 +46,12 @@
%prep
%setup -q -n %{pkg_name}-%{version}
-
%build
%ghc_lib_build
-
%install
%ghc_lib_install
-
%post devel
%ghc_pkg_recache
@@ -70,5 +64,6 @@
%files devel -f %{name}-devel.files
%defattr(-,root,root,-)
+%doc README.md
%changelog
++++++ monad-skeleton-0.1.2.2.tar.gz -> monad-skeleton-0.1.3.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/.gitignore
new/monad-skeleton-0.1.3.2/.gitignore
--- old/monad-skeleton-0.1.2.2/.gitignore 1970-01-01 01:00:00.000000000
+0100
+++ new/monad-skeleton-0.1.3.2/.gitignore 2017-03-15 09:28:20.000000000
+0100
@@ -0,0 +1,59 @@
+dist
+cabal-dev
+*.o
+*.hi
+*.chi
+*.chs.h
+.virtualenv
+.hsenv
+.cabal-sandbox/
+cabal.sandbox.config
+cabal.config
+.stack-work
+
+# =========================
+# Operating System Files
+# =========================
+
+# OSX
+# =========================
+
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Thumbnails
+._*
+
+# Files that might appear on external disk
+.Spotlight-V100
+.Trashes
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# Windows
+# =========================
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/.travis.yml
new/monad-skeleton-0.1.3.2/.travis.yml
--- old/monad-skeleton-0.1.2.2/.travis.yml 1970-01-01 01:00:00.000000000
+0100
+++ new/monad-skeleton-0.1.3.2/.travis.yml 2017-03-16 08:23:19.000000000
+0100
@@ -0,0 +1,85 @@
+# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
+language: c
+sudo: false
+
+cache:
+ directories:
+ - $HOME/.cabsnap
+ - $HOME/.cabal/packages
+
+before_cache:
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
+
+matrix:
+ include:
+ - env: CABALVER=1.18 GHCVER=7.8.4
+ compiler: ": #GHC 7.8.4"
+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources:
[hvr-ghc]}}
+ - env: CABALVER=1.22 GHCVER=7.10.3
+ compiler: ": #GHC 7.10.3"
+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources:
[hvr-ghc]}}
+ - env: CABALVER=1.24 GHCVER=8.0.2
+ compiler: ": #GHC 8.0.2"
+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2], sources:
[hvr-ghc]}}
+ - env: CABALVER=head GHCVER=head
+ addons: {apt: {packages: [cabal-install-head,ghc-head], sources:
[hvr-ghc]}}
+ allow_failures:
+ - env: CABALVER=head GHCVER=head
+before_install:
+ - unset CC
+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
+
+install:
+ - cabal --version
+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null ||
echo '?')]"
+ - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
+ then
+ zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
+ $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
+ fi
+ - travis_retry cabal update -v
+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
+ - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry
-v > installplan.txt
+ - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
+
+# check whether current requested install-plan matches cached package-db
snapshot
+ - if diff -u $HOME/.cabsnap/installplan.txt installplan.txt;
+ then
+ echo "cabal build-cache HIT";
+ rm -rfv .ghc;
+ cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
+ cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin
$HOME/.cabal/;
+ else
+ echo "cabal build-cache MISS";
+ rm -rf $HOME/.cabsnap;
+ mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
+ cabal install --only-dependencies --enable-tests --enable-benchmarks;
+ fi
+
+# snapshot package-db on cache miss
+ - if [ ! -d $HOME/.cabsnap ];
+ then
+ echo "snapshotting package-db to build-cache";
+ mkdir $HOME/.cabsnap;
+ cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
+ cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin
installplan.txt $HOME/.cabsnap/;
+ fi
+
+# Here starts the actual work to be performed for the package under test;
+# any command which exits with a non-zero exit code causes the build to fail.
+script:
+ - if [ -f configure.ac ]; then autoreconf -i; fi
+ - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides
useful information for debugging
+ - cabal build # this builds all libraries and executables (including
tests/benchmarks)
+ - cabal test
+ - cabal check
+ - cabal sdist # tests that a source-distribution can be generated
+
+# Check that the resulting source distribution can be built & installed.
+# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
+# `cabal install --force-reinstalls dist/*-*.tar.gz`
+ - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
+
+# EOF
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/LICENSE
new/monad-skeleton-0.1.3.2/LICENSE
--- old/monad-skeleton-0.1.2.2/LICENSE 2015-03-27 08:06:01.000000000 +0100
+++ new/monad-skeleton-0.1.3.2/LICENSE 2017-03-15 09:28:20.000000000 +0100
@@ -1,30 +1,30 @@
-Copyright (c) 2015, Fumiaki Kinoshita
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Fumiaki Kinoshita nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Copyright (c) 2015, Fumiaki Kinoshita
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Fumiaki Kinoshita nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/README.md
new/monad-skeleton-0.1.3.2/README.md
--- old/monad-skeleton-0.1.2.2/README.md 1970-01-01 01:00:00.000000000
+0100
+++ new/monad-skeleton-0.1.3.2/README.md 2017-03-16 06:48:35.000000000
+0100
@@ -0,0 +1,41 @@
+monad-skeleton
+======================
+
+[](https://travis-ci.org/fumieval/monad-skeleton)
+[](https://hackage.haskell.org/package/monad-skeleton)
+
+This package provides `Skeleton`, an operational monad. The internal encoding
+gives O(1) bind and monadic reflection.
+
+`Skeleton` promotes unit instructions to a monad. It is isomorphic to
+`MonadView (Skeleton t)`:
+
+```haskell
+data MonadView t m x where
+ Return :: a -> MonadView t m a
+ (:>>=) :: !(t a) -> (a -> m b) -> MonadView t m b
+
+boned :: MonadView t (Skeleton t) a -> Skeleton t a
+debone :: Skeleton t a -> MonadView t (Skeleton t) a
+```
+
+GADTs are handy to define instructions:
+
+```haskell
+data Interaction x where
+ Get :: Interacton String
+ Put :: String -> Interaction ()
+
+echo :: Skeleton Interaction ()
+echo = bone Get >>= bone . Put
+```
+
+Use `debone` to interpret a computation.
+
+```haskell
+interpret :: Skeleton Interaction a -> IO a
+interpret m = case debone m of
+ Return a -> return a
+ Get :>>= k -> getLine >>= interpret . k
+ Put s :>>= k -> putStrLn s >>= interpret . k
+```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/Setup.hs
new/monad-skeleton-0.1.3.2/Setup.hs
--- old/monad-skeleton-0.1.2.2/Setup.hs 2015-03-27 08:06:01.000000000 +0100
+++ new/monad-skeleton-0.1.3.2/Setup.hs 2017-03-15 09:28:20.000000000 +0100
@@ -1,2 +1,2 @@
-import Distribution.Simple
-main = defaultMain
+import Distribution.Simple
+main = defaultMain
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/monad-skeleton.cabal
new/monad-skeleton-0.1.3.2/monad-skeleton.cabal
--- old/monad-skeleton-0.1.2.2/monad-skeleton.cabal 2015-12-06
06:48:43.000000000 +0100
+++ new/monad-skeleton-0.1.3.2/monad-skeleton.cabal 2017-03-16
08:21:29.000000000 +0100
@@ -1,26 +1,32 @@
-name: monad-skeleton
-version: 0.1.2.2
-synopsis: An undead monad
-description: A simple operational monad based on Reflection without
Remorse
-homepage: https://github.com/fumieval/monad-skeleton
-bug-reports: http://github.com/fumieval/monad-skeleton/issues
-license: BSD3
-license-file: LICENSE
-author: Fumiaki Kinoshita
-maintainer: Fumiaki Kinoshita <[email protected]>
-copyright: Copyright (c) 2015 Fumiaki Kinoshita
-category: Control
-build-type: Simple
--- extra-source-files:
-cabal-version: >=1.10
-
-source-repository head
- type: git
- location: https://github.com/fumieval/monad-skeleton.git
-
-library
- exposed-modules: Control.Monad.Skeleton, Control.Monad.Skeleton.Internal
- build-depends: base == 4.*, containers, ghc-prim
- hs-source-dirs: src
- ghc-options: -Wall
- default-language: Haskell2010
+name: monad-skeleton
+version: 0.1.3.2
+synopsis: Monads of program skeleta
+description: Fast operational monad library
+homepage: https://github.com/fumieval/monad-skeleton
+bug-reports: http://github.com/fumieval/monad-skeleton/issues
+license: BSD3
+license-file: LICENSE
+author: Fumiaki Kinoshita
+maintainer: Fumiaki Kinoshita <[email protected]>
+copyright: Copyright (c) 2017 Fumiaki Kinoshita
+category: Control, Monads
+build-type: Simple
+cabal-version: >=1.10
+extra-source-files:
+ .travis.yml
+ .gitignore
+ README.md
+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
+
+source-repository head
+ type: git
+ location: https://github.com/fumieval/monad-skeleton.git
+
+library
+ exposed-modules: Control.Monad.Skeleton
+ , Control.Monad.Skeleton.Internal
+ , Control.Monad.Zombie
+ build-depends: base == 4.*
+ hs-source-dirs: src
+ ghc-options: -Wall
+ default-language: Haskell2010
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/monad-skeleton-0.1.2.2/src/Control/Monad/Skeleton/Internal.hs
new/monad-skeleton-0.1.3.2/src/Control/Monad/Skeleton/Internal.hs
--- old/monad-skeleton-0.1.2.2/src/Control/Monad/Skeleton/Internal.hs
2015-12-06 06:50:58.000000000 +0100
+++ new/monad-skeleton-0.1.3.2/src/Control/Monad/Skeleton/Internal.hs
2017-03-16 08:17:20.000000000 +0100
@@ -1,33 +1,43 @@
-{-# LANGUAGE PolyKinds, GADTs, Rank2Types #-}
-module Control.Monad.Skeleton.Internal (Cat, transCat, (|>), viewL) where
-
-import Control.Category
-
-data Cat k a b where
- Empty :: Cat k a a
- Leaf :: k a b -> Cat k a b
- Tree :: Cat k a b -> Cat k b c -> Cat k a c
-
-transCat :: (forall x y. j x y -> k x y) -> Cat j a b -> Cat k a b
-transCat f (Tree a b) = transCat f a `Tree` transCat f b
-transCat f (Leaf k) = Leaf (f k)
-transCat _ Empty = Empty
-{-# INLINE transCat #-}
-
-(|>) :: Cat k a b -> k b c -> Cat k a c
-s |> k = Tree s (Leaf k)
-{-# INLINE (|>) #-}
-
-viewL :: Cat k a b
- -> ((a ~ b) => r)
- -> (forall x. k a x -> Cat k x b -> r)
- -> r
-viewL Empty e _ = e
-viewL (Leaf k) _ r = k `r` Empty
-viewL (Tree a b) e r = viewL a (viewL b e r) $ \k t -> k `r` Tree t b
-
-instance Category (Cat k) where
- id = Empty
- {-# INLINE id #-}
- (.) = flip Tree
- {-# INLINE (.) #-}
\ No newline at end of file
+{-# LANGUAGE PolyKinds, GADTs, Rank2Types, ScopedTypeVariables, Trustworthy #-}
+module Control.Monad.Skeleton.Internal (Cat(..), transCat, (|>), viewL,
transKleisli) where
+
+import Control.Arrow
+import Control.Category
+import Unsafe.Coerce
+
+data Cat k a b where
+ Empty :: Cat k a a
+ Leaf :: k a b -> Cat k a b
+ Tree :: Cat k a b -> Cat k b c -> Cat k a c
+
+transCat :: (forall x y. j x y -> k x y) -> Cat j a b -> Cat k a b
+transCat f (Tree a b) = transCat f a `Tree` transCat f b
+transCat f (Leaf k) = Leaf (f k)
+transCat _ Empty = Empty
+{-# INLINE transCat #-}
+
+(|>) :: Cat k a b -> k b c -> Cat k a c
+s |> k = Tree s (Leaf k)
+{-# INLINE (|>) #-}
+
+viewL :: forall k a b r. Cat k a b
+ -> ((a ~ b) => r)
+ -> (forall x. k a x -> Cat k x b -> r)
+ -> r
+viewL Empty e _ = e
+viewL (Leaf k) _ r = k `r` Empty
+viewL (Tree a b) e r = go a b where
+ go :: Cat k a x -> Cat k x b -> r
+ go Empty t = viewL t e r
+ go (Leaf k) t = r k t
+ go (Tree c d) t = go c (Tree d t)
+
+instance Category (Cat k) where
+ id = Empty
+ {-# INLINE id #-}
+ (.) = flip Tree
+ {-# INLINE (.) #-}
+
+transKleisli :: (m b -> n b) -> Kleisli m a b -> Kleisli n a b
+transKleisli f = unsafeCoerce (f Prelude..)
+{-# INLINE transKleisli #-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/src/Control/Monad/Skeleton.hs
new/monad-skeleton-0.1.3.2/src/Control/Monad/Skeleton.hs
--- old/monad-skeleton-0.1.2.2/src/Control/Monad/Skeleton.hs 2015-12-06
06:50:49.000000000 +0100
+++ new/monad-skeleton-0.1.3.2/src/Control/Monad/Skeleton.hs 2017-03-16
08:17:17.000000000 +0100
@@ -1,100 +1,108 @@
-{-# LANGUAGE Trustworthy, RankNTypes, GADTs, ScopedTypeVariables #-}
-module Control.Monad.Skeleton (MonadView(..)
- , hoistMV
- , iterMV
- , Skeleton(..)
- , bone
- , debone
- , unbone
- , boned
- , hoistSkeleton
- ) where
-import Control.Arrow
-import Control.Applicative
-import Control.Monad
-import Control.Category
-import Unsafe.Coerce
-import Control.Monad.Skeleton.Internal
-import Prelude hiding (id, (.))
-
--- | Re-add a bone.
-boned :: MonadView t (Skeleton t) a -> Skeleton t a
-boned t = Skeleton (Spine t id)
-{-# INLINE boned #-}
-
--- | Pick a bone from a 'Skeleton'.
-debone :: Skeleton t a -> MonadView t (Skeleton t) a
-debone (Skeleton (Spine (Return a) s)) = viewL s (Return a) $ \(Kleisli k) c
-> case k a of
- Skeleton (Spine h t) -> debone $ Skeleton $ Spine h (c . t)
-debone (Skeleton (Spine (t :>>= k) s)) = t :>>= \a -> case k a of
- Skeleton (Spine h c) -> Skeleton (Spine h (s . c))
-
--- | Uncommon synonym for 'debone'.
-unbone :: Skeleton t a -> MonadView t (Skeleton t) a
-unbone = debone
-{-# INLINE unbone #-}
-
--- | A skeleton that has only one bone.
-bone :: t a -> Skeleton t a
-bone t = Skeleton (Spine (t :>>= return) id)
-{-# INLINABLE bone #-}
-
--- | Lift a transformation between bones into transformation between skeletons.
-hoistSkeleton :: forall s t a. (forall x. s x -> t x) -> Skeleton s a ->
Skeleton t a
-hoistSkeleton f = go where
- go :: forall x. Skeleton s x -> Skeleton t x
- go (Skeleton (Spine v c)) = Skeleton $ Spine (hoistMV f go v)
- (transCat (transKleisli go) c)
-{-# INLINE hoistSkeleton #-}
-
-data MonadView t m x where
- Return :: a -> MonadView t m a
- (:>>=) :: t a -> (a -> m b) -> MonadView t m b
-infixl 1 :>>=
-
-instance Functor m => Functor (MonadView t m) where
- fmap f (Return a) = Return (f a)
- fmap f (t :>>= k) = t :>>= fmap f . k
- {-# INLINE fmap #-}
-
-hoistMV :: (forall x. s x -> t x) -> (m a -> n a) -> MonadView s m a ->
MonadView t n a
-hoistMV _ _ (Return a) = Return a
-hoistMV f g (t :>>= k) = f t :>>= g . k
-{-# INLINE hoistMV #-}
-
-iterMV :: Monad m => (t a -> MonadView m t a) -> t a -> m a
-iterMV f = go where
- go t = case f t of
- m :>>= k -> m >>= go . k
- Return a -> return a
-{-# INLINE iterMV #-}
-
-data Spine t m a where
- Spine :: !(MonadView t m a) -> !(Cat (Kleisli m) a b) -> Spine t m b
-
--- | @'Skeleton' t@ is a monadic skeleton (operational monad) made out of 't'.
--- Skeletons can be fleshed out by getting transformed to other monads.
--- The implementation is based on
--- <http://wwwhome.cs.utwente.nl/~jankuper/fp-dag/pref.pdf Reflection without
Remorse>
--- so it provides efficient ('>>=') and 'debone', monadic reflection.
-newtype Skeleton t a = Skeleton { unSkeleton :: Spine t (Skeleton t) a }
-
-instance Functor (Skeleton t) where
- fmap = liftM
- {-# INLINE fmap #-}
-
-instance Applicative (Skeleton t) where
- pure = return
- {-# INLINE pure #-}
- (<*>) = ap
- {-# INLINE (<*>) #-}
-
-instance Monad (Skeleton t) where
- return a = Skeleton $ Spine (Return a) id
- {-# INLINE return #-}
- Skeleton (Spine t c) >>= k = Skeleton $ Spine t (c |> Kleisli k)
- {-# INLINE (>>=) #-}
-
-transKleisli :: (m b -> n b) -> Kleisli m a b -> Kleisli n a b
-transKleisli f = unsafeCoerce (f.)
-{-# INLINE transKleisli #-}
+{-# LANGUAGE BangPatterns, RankNTypes, GADTs, ScopedTypeVariables #-}
+module Control.Monad.Skeleton (MonadView(..)
+ , hoistMV
+ , iterMV
+ , Skeleton(..)
+ , bone
+ , debone
+ , unbone
+ , boned
+ , hoistSkeleton
+ -- * internal
+ , Spine(..)
+ , graftSpine
+ ) where
+import Control.Arrow
+import Control.Applicative
+import Control.Monad
+import Control.Category
+import Control.Monad.Skeleton.Internal
+import Prelude hiding (id, (.))
+
+-- | Re-add a bone.
+boned :: MonadView t (Skeleton t) a -> Skeleton t a
+boned t = Skeleton (Spine t id)
+{-# INLINE boned #-}
+
+-- | Pick a bone from a 'Skeleton'.
+debone :: Skeleton t a -> MonadView t (Skeleton t) a
+debone (Skeleton (Spine v c)) = case v of
+ Return a -> viewL c (Return a) $ \(Kleisli k) c' -> case k a of
+ Skeleton s -> debone $ Skeleton $ graftSpine c' s
+ t :>>= k -> t :>>= \a -> case k a of
+ Skeleton s -> Skeleton (graftSpine c s)
+
+-- | Uncommon synonym for 'debone'.
+unbone :: Skeleton t a -> MonadView t (Skeleton t) a
+unbone = debone
+{-# INLINE unbone #-}
+{-# DEPRECATED unbone "Use debone instead" #-}
+
+-- | A skeleton that has only one bone.
+bone :: t a -> Skeleton t a
+bone t = Skeleton (Spine (t :>>= return) id)
+{-# INLINABLE bone #-}
+
+-- | Lift a transformation between bones into transformation between skeletons.
+hoistSkeleton :: forall s t a. (forall x. s x -> t x) -> Skeleton s a ->
Skeleton t a
+hoistSkeleton f = go where
+ go :: forall x. Skeleton s x -> Skeleton t x
+ go (Skeleton (Spine v c)) = Skeleton $ Spine (hoistMV f go v)
+ (transCat (transKleisli go) c)
+{-# INLINE hoistSkeleton #-}
+
+-- | A deconstructed action
+data MonadView t m x where
+ Return :: a -> MonadView t m a
+ (:>>=) :: !(t a) -> (a -> m b) -> MonadView t m b
+infixl 1 :>>=
+
+instance Functor m => Functor (MonadView t m) where
+ fmap f (Return a) = Return (f a)
+ fmap f (t :>>= k) = t :>>= fmap f . k
+ {-# INLINE fmap #-}
+
+-- | Transform the action and the continuation.
+hoistMV :: (forall x. s x -> t x) -> (m a -> n a) -> MonadView s m a ->
MonadView t n a
+hoistMV _ _ (Return a) = Return a
+hoistMV f g (t :>>= k) = f t :>>= g . k
+{-# INLINE hoistMV #-}
+
+-- | Join 'MonadView' recursively.
+iterMV :: Monad m => (t a -> MonadView m t a) -> t a -> m a
+iterMV f = go where
+ go t = case f t of
+ m :>>= k -> m >>= go . k
+ Return a -> return a
+{-# INLINE iterMV #-}
+
+-- | The spine of skeleta.
+data Spine t m a where
+ Spine :: MonadView t m a -> Cat (Kleisli m) a b -> Spine t m b
+
+-- | Extend a spine.
+graftSpine :: Cat (Kleisli m) a b -> Spine t m a -> Spine t m b
+graftSpine c (Spine v d) = Spine v (c . d)
+{-# INLINE graftSpine #-}
+
+-- | @'Skeleton' t@ is a monadic skeleton (operational monad) made out of 't'.
+-- Skeletons can be fleshed out by getting transformed to other monads.
+-- It provides O(1) ('>>=') and 'debone', the monadic reflection.
+newtype Skeleton t a = Skeleton { unSkeleton :: Spine t (Skeleton t) a }
+
+instance Functor (Skeleton t) where
+ fmap = liftM
+ {-# INLINE fmap #-}
+
+instance Applicative (Skeleton t) where
+ pure = return
+ {-# INLINE pure #-}
+ (<*>) = ap
+ {-# INLINE (<*>) #-}
+ (*>) = (>>)
+ {-# INLINE (*>) #-}
+ a <* b = a >>= \x -> b >> return x
+
+instance Monad (Skeleton t) where
+ return a = Skeleton $ Spine (Return a) id
+ Skeleton (Spine t c) >>= k = Skeleton $ Spine t (c |> Kleisli k)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/monad-skeleton-0.1.2.2/src/Control/Monad/Zombie.hs
new/monad-skeleton-0.1.3.2/src/Control/Monad/Zombie.hs
--- old/monad-skeleton-0.1.2.2/src/Control/Monad/Zombie.hs 1970-01-01
01:00:00.000000000 +0100
+++ new/monad-skeleton-0.1.3.2/src/Control/Monad/Zombie.hs 2017-03-16
08:18:14.000000000 +0100
@@ -0,0 +1,60 @@
+{-# LANGUAGE Rank2Types, ScopedTypeVariables #-}
+module Control.Monad.Zombie where
+import Control.Applicative
+import Control.Arrow
+import Control.Category
+import Control.Monad
+import Control.Monad.Skeleton
+import Control.Monad.Skeleton.Internal
+import Prelude hiding (id, (.))
+
+-- | 'Zombie' is a variant of 'Skeleton' which has an 'Alternative' instance.
+newtype Zombie t a = Zombie { unZombie :: [Spine t (Zombie t) a] }
+
+instance Functor (Zombie t) where
+ fmap = liftM
+
+instance Applicative (Zombie t) where
+ pure = return
+ (<*>) = ap
+ (*>) = (>>)
+
+instance Alternative (Zombie t) where
+ empty = Zombie []
+ Zombie xs <|> Zombie ys = Zombie (xs ++ ys)
+
+instance Monad (Zombie t) where
+ return a = Zombie [Spine (Return a) id]
+ Zombie xs >>= k = Zombie $ map (graftSpine $ Leaf $ Kleisli k) xs
+
+instance MonadPlus (Zombie t) where
+ mzero = empty
+ mplus = (<|>)
+
+-- | Lift a unit action
+liftZ :: t a -> Zombie t a
+liftZ t = embalm (t :>>= return)
+{-# INLINE liftZ #-}
+
+-- | Turn a decomposed form into a composed form.
+embalm :: MonadView t (Zombie t) a -> Zombie t a
+embalm t = Zombie [Spine t id]
+{-# INLINE embalm #-}
+
+-- | Decompose a zombie as a list of possibilities.
+disembalm :: Zombie t a -> [MonadView t (Zombie t) a]
+disembalm (Zombie ss) = do
+ Spine v c <- ss
+ case v of
+ Return a -> viewL c [Return a] $ \(Kleisli k) c' -> case k a of
+ Zombie ss' -> disembalm $ Zombie $ map (graftSpine c') ss'
+ t :>>= k -> return $ t :>>= \a -> case k a of
+ Zombie ss' -> Zombie $ map (graftSpine c) ss'
+
+-- | Like 'hoistSkeleton'
+hoistZombie :: forall s t a. (forall x. s x -> t x) -> Zombie s a -> Zombie t a
+hoistZombie f = go where
+ go :: forall x. Zombie s x -> Zombie t x
+ go (Zombie ss) = Zombie [Spine (hoistMV f go v) (transCat (transKleisli go)
c)
+ | Spine v c <- ss]
+{-# INLINE hoistZombie #-}