This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
newtype Heftia h a = Heftia {unHeftia :: FreerTreeT (h (Heftia h)) Identity a} | |
deriving (Functor, Applicative, Monad) | |
to :: HFunctor h => Heftia h a -> HeftiaTree h a | |
to (Heftia (FreerTreeT (FreeT (Identity f)))) = | |
HeftiaTreeT . HeftyT . Identity $ case f of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE UndecidableInstances #-} | |
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
module Control.HyperFree where | |
import Control.Applicative (Alternative) | |
import Control.Monad (MonadPlus) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE UndecidableInstances #-} | |
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
module Control.HyperFree where | |
import Control.Applicative (Alternative) | |
import Control.Monad (MonadPlus) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
newtype | |
HyperFree | |
(f :: InsClass -> Type -> Type) | |
(e :: ASigClass) | |
(a :: Type) = HyperFree | |
{unHyperFree :: (f :# GetSigClass e) a} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
infixr 5 #+#, #+, +#, :+: | |
newtype | |
(:+:) | |
(e1 :: SigClass) | |
(e2 :: SigClass) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
sumH :: (e1 h e a -> r) -> (e2 h e a -> r) -> (e1 :+: e2) h e a -> r | |
sumH f g = caseSum f g . unSumH | |
{-# INLINE sumH #-} | |
swapSumH :: (e1 :+: e2) h e ~> (e2 :+: e1) h e | |
swapSumH = SumH . sumH R1 L1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
class HFunctorT (e :: SigClass) where | |
type HFTDict e :: ((Type -> Type) -> Type -> Type) -> Type | |
type HFTDict _ = (:~:) IdentityT | |
hfmapT :: (forall t. HFTDict e t -> t f ~> t g) -> e f ~> e g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE ImpredicativeTypes #-} | |
{-# LANGUAGE PartialTypeSignatures #-} | |
{-# LANGUAGE QuantifiedConstraints #-} | |
{-# LANGUAGE TypeFamilyDependencies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE UndecidableSuperClasses #-} | |
-- This Source Code Form is subject to the terms of the Mozilla Public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
-- This Source Code Form is subject to the terms of the Mozilla Public | |
-- License, v. 2.0. If a copy of the MPL was not distributed with this | |
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
module Control.Hefty where | |
import Control.Applicative (Alternative) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
括弧が見づらいので()に加えて[],{}も括弧の代わりに使います | |
つまり[]はいわゆるHaskellのリストの型ではないので注意してください | |
まず前提として | |
Hefty h a = Return a | Op [h (Hefty h) (Hefty h a)] | |
Coyoneda f a = ∀b. (b -> a, f b) | |
です | |
(cf. https://twitter.com/ymdfield/status/1743235218847465546) | |
ここでCoyonedaの高階版を定義します |
OlderNewer