packages feed

higher-order-freer-monad (empty) → 0.1.0.0

raw patch · 7 files changed

+162/−0 lines, 7 filesdep +basedep +freer-base-classesdep +ftcqueuesetup-changed

Dependencies added: base, freer-base-classes, ftcqueue, higher-order-freer-monad

Files

+ CHANGELOG.md view
@@ -0,0 +1,11 @@+# Changelog for `higher-order-freer-monad`++All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),+and this project adheres to the+[Haskell Package Versioning Policy](https://pvp.haskell.org/).++## Unreleased++## 0.1.0.0 - YYYY-MM-DD
+ LICENSE view
@@ -0,0 +1,26 @@+Copyright 2025 Yoshikuni Jujo++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1.  Redistributions of source code must retain the above copyright notice, this+    list of conditions and the following disclaimer.++2.  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.++3.  Neither the name of the copyright holder nor the names of its 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 HOLDER 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.
+ README.md view
@@ -0,0 +1,7 @@+# higher-order-freer-monad++This package used by package yaftee.++```Haskell+type Eff effs = Data.HigherFunctor.H (Control.HigherOpenUnion.U effs)+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ higher-order-freer-monad.cabal view
@@ -0,0 +1,60 @@+cabal-version: 2.2++-- This file has been generated from package.yaml by hpack version 0.38.1.+--+-- see: https://github.com/sol/hpack++name:           higher-order-freer-monad+version:        0.1.0.0+synopsis:       This package is used by package yaftee+description:    Please see the README on GitHub at <https://github.com/YoshikuniJujo/higher-order-freer-monad#readme>+category:       Control+homepage:       https://github.com/YoshikuniJujo/higher-order-freer-monad#readme+bug-reports:    https://github.com/YoshikuniJujo/higher-order-freer-monad/issues+author:         Yoshikuni Jujo+maintainer:     yoshikuni.jujo@gmail.com+copyright:      (c) 2025 Yoshikuni Jujo+license:        BSD-3-Clause+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+extra-doc-files:+    CHANGELOG.md++source-repository head+  type: git+  location: https://github.com/YoshikuniJujo/higher-order-freer-monad++library+  exposed-modules:+      Control.Monad.HigherFreer+  other-modules:+      Paths_higher_order_freer_monad+  autogen-modules:+      Paths_higher_order_freer_monad+  hs-source-dirs:+      src+  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints+  build-depends:+      base >=4.7 && <5+    , freer-base-classes ==0.1.*+    , ftcqueue ==0.1.*+  default-language: Haskell2010++test-suite higher-order-freer-monad-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_higher_order_freer_monad+  autogen-modules:+      Paths_higher_order_freer_monad+  hs-source-dirs:+      test+  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      base >=4.7 && <5+    , freer-base-classes ==0.1.*+    , ftcqueue ==0.1.*+    , higher-order-freer-monad+  default-language: Haskell2010
+ src/Control/Monad/HigherFreer.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE ImportQualifiedPost #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}++module Control.Monad.HigherFreer (H(..), ($), (.)) where++import Prelude hiding (($), (.))+import Prelude qualified as P+import Control.Applicative+import Control.Monad+import Control.Monad.Freer.NonDetable qualified as NonDetable+import Control.Monad.Freer.Failable qualified as Failable+import Data.FTCQueue qualified as Q+import Data.Bool++data H h i o a = Pure a | forall x . h (H h) i o x :>>= Q.Q (H h i o) x a++infixl 1 :>>=++instance Functor (H h i o) where+	fmap f = \case+		Pure x -> Pure P.$ f x; hx :>>= q -> hx :>>= q Q.|> Pure P.. f++instance Applicative (H h i o) where+	pure = Pure+	Pure f <*> m = f <$> m; (hx :>>= q) <*> m = hx :>>= q Q.|> (<$> m)++instance Monad (H h i o) where+	Pure x >>= f = f x; hx :>>= q >>= f = hx :>>= q Q.|> f++infixr 0 $++($) :: Q.Q (H h i o) a b -> a -> H h i o b+q $ x = case Q.viewl q of+	Q.One f -> f x+	f Q.:| r -> case f x of Pure y -> r $ y; hx :>>= q' -> hx :>>= q' Q.>< r++infixr 9 .++(.) :: forall a h i o b h' i' o' c .+	(H h i o b -> H h' i' o' c) -> Q.Q (H h i o) a b -> a -> H h' i' o' c+(.) = (P.. ($)) P.. (P..)++instance NonDetable.N (h (H h) i o) => Alternative (H h i o) where+	empty = NonDetable.mz :>>= Q.singleton Pure+	m1 <|> m2 = NonDetable.mp :>>= Q.singleton (bool m1 m2)++instance NonDetable.N (h (H h) i o) => MonadPlus (H h i o) where+	mzero = empty; mplus = (<|>)++instance Failable.F (h (H h) i o) => MonadFail (H h i o) where+	fail msg = Failable.fail msg :>>= Q.singleton Pure
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"