diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.hi b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.hi index 2e0be2e..86bb0f2 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.hi and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.hi differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.o b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.o index 1aed21d..453c995 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.o and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/JSONParser.o differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/autogen/cabal_macros.h b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/autogen/cabal_macros.h index be15e0e..91fc158 100644 --- a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/autogen/cabal_macros.h +++ b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/autogen/cabal_macros.h @@ -20,6 +20,16 @@ (major1) == 4 && (major2) < 16 || \ (major1) == 4 && (major2) == 16 && (minor) <= 0) #endif /* MIN_VERSION_base */ +/* package mtl-2.2.2 */ +#ifndef VERSION_mtl +#define VERSION_mtl "2.2.2" +#endif /* VERSION_mtl */ +#ifndef MIN_VERSION_mtl +#define MIN_VERSION_mtl(major1,major2,minor) (\ + (major1) < 2 || \ + (major1) == 2 && (major2) < 2 || \ + (major1) == 2 && (major2) == 2 && (minor) <= 2) +#endif /* MIN_VERSION_mtl */ /* tool gcc-10.2.0 */ #ifndef TOOL_VERSION_gcc diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/libHSparsing-0.1.0.0-inplace.a b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/libHSparsing-0.1.0.0-inplace.a index 912731d..65ed401 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/libHSparsing-0.1.0.0-inplace.a and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/build/libHSparsing-0.1.0.0-inplace.a differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/build b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/build index 57fd3c6..05ffe36 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/build and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/build differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/config b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/config index 418f4a7..55f400c 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/config and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/config differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/registration b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/registration index 8936221..648b72a 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/registration and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/cache/registration differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/setup-config b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/setup-config index 2676300..28b2958 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/setup-config and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/build/x86_64-windows/ghc-9.2.1/parsing-0.1.0.0/setup-config differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/config b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/config index 0751700..2b346a8 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/config and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/config differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/elaborated-plan b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/elaborated-plan index 7620a16..81c3c5e 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/elaborated-plan and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/elaborated-plan differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/improved-plan b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/improved-plan index d4f74cd..0a64d6a 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/improved-plan and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/improved-plan differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/plan.json b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/plan.json index 31685d1..043e788 100644 --- a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/plan.json +++ b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/plan.json @@ -1 +1 @@ -{"cabal-version":"3.6.2.0","cabal-lib-version":"3.6.2.0","compiler-id":"ghc-9.2.1","os":"windows","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.16.0.0","pkg-name":"base","pkg-version":"4.16.0.0","depends":["ghc-bignum-1.2","ghc-prim-0.8.0","rts-1.0.2"]},{"type":"pre-existing","id":"ghc-bignum-1.2","pkg-name":"ghc-bignum","pkg-version":"1.2","depends":["ghc-prim-0.8.0"]},{"type":"pre-existing","id":"ghc-prim-0.8.0","pkg-name":"ghc-prim","pkg-version":"0.8.0","depends":["rts-1.0.2"]},{"type":"configured","id":"parsing-0.1.0.0-inplace","pkg-name":"parsing","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"C:\\Users\\Administrator\\Desktop\\Haskell first Principles\\haskell-deepidive\\Haskell Excercises & Code\\Alejandro - Book of Monads\\."},"dist-dir":"C:\\Users\\Administrator\\Desktop\\Haskell first Principles\\haskell-deepidive\\Haskell Excercises & Code\\Alejandro - Book of Monads\\dist-newstyle\\build\\x86_64-windows\\ghc-9.2.1\\parsing-0.1.0.0","depends":["base-4.16.0.0"],"exe-depends":[],"component-name":"lib"},{"type":"pre-existing","id":"rts-1.0.2","pkg-name":"rts","pkg-version":"1.0.2","depends":[]}]} \ No newline at end of file +{"cabal-version":"3.6.2.0","cabal-lib-version":"3.6.2.0","compiler-id":"ghc-9.2.1","os":"windows","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.16.0.0","pkg-name":"base","pkg-version":"4.16.0.0","depends":["ghc-bignum-1.2","ghc-prim-0.8.0","rts-1.0.2"]},{"type":"pre-existing","id":"ghc-bignum-1.2","pkg-name":"ghc-bignum","pkg-version":"1.2","depends":["ghc-prim-0.8.0"]},{"type":"pre-existing","id":"ghc-prim-0.8.0","pkg-name":"ghc-prim","pkg-version":"0.8.0","depends":["rts-1.0.2"]},{"type":"pre-existing","id":"mtl-2.2.2","pkg-name":"mtl","pkg-version":"2.2.2","depends":["base-4.16.0.0","transformers-0.5.6.2"]},{"type":"configured","id":"parsing-0.1.0.0-inplace","pkg-name":"parsing","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"C:\\Users\\Administrator\\Desktop\\Haskell first Principles\\haskell-deepidive\\Haskell Excercises & Code\\Alejandro - Book of Monads\\."},"dist-dir":"C:\\Users\\Administrator\\Desktop\\Haskell first Principles\\haskell-deepidive\\Haskell Excercises & Code\\Alejandro - Book of Monads\\dist-newstyle\\build\\x86_64-windows\\ghc-9.2.1\\parsing-0.1.0.0","depends":["base-4.16.0.0","mtl-2.2.2"],"exe-depends":[],"component-name":"lib"},{"type":"pre-existing","id":"rts-1.0.2","pkg-name":"rts","pkg-version":"1.0.2","depends":[]},{"type":"pre-existing","id":"transformers-0.5.6.2","pkg-name":"transformers","pkg-version":"0.5.6.2","depends":["base-4.16.0.0"]}]} \ No newline at end of file diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/solver-plan b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/solver-plan index eff6e4d..27b2e0b 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/solver-plan and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/solver-plan differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/up-to-date b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/up-to-date index 856813f..48779b9 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/up-to-date and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/cache/up-to-date differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/package.cache b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/package.cache index c3fa80c..3265b78 100644 Binary files a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/package.cache and b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/package.cache differ diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/parsing-0.1.0.0-inplace.conf b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/parsing-0.1.0.0-inplace.conf index 0374085..583b923 100644 --- a/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/parsing-0.1.0.0-inplace.conf +++ b/Haskell Excercises & Code/Alejandro - Book of Monads/dist-newstyle/packagedb/ghc-9.2.1/parsing-0.1.0.0-inplace.conf @@ -23,7 +23,7 @@ data-dir: hs-libraries: HSparsing-0.1.0.0-inplace include-dirs: C:\tools\msys64\mingw64\include -depends: base-4.16.0.0 +depends: base-4.16.0.0 mtl-2.2.2 haddock-interfaces: "C:\\Users\\Administrator\\Desktop\\Haskell first Principles\\haskell-deepidive\\Haskell Excercises & Code\\Alejandro - Book of Monads\\dist-newstyle\\build\\x86_64-windows\\ghc-9.2.1\\parsing-0.1.0.0\\doc\\html\\parsing\\parsing.haddock" diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/monadic.hs b/Haskell Excercises & Code/Alejandro - Book of Monads/monadic.hs new file mode 100644 index 0000000..959ca87 --- /dev/null +++ b/Haskell Excercises & Code/Alejandro - Book of Monads/monadic.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE FlexibleContexts #-} +module MonadicCode where + +import Control.Monad.State as CMS + + +-- implement `ap` yourself + +ap :: Monad m => m (a -> b) -> m a -> m b +ap mf mx = do + f <- mf + x <- mx + return (f x) \ No newline at end of file diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/parser.cabal b/Haskell Excercises & Code/Alejandro - Book of Monads/parser.cabal index c86f86a..59bf0a8 100644 --- a/Haskell Excercises & Code/Alejandro - Book of Monads/parser.cabal +++ b/Haskell Excercises & Code/Alejandro - Book of Monads/parser.cabal @@ -11,5 +11,6 @@ library exposed-modules: JSONParser ghc-options: -Wall -fwarn-tabs build-depends: base >=4.7 && <5 + , mtl hs-source-dirs: . default-language: Haskell2010 \ No newline at end of file diff --git a/Haskell Excercises & Code/Alejandro - Book of Monads/practice.hs b/Haskell Excercises & Code/Alejandro - Book of Monads/practice.hs index c34f7e1..ff3f344 100644 --- a/Haskell Excercises & Code/Alejandro - Book of Monads/practice.hs +++ b/Haskell Excercises & Code/Alejandro - Book of Monads/practice.hs @@ -1,5 +1,7 @@ module WithCounting where +import Control.Monad.State as CMS + -- Chapter 1. Exercises and Practice type WithCounter a = Int -> (a, Int) @@ -23,10 +25,10 @@ pure x = \i -> (x, i) type State s a = s -> (a, s) -- rewrite next & pure -next' :: State s a -> (a -> State s b) -> State s b +next' :: CMS.State s a -> (a -> CMS.State s b) -> CMS.State s b f `next'` g = \i -> let (r, i') = f i in g r i' -pure' :: a -> State s a +pure' :: a -> CMS.State s a pure' x = \s -> (x, s) -- 1.2 @@ -54,7 +56,7 @@ flatten :: Maybe (Maybe a) -> Maybe a flatten (Just (Just x)) = Just x flatten _ = Nothing -flatten' oo = then_ oo id - -- case oo of - Nothing -> Nothing - Just x -> id x ==> x \ No newline at end of file +-- flatten' oo = then_ oo id +-- -- case oo of +-- Nothing -> Nothing +-- Just x -> id x ==> x \ No newline at end of file