Movatterモバイル変換


[0]ホーム

URL:


{-# LANGUAGE Safe #-}{-# LANGUAGE TypeOperators #-}------------------------------------------------------------------------------- |-- Module      :  Control.Monad.Zip-- Copyright   :  (c) Nils Schweinsberg 2011,--                (c) George Giorgidze 2011--                (c) University Tuebingen 2011-- License     :  BSD-style (see the file libraries/base/LICENSE)-- Maintainer  :  libraries@haskell.org-- Stability   :  experimental-- Portability :  portable---- Monadic zipping (used for monad comprehensions)-------------------------------------------------------------------------------moduleControl.Monad.ZipwhereimportControl.Monad(liftM,liftM2)importData.Functor.IdentityimportData.MonoidimportData.Ord(Down(..))importData.ProxyimportqualifiedData.List.NonEmptyasNEimportGHC.Generics-- | `MonadZip` type class. Minimal definition: `mzip` or `mzipWith`---- Instances should satisfy the laws:---- * Naturality :----   > liftM (f *** g) (mzip ma mb) = mzip (liftM f ma) (liftM g mb)---- * Information Preservation:----   > liftM (const ()) ma = liftM (const ()) mb--   > ==>--   > munzip (mzip ma mb) = (ma, mb)--classMonadm=>MonadZipmwhere{-# MINIMALmzip|mzipWith#-}mzip::ma->mb->m(a,b)mzip=mzipWith(,)mzipWith::(a->b->c)->ma->mb->mcmzipWithfmamb=liftM(uncurryf)(mzipmamb)munzip::m(a,b)->(ma,mb)munzipmab=(liftMfstmab,liftMsndmab)-- munzip is a member of the class because sometimes-- you can implement it more efficiently than the-- above default code.  See Trac #4370 comment by giorgidze-- | @since 4.3.1.0instanceMonadZip[]wheremzip=zipmzipWith=zipWithmunzip=unzip-- | @since 4.9.0.0instanceMonadZipNE.NonEmptywheremzip=NE.zipmzipWith=NE.zipWithmunzip=NE.unzip-- | @since 4.8.0.0instanceMonadZipIdentitywheremzipWith=liftM2munzip(Identity(a,b))=(Identitya,Identityb)-- | @since 4.8.0.0instanceMonadZipDualwhere-- Cannot use coerce, it's unsafemzipWith=liftM2-- | @since 4.8.0.0instanceMonadZipSumwheremzipWith=liftM2-- | @since 4.8.0.0instanceMonadZipProductwheremzipWith=liftM2-- | @since 4.8.0.0instanceMonadZipMaybewheremzipWith=liftM2-- | @since 4.8.0.0instanceMonadZipFirstwheremzipWith=liftM2-- | @since 4.8.0.0instanceMonadZipLastwheremzipWith=liftM2-- | @since 4.8.0.0instanceMonadZipf=>MonadZip(Altf)wheremzipWithf(Altma)(Altmb)=Alt(mzipWithfmamb)-- | @since 4.9.0.0instanceMonadZipProxywheremzipWith___=Proxy-- Instances for GHC.Generics-- | @since 4.9.0.0instanceMonadZipU1wheremzipWith___=U1-- | @since 4.9.0.0instanceMonadZipPar1wheremzipWith=liftM2-- | @since 4.9.0.0instanceMonadZipf=>MonadZip(Rec1f)wheremzipWithf(Rec1fa)(Rec1fb)=Rec1(mzipWithffafb)-- | @since 4.9.0.0instanceMonadZipf=>MonadZip(M1icf)wheremzipWithf(M1fa)(M1fb)=M1(mzipWithffafb)-- | @since 4.9.0.0instance(MonadZipf,MonadZipg)=>MonadZip(f:*:g)wheremzipWithf(x1:*:y1)(x2:*:y2)=mzipWithfx1x2:*:mzipWithfy1y2-- instances for Data.Ord-- | @since 4.12.0.0instanceMonadZipDownwheremzipWith=liftM2

[8]ページ先頭

©2009-2025 Movatter.jp