packages feed

fcf-containers 0.6.0 → 0.7.0

raw patch · 11 files changed

+477/−43 lines, 11 filesdep +ghc-primdep +mtlPVP ok

version bump matches the API change (PVP)

Dependencies added: ghc-prim, mtl

API changes (from Hackage documentation)

+ Fcf.Control.Monad: data (>>) :: m a -> m b -> Exp (m b)
+ Fcf.Control.Monad: data Cons_f :: (a -> Exp (f b)) -> a -> f [b] -> Exp (f [b])
+ Fcf.Control.Monad: data ForM :: t a -> (a -> Exp (m b)) -> Exp (m (t b))
+ Fcf.Control.Monad: data Id :: a -> Exp a
+ Fcf.Control.Monad: data LiftA2 :: (a -> b -> Exp c) -> f a -> f b -> Exp (f c)
+ Fcf.Control.Monad: data LiftA2_ :: (a -> b -> Exp c) -> a -> f b -> Exp (f c)
+ Fcf.Control.Monad: data MapM :: (a -> Exp (m b)) -> t a -> Exp (m (t b))
+ Fcf.Control.Monad: data Plus1 :: Nat -> Exp Nat
+ Fcf.Control.Monad: data Plus2 :: Nat -> Exp Nat
+ Fcf.Control.Monad: data Plus2M :: Nat -> Exp [Nat]
+ Fcf.Control.Monad: data PureXPlusY :: Nat -> Nat -> Exp [Nat]
+ Fcf.Control.Monad: data Return :: a -> Exp (m a)
+ Fcf.Control.Monad: data Sequence :: t (f a) -> Exp (f (t a))
+ Fcf.Control.Monad: data Star_ :: (a -> Exp b) -> f a -> Exp (f b)
+ Fcf.Control.Monad: data Traverse :: (a -> Exp (f b)) -> t a -> Exp (f (t b))
+ Fcf.Control.Monad: data XPlusYs :: Nat -> [Nat] -> Exp [Nat]
+ Fcf.Control.Monad: data XsPlusYsMonadic :: [Nat] -> [Nat] -> Exp [Nat]
+ Fcf.Data.Text: data FromSymbolList :: [Symbol] -> Exp Text
+ Fcf.Data.Text: data ToSymbolList :: Text -> Exp [Symbol]
+ Fcf.Data.Tree: data StarTx :: Tree a -> Tree (a -> Exp b) -> Exp (Tree b)
+ Fcf.Data.Tree: type ExT1r = 'Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]]
+ Fcf.Data.Tree: type ExTr2 = 'Node ('Just 1) '[ 'Node ('Just 2) '[ 'Node ('Just 3) '[ 'Node ('Just 4) '[]]], 'Node ('Just 5) '[ 'Node ('Just 6) '[]]]

Files

CHANGELOG.md view
@@ -1,4 +1,24 @@+++# 0.7.0++20220424++ - Add preliminary support for Applicative and Monadic computations+ - Small whitespace fixes+ - Added dependency for mtl (to get Identity)+ - Add new compiler versions for tests and drop some old+ - Start referring to cabal version 3.0++# 0.6.1++20210130++Start using the github actions and remove travis CI.+ # 0.6.0++20210130   - use symbol as text representation (we can split predefined char-sets, as shown    by the Csongor at https://kcsongor.github.io/symbol-parsing-haskell/ see also
default.nix view
@@ -1,5 +1,8 @@ { -  # compiler ? "ghc881" +  # compiler ? "ghc884" +  # compiler ? "ghc8107"+  # compiler ? "ghc902"+  # compiler ? "ghc922" } : let   config = {@@ -16,11 +19,11 @@           # });           first-class-families = self.callCabal2nix "first-class-families"            #   ~/gito/first-class-families {}; -            (pkgs.fetchFromGitHub { # 0.8+            (pkgs.fetchFromGitHub { # 0.8.0.1               owner  = "Lysxia";               repo   = "first-class-families";-              rev    = "4a0bf3ea9c125bb4009b61ce70b1a5339b7b2072";-              sha256 = "14387mpfvds226iynkpay3aaqamvxznxjsmg2qcwdxafdvxmyq9z";+              rev    = "d4780864ed9b11343b7b26050e39b2048a8e61f6";+              sha256 = "1iw0dryz66z4k9lsj1kayf17xs38i8bdk9aqi2qz49vcbhnfw8pd";             }) {};             # something for the next version?             #  rev    = "9fe4ce36cf1cd4b0f5af59c923c15b9085c48cd6";@@ -47,7 +50,8 @@   adjust-for-ghc = drv: {     executableSystemDepends = [       hpkgs.ghcid-      hpkgs.ghcide+      # hpkgs.ghcide+      hpkgs.haskell-language-server       hpkgs.cabal-install     ];     buildDepends = [
fcf-containers.cabal view
@@ -1,3 +1,4 @@+Cabal-version:       3.0 Name:                fcf-containers Synopsis:            Data structures and algorithms for first-class-families Description:@@ -6,22 +7,22 @@     contents of containers-package and show how these can be used. Everything is     based on the ideas given in the first-class-families -package. Homepage:            https://github.com/gspia/fcf-containers-Version:             0.6.0+Version:             0.7.0 Build-type:          Simple Author:              gspia Maintainer:          iahogsp@gmail.com-License:             BSD3+License:             BSD-3-Clause License-file:        LICENSE Category:            Other Copyright:           gspia (c) 2020- Extra-source-files:  README.md, TODO.md, CHANGELOG.md, default.nix, shell.nix-Cabal-version:       1.24-Tested-With:         GHC ==8.10.3 || ==8.8.4 || ==8.6.5 || ==8.4.4+Tested-With:         GHC ==9.2.2 || ==9.0.2 || ==8.10.7 || ==8.8.4   library   hs-source-dirs:    src-  exposed-modules:   Fcf.Data.MapC+  exposed-modules:   Fcf.Control.Monad+                   , Fcf.Data.MapC                    , Fcf.Data.Bitree                    , Fcf.Data.NatMap                    , Fcf.Data.Set@@ -37,6 +38,8 @@                    , Fcf.Alg.Tree   build-depends:     base >= 4.9 && < 4.18                    , first-class-families >= 0.8 && < 0.9+                   , ghc-prim+                   , mtl   ghc-options:      -Wall   default-language:  Haskell2010   -- ghc-options:@@ -93,9 +96,10 @@   if impl(ghc >= 8.6)     build-depends:       base+      , doctest       , first-class-families       , fcf-containers-      , doctest+      , ghc-prim       , Glob   else     buildable: False
src/Fcf/Alg/List.hs view
@@ -57,7 +57,7 @@  -------------------------------------------------------------------------------- --- | ListToFix can be used to turn a norma type-level list into the base+-- | ListToFix can be used to turn a normal type-level list into the base -- functor type ListF, to be used with e.g. Cata. For examples in use, see -- 'LenAlg' and 'SumAlg'. --@@ -172,7 +172,7 @@ type instance Eval (EvensAlg 'NilF) = '[] type instance Eval (EvensAlg ('ConsF _ rst )) = Eval (EvensStrip =<< Strip rst) --- | This picks up the elements on even positions on a list and is an +-- | This picks up the elements on even positions on a list and is an -- example on how to use Histo. This example is -- from Tim Williams, Recursion Schemes by example. --
src/Fcf/Alg/Other.hs view
@@ -32,16 +32,17 @@ -- For the doctests:  -- $setup+-- >>> import           GHC.Types  --------------------------------------------------------------------------------  -- | Helper. ----- === __Evample__+-- === __Example__ -- -- >>> :kind! Eval (PairMaybeToMaybePair '( 'Just "txt", 'Just 1)) -- Eval (PairMaybeToMaybePair '( 'Just "txt", 'Just 1)) :: Maybe---                                                           (GHC.Types.Symbol, GHC.Types.Nat)+--                                                           (Symbol, Nat) -- = 'Just '("txt", 1) data PairMaybeToMaybePair :: (Maybe a, Maybe b) -> Exp (Maybe (a,b)) type instance Eval (PairMaybeToMaybePair '( 'Nothing, _)) = 'Nothing@@ -51,10 +52,10 @@  -- | Id function. ----- === __Evample__+-- === __Example__ -- -- >>> :kind! Eval (Id "id")--- Eval (Id "id") :: GHC.Types.Symbol+-- Eval (Id "id") :: Symbol -- = "id" data Id :: a -> Exp a type instance Eval (Id a) = a
src/Fcf/Alg/Sort.hs view
@@ -105,7 +105,7 @@  -- | Qsort - give the comparison function @a -> a -> Exp Bool@ comparing your  -- list elements and then Qsort will order the list.--- +-- -- __Example__ -- -- >>> :kind! Eval (Qsort (N.<) '[5,3,1,9,4,6,3])@@ -120,7 +120,7 @@  -- Helper ----- We use the Flip version so that using <-comparison will give an inreasing +-- We use the Flip version so that using <-comparison will give an inreasing -- Nat-list. Sorting would work without PartCmp. data PartCmp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a]  type instance Eval (PartCmp cmp coalg) = Eval (PartHlp (Flip cmp) coalg)
+ src/Fcf/Control/Monad.hs view
@@ -0,0 +1,359 @@+{-# LANGUAGE DataKinds              #-}+{-# LANGUAGE PolyKinds              #-}+{-# LANGUAGE RankNTypes             #-}+{-# LANGUAGE TypeFamilies           #-}+{-# LANGUAGE TypeInType             #-}+{-# LANGUAGE TypeOperators          #-}+{-# LANGUAGE UndecidableInstances   #-}+{-# OPTIONS_GHC -Wall                       #-}+{-# OPTIONS_GHC -Werror=incomplete-patterns #-}++{-|+Module      : Fcf.Control.Monad+Description : Monad definitions+Copyright   : (c) gspia 2020-+License     : BSD+Maintainer  : gspia++= Fcf.Control.Monad+++-}++--------------------------------------------------------------------------------++module Fcf.Control.Monad where++import           Control.Monad.Identity+import           GHC.TypeNats as TN++import           Fcf as Fcf hiding (type (<*>))++--------------------------------------------------------------------------------+-- Functor instances++type instance Eval (Map f ('Identity a)) = 'Identity (Eval (f a))++++--------------------------------------------------------------------------------+-- Common methods for both Applicative and Monad+++-- | Return corresponds to the 'return' at Monad+-- or 'pure' of Applicative.+--+--+-- :kind! Eval (Return 1) :: Maybe Nat+-- :kind! Eval (Return 1) :: Either Symbol Nat+data Return :: a -> Exp (m a)+type instance Eval (Return a) = '[a]+type instance Eval (Return a) = 'Just a+type instance Eval (Return a) = 'Right a+type instance Eval (Return a) = 'Identity a+++--------------------------------------------------------------------------------+-- Applicative++-- | (<*>) corresponds to the value level '<*>'. Note that this clashes with+-- the definition given at Fcf.Combinators.((<*>)).+--+-- Applicatives that we define include:+--+--  - Identity+--  - []+--  - Maybe+--  - Either+--+-- === __Example__+--+-- >>> :kind! Eval ('Identity Plus2 <*> 'Identity 5)+-- Eval ('Identity Plus2 <*> 'Identity 5) :: Identity Nat+-- = 'Identity 7+--+-- >>> :kind! Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[4,5,6,7])+-- Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[4,5,6,7]) :: [Nat]+-- = '[5, 6, 7, 8, 40, 50, 60, 70]+-- >>> :kind! Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[])+-- Eval ( (<*>) '[ (Fcf.+) 1, (Fcf.*) 10] '[]) :: [Nat]+-- = '[]+-- >>> :kind! Eval ( (<*>) '[] '[4,5,6,7])+-- Eval ( (<*>) '[] '[4,5,6,7]) :: [b]+-- = '[]+--+--+data (<*>) :: f (a -> Exp b) -> f a -> Exp (f b)++type instance Eval ('Identity f <*> m) = Eval (Map f m)++type instance Eval ('[] <*> _) = '[]+type instance Eval (_ <*> '[]) = '[]+type instance Eval ((f ': fs) <*> (a ': as)) =+    Eval ((++) (Eval (Star_ f (a ': as))) (Eval ((<*>) fs (a ':as))))++-- | Helper for the [] applicative instance.+data Star_ :: (a -> Exp b) -> f a -> Exp (f b)+type instance Eval (Star_ _ '[]) = '[]+type instance Eval (Star_ f (a ': as)) =+    Eval (f a) ': (Eval (Star_ f as))+++-- Example+data Plus1 :: Nat -> Exp Nat+type instance Eval (Plus1 n) = n TN.+ 1++-- Example+data Plus2 :: Nat -> Exp Nat+type instance Eval (Plus2 n) = n TN.+ 2+++type instance Eval ('Nothing <*> _) = 'Nothing+type instance Eval ('Just f <*> m) = Eval (Map f m)+++type instance Eval ('Left e <*> _) = 'Left e+type instance Eval ('Right f <*> m) = Eval (Map f m)+++-- | Type level LiftA2.+--+-- === __Example__+--+-- >>> :kind! Eval (LiftA2 (Fcf.+) '[1,2] '[3,4])+-- Eval (LiftA2 (Fcf.+) '[1,2] '[3,4]) :: [Nat]+-- = '[4, 5, 5, 6]+--+--+data LiftA2 :: (a -> b -> Exp c) -> f a -> f b -> Exp (f c)+-- Could a single default implementation work here? Looks like it would need+-- a function that turns (a -> b -> c) to (b -> c).+-- E.g. something like:+-- type instance Eval (LiftA2 f fa fb) = Eval ( (<*>) (Map (f fa)) fb)++type instance Eval (LiftA2 f 'Nothing _) = 'Nothing+type instance Eval (LiftA2 f _ 'Nothing) = 'Nothing+type instance Eval (LiftA2 f ('Just a) ('Just b)) = 'Just (Eval (f a b))++type instance Eval (LiftA2 f ('Left e) _) = 'Left e+type instance Eval (LiftA2 f ('Right _) ('Left e)) = 'Left e+type instance Eval (LiftA2 f ('Right a) ('Right b)) = 'Right (Eval (f a b))+++type instance Eval (LiftA2 f '[] _) = '[]+type instance Eval (LiftA2 f (a ': as) '[]) = '[]+type instance Eval (LiftA2 f (a ': as) (b ':bs)) =+    Eval ((++) (Eval (LiftA2_ f a (b ': bs))) (Eval (LiftA2 f as (b ':bs))))++-- Helper for list LiftA2 instance.+data LiftA2_ :: (a -> b -> Exp c) -> a -> f b -> Exp (f c)+type instance Eval (LiftA2_ f a '[]) = '[]+type instance Eval (LiftA2_ f a (b ': bs)) =+    Eval (f a b) ': (Eval (LiftA2_ f a bs))+++--------------------------------------------------------------------------------+-- Monad+++-- | Type level Bind corresponding to the value level bind '>>=' operator.+--  Note that name (>>=) clashes with the definition given at+--  Fcf.Combinators.(>>=). (It doesn't export it yet, though.)+--+-- Monads that we define include:+--+--  - Identity+--  - []+--  - Maybe+--  - Either+--+-- === __Example__+--+-- Example: double the length of the input list and increase the numbers at+-- the same time.+--+-- >>> :kind! Eval ('[5,6,7] >>= Plus2M)+-- Eval ('[5,6,7] >>= Plus2M) :: [Nat]+-- = '[7, 8, 8, 9, 9, 10]+--+--+-- >>> :kind! Eval (XsPlusYsMonadic '[1,2,3] '[4,5,6])+-- Eval (XsPlusYsMonadic '[1,2,3] '[4,5,6]) :: [Nat]+-- = '[5, 6, 7, 6, 7, 8, 7, 8, 9]+data (>>=) :: m a -> (a -> Exp (m b)) -> Exp (m b)++-- Maybe+type instance Eval ('Nothing >>= f) = 'Nothing+type instance Eval ('Just a >>= f) = Eval (f a)++-- Either+type instance Eval ('Left a >>= _) = 'Left a+type instance Eval ('Right a >>= f) = Eval (f a)++-- Identity+type instance Eval ('Identity a >>= f) = Eval (f a)++-- Lists+type instance Eval ('[] >>= _) = '[]+type instance Eval ((x ': xs) >>= f) = Eval ((f @@ x) ++  Eval (xs >>= f))+++-- For the example. Turn an input number to list of two numbers of a bit+-- larger numbers.+data Plus2M :: Nat -> Exp [Nat]+type instance Eval (Plus2M n) = '[n TN.+ 2, n TN.+3]++-- Part of an example+data PureXPlusY :: Nat -> Nat -> Exp [Nat]+type instance Eval (PureXPlusY x y) = Eval (Return ((TN.+) x y))++-- Part of an example+data XPlusYs :: Nat -> [Nat] -> Exp [Nat]+type instance Eval (XPlusYs x ys) = Eval (ys >>= PureXPlusY x)++-- | An example implementing+--+-- sumM xs ys = do+--     x <- xs+--     y <- ys+--     return (x + y)+--+-- or+--+-- sumM xs ys = xs >>= (\x -> ys >>= (\y -> pure (x+y)))+--+-- Note the use of helper functions. This is a bit awkward, a type level+-- lambda would be nice.+data XsPlusYsMonadic :: [Nat] -> [Nat] -> Exp [Nat]+type instance Eval (XsPlusYsMonadic xs ys) = Eval (xs >>= Flip XPlusYs ys)+++++-- data Sumnd :: [Nat] -> [Nat] -> Exp [Nat]+-- type instance Eval (Sumnd xs ys) = xs >>=++-- data Sum2 :: Nat -> Nat -> Exp Nat+-- type instance Eval (Sum2 x y) = x TN.+ y++--+-- === __Example__+--+--+-- >>> :kind! Eval ( 'Just 1 >> 'Just 2)+-- Eval ( 'Just 1 >> 'Just 2) :: Maybe Nat+-- = 'Just 2+-- >>> :kind! Eval ( 'Nothing >> 'Just 2)+-- Eval ( 'Nothing >> 'Just 2) :: Maybe Nat+-- = 'Nothing+--+--+data (>>) :: m a -> m b -> Exp (m b)++-- Maybe+type instance Eval ('Nothing >> b) = 'Nothing+type instance Eval ('Just a >> b) = b++-- Either+type instance Eval ('Left a >> _) = 'Left a+type instance Eval ('Right _ >> b) = b++-- Lists+-- TODO, are the instances ok?+type instance Eval ('[] >> _) = '[]+type instance Eval ((x ': xs) >> b) = b++--------------------------------------------------------------------------------+-- MapM++-- | MapM+--+-- === __Example__+--+-- >>> :kind! Eval (MapM (ConstFn '[ 'True, 'False]) '["a","b","c"])+-- Eval (MapM (ConstFn '[ 'True, 'False]) '["a","b","c"]) :: [[Bool]]+-- = '[ '[ 'True, 'True, 'True], '[ 'True, 'True, 'False],+--      '[ 'True, 'False, 'True], '[ 'True, 'False, 'False],+--      '[ 'False, 'True, 'True], '[ 'False, 'True, 'False],+--      '[ 'False, 'False, 'True], '[ 'False, 'False, 'False]]+--+--+data MapM :: (a -> Exp (m b)) -> t a -> Exp (m (t b))+type instance Eval (MapM f ta) = Eval (Sequence (Map f @@ ta))+-- Above one is same as:+-- type instance Eval (MapM f ta) = Eval (Sequence (Eval (Map f ta)))+++-- | ForM = Flip MapM+data ForM :: t a -> (a -> Exp (m b)) -> Exp (m (t b))+type instance Eval (ForM ta f) = Eval (MapM f ta)+++--------------------------------------------------------------------------------+-- Traversable+++-- | Traverse+--+-- === __Example__+--+-- >>> :kind! Eval (Traverse Id '[ '[1,2], '[3,4]])+-- Eval (Traverse Id '[ '[1,2], '[3,4]]) :: [[Nat]]+-- = '[ '[1, 3], '[1, 4], '[2, 3], '[2, 4]]+--+--+data Traverse :: (a -> Exp (f b)) -> t a -> Exp (f (t b))+-- type instance Eval (Traverse f ta) = Eval (SequenceA =<< Map f ta)+-- Could the above one just be made to work? At the moment, the computation+-- diverges (we need to give the Traverse instances).++-- []+type instance Eval (Traverse f lst) =+    Eval (Foldr (Cons_f f) (Eval (Return '[])) lst)++-- | Helper for [] traverse+data Cons_f :: (a -> Exp (f b)) -> a -> f [b] -> Exp (f [b])+type instance Eval (Cons_f f x ys) = Eval (LiftA2 (Pure2 '(:)) (Eval (f x)) ys)+-- The following would need an extra import line:+-- type instance Eval (Cons_f f x ys) = Eval (LiftA2 Cons (Eval (f x)) ys)+++-- Maybe+type instance Eval (Traverse f 'Nothing) = Eval (Return 'Nothing)+type instance Eval (Traverse f ('Just x)) = Eval (Map (Pure1 'Just) (Eval (f x)))++-- Either+type instance Eval (Traverse f ('Left e)) = Eval (Return ('Left e))+type instance Eval (Traverse f ('Right x)) = Eval (Map (Pure1 'Right) (Eval (f x)))+++-- | Id function correspondes to term level 'id'-function.+data Id :: a -> Exp a+type instance Eval (Id a) = a+++-- | Sequence+--+-- === __Example__+--+-- >>> :kind! Eval (Sequence ('Just ('Right 5)))+-- Eval (Sequence ('Just ('Right 5))) :: Either a (Maybe Nat)+-- = 'Right ('Just 5)+--+-- >>> :kind! Eval (Sequence '[ 'Just 3, 'Just 5, 'Just 7])+-- Eval (Sequence '[ 'Just 3, 'Just 5, 'Just 7]) :: Maybe [Nat]+-- = 'Just '[3, 5, 7]+--+-- >>> :kind! Eval (Sequence '[ 'Just 3, 'Nothing, 'Just 7])+-- Eval (Sequence '[ 'Just 3, 'Nothing, 'Just 7]) :: Maybe [Nat]+-- = 'Nothing+--+-- >>> :kind! Eval (Sequence '[ '[1,2], '[3,4]])+-- Eval (Sequence '[ '[1,2], '[3,4]]) :: [[Nat]]+-- = '[ '[1, 3], '[1, 4], '[2, 3], '[2, 4]]+--+--+data Sequence :: t (f a) -> Exp (f (t a))+type instance Eval (Sequence tfa) = Eval (Traverse Id tfa)++
src/Fcf/Data/Set.hs view
@@ -92,9 +92,9 @@ --------------------------------------------------------------------------------  -- | Empty--- +-- -- === __Example__--- +-- -- >>> :kind! (Eval Empty :: Set Nat) -- (Eval Empty :: Set Nat) :: Set Nat -- = 'Set '[]@@ -104,9 +104,9 @@ type instance Eval Empty = 'Set '[]  -- | Singleton--- +-- -- === __Example__--- +-- -- >>> :kind! Eval (Singleton 1) -- Eval (Singleton 1) :: Set Nat -- = 'Set '[1]@@ -132,9 +132,9 @@         ('Set (v ': lst))  -- | Delete--- +-- -- === __Example__--- +-- -- >>> :kind! Eval (Delete 5 =<< FromList '[5, 3]) -- Eval (Delete 5 =<< FromList '[5, 3]) :: Set Nat -- = 'Set '[3]@@ -149,7 +149,7 @@ -- | Member -- -- === __Example__--- +-- -- >>> :kind! Eval (Member 5 =<< FromList '[5, 3]) -- Eval (Member 5 =<< FromList '[5, 3]) :: Bool -- = 'True@@ -162,7 +162,7 @@ -- | NotMember -- -- === __Example__--- +-- -- >>> :kind! Eval (NotMember 5 =<< FromList '[5, 3]) -- Eval (NotMember 5 =<< FromList '[5, 3]) :: Bool -- = 'False@@ -177,7 +177,7 @@ -- | Null -- -- === __Example__--- +-- -- >>> :kind! Eval (Null =<< FromList '[5, 3]) -- Eval (Null =<< FromList '[5, 3]) :: Bool -- = 'False@@ -192,7 +192,7 @@ -- | Size -- -- === __Example__--- +-- -- >>> :kind! Eval (Size =<< FromList '[5, 3]) -- Eval (Size =<< FromList '[5, 3]) :: Nat -- = 2@@ -200,10 +200,10 @@ type instance Eval (Size ('Set lst)) = Eval (Length lst)  --- | IsSubsetOf +-- | IsSubsetOf -- -- === __Example__--- +-- -- >>> :kind! Eval (IsSubsetOf ('Set '[]) ('Set '[0,1,2,3,4])) -- Eval (IsSubsetOf ('Set '[]) ('Set '[0,1,2,3,4])) :: Bool -- = 'True@@ -224,10 +224,10 @@     Eval (All (Flip Elem s2) s1)  --- | IsProperSubsetOf +-- | IsProperSubsetOf -- -- === __Example__--- +-- -- >>> :kind! Eval (IsProperSubsetOf ('Set '[0,1,2,3,4]) ('Set '[0,1,2,3,4])) -- Eval (IsProperSubsetOf ('Set '[0,1,2,3,4]) ('Set '[0,1,2,3,4])) :: Bool -- = 'False@@ -245,7 +245,7 @@ -- | Type-level set union. -- -- === __Example__--- +-- -- >>> :kind! Eval (Union (Eval (FromList '[5, 3])) (Eval (FromList '[5, 7])) ) -- Eval (Union (Eval (FromList '[5, 3])) (Eval (FromList '[5, 7])) ) :: Set  --                                                                        Nat@@ -262,9 +262,9 @@   -- | Type-level set difference.--- +-- -- === __Example__--- +-- -- >>> :kind! Eval (Difference (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7]))) -- Eval (Difference (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7]))) :: Set  --                                                                            Nat@@ -330,7 +330,7 @@ type instance Eval (SelectWithBools elms bls) =     Eval (Concat =<< ZipWith SelWithBool elms bls) --- | Calculate the power sets of a given type-level list. The algorithm is based +-- | Calculate the power sets of a given type-level list. The algorithm is based -- on Gray codes. -- -- === __Example__@@ -360,7 +360,7 @@ -- | Use FromList to construct a Set from type-level list. -- -- === __Example__--- +-- -- >>> :kind! Eval (FromList '[1, 2]) -- Eval (FromList '[1, 2]) :: Set Nat -- = 'Set '[1, 2]@@ -370,7 +370,7 @@ -- | Get the type-level list out of the 'Set'. -- -- === __Example__--- +-- -- >>> :kind! Eval (ToList =<< PowerSet =<< FromList '[1,2,3]) -- Eval (ToList =<< PowerSet =<< FromList '[1,2,3]) :: [Set Nat] -- = '[ 'Set '[], 'Set '[3], 'Set '[2], 'Set '[2, 3], 'Set '[1],
src/Fcf/Data/Text.hs view
@@ -30,8 +30,10 @@     , Empty     , Singleton     , FromList+    , FromSymbolList     , ToList     , ToSymbol+    , ToSymbolList      -- * Basic Interface     , Null@@ -96,7 +98,6 @@     ( Length, Init, Reverse, Take, Drop, TakeWhile, DropWhile     , Intercalate, Intersperse, IsPrefixOf, IsSuffixOf, IsInfixOf, Snoc) import           Fcf.Data.Symbol (Symbol)--- import qualified Fcf.Data.Symbol as FS  import qualified Fcf.Class.Functor as F ( FMap ) 
src/Fcf/Data/Text/Internal.hs view
@@ -20,7 +20,7 @@  This is from https://kcsongor.github.io/symbol-parsing-haskell/ -Ks. symbols library+Please do also check the symbols library at Hackage.  -} @@ -29,7 +29,6 @@ module Fcf.Data.Text.Internal where  import Data.Char (chr)--- import Data.Proxy  import qualified GHC.TypeLits as TL import qualified Fcf.Data.List as L@@ -51,7 +50,7 @@ type family ToList (sym :: TL.Symbol) :: [TL.Symbol] where     ToList sym = ToList1 sym "" --- Helper. +-- Helper. data ToSymbol2 :: [TL.Symbol] -> Exp TL.Symbol type instance Eval (ToSymbol2 lst) = Eval (Foldr S.Append "" lst) 
src/Fcf/Data/Tree.hs view
@@ -37,6 +37,8 @@ import           Fcf as Fcf import           Fcf.Data.List as Fcf +import           Fcf.Control.Monad as M+ --------------------------------------------------------------------------------  -- For the doctests:@@ -54,6 +56,50 @@ -- | Same as in containers, except not used for any term-level computation -- in this module. type Forest a = [Tree a]+++type ExT1r =+    'Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]]++type ExTr2 =+    'Node ('Just 1)+        '[ 'Node ('Just 2)+            '[ 'Node ('Just 3)+                '[ 'Node ('Just 4) '[]]+             ]+         , 'Node ('Just 5)+            '[ 'Node ('Just 6) '[]+             ]+         ]+++-- map for trees+type instance Eval (Map f ('Node a tr)) = 'Node (f @@ a) (Eval (Map (Map f) tr))++-- pure/return for trees+type instance Eval (M.Return a) = 'Node a '[]++-- M.<*> instance (applicative)+type instance Eval (('Node f tfs) M.<*> ('Node x txs)) =+    'Node (Eval (f x))+        (Eval ( (Eval (Map (Map f) txs))+        +++          (Eval (Map (StarTx ('Node x txs)) tfs))+          -- (Eval (Map ( M.<*> ('Node x txs)) tfs))+        ))++-- Helper for M.<*>+data StarTx :: Tree a -> Tree (a -> Exp b) -> Exp (Tree b)+type instance Eval (StarTx fa fab) = Eval (fab M.<*> fa)+++-- :kind! Eval (Sequence ExTr2)+type instance Eval (Traverse f ('Node x ts)) =+    Eval (LiftA2 (Pure2 'Node) (Eval (f x)) (Eval (Traverse (Traverse f) ts)))+++--------------------------------------------------------------------------------+  -- | Fold a type-level 'Tree'. data FoldTree :: (a -> [b] -> Exp b) -> Tree a -> Exp b