Related to: CoSemigroup and random generator transformers? - r/haskell
class CoSemigroup a where
comult :: a -> (a,a)
comult a = (projL a, projR a)
projL :: a -> a
projL = fst . comult
| -- This exists so that I haven't made a silly mistake, | |
| -- like typo or type mismatch of expressions surrounding equal sign. | |
| {-# LANGUAGE TypeOperators #-} | |
| module Check where | |
| import Prelude hiding (zip) | |
| import Data.These | |
| import Data.Zip | |
| import Data.Bifunctor |
| -- https://www.reddit.com/r/haskell/comments/z9eyu7/monthly_hask_anything_december_2022/izpv48z/ | |
| {-# language | |
| DeriveGeneric, | |
| DerivingVia, | |
| StandaloneDeriving, | |
| TypeOperators, | |
| FlexibleInstances, | |
| ScopedTypeVariables, | |
| TypeFamilies, | |
| TypeApplications, |
| module Foldl(foldl', foldl'Copied, foldl'CopiedMono, foldl'Recursion, foldl'Recursion2) where | |
| import Data.List (foldl') | |
| import GHC.Exts (oneShot) | |
| foldl'Copied :: Foldable t => (b -> a -> b) -> b -> t a -> b | |
| {-# INLINE foldl'Copied #-} | |
| foldl'Copied f z0 = \ xs -> foldr (\ (x::a) (k::b->b) -> oneShot (\ (z::b) -> z `seq` k (f z x))) (id::b->b) xs z0 | |
| foldl'CopiedMono :: (b -> a -> b) -> b -> [a] -> b |
| {-# LANGUAGE GADTs, DataKinds #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| module Main where | |
| import Data.Typeable (cast) | |
| import Type.Reflection |
Related to: CoSemigroup and random generator transformers? - r/haskell
class CoSemigroup a where
comult :: a -> (a,a)
comult a = (projL a, projR a)
projL :: a -> a
projL = fst . comult
tはどんな関手 |
とる | 返す | ||
|---|---|---|---|---|
| Traversable t | traverse | Star f a b |
Star f (t a) (t b) |
|
| PTraversable t | ptraverse | p a b |
p (t a) (t b) |
|
| Bitraversable t | bitraverse | Star2 f a₁ a₂ b₁ b₂ |
Star f (t a₁ a₂) (t b₁ b₂) |
|
| Rank2.Traversable t | Rank2.traverse | IxStar f a b |
Star f (t a) (t b) |
|
| traverseBia | $\mathrm |
Collection of "would-be co-Applicative" formulations
This article explains Divisible as a co-Applicative
| $ ls | |
| foobar.txt hoge.txt piyo.txt | |
| $ git status | |
| ブランチ main | |
| Changes not staged for commit: | |
| (use "git add <file>..." to update what will be committed) | |
| (use "git restore <file>..." to discard changes in working directory) | |
| modified: hoge.txt | |
| 追跡されていないファイル: |
| #!/usr/bin/env cabal | |
| {- cabal: | |
| build-depends: base, vector, process | |
| -} | |
| module Main where | |
| {- | |
| 検算 |
| {-# LANGUAGE | |
| GADTs, | |
| RankNTypes, | |
| PolyKinds, | |
| DataKinds, | |
| ScopedTypeVariables, | |
| StandaloneKindSignatures | |
| #-} | |
| module DiscreteCategory where |