1
1
mirror of https://github.com/thma/LtuPatternFactory.git synced 2024-11-30 02:03:47 +03:00

small updates

This commit is contained in:
thma 2018-10-17 22:06:03 +02:00
parent dd2e0e781c
commit 42e10eb4d7
9 changed files with 13 additions and 8 deletions

2
.gitignore vendored
View File

@ -20,3 +20,5 @@ cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
.idea
*.iml

View File

@ -1,6 +1,6 @@
name: LtuPatternFactory
version: 0.1.0.0
synopsis: Comparing OO Design Paterns with Functional Programming concepts
synopsis: Comparing OO Design Patterns with Functional Programming concepts
-- description:
homepage: https://github.com/thma/LtuPatternFactory#readme
license: Apache-2.0

View File

@ -503,13 +503,15 @@ TBD: Traversable Demo
### Alternative approaches
http://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/
## Template Method -> Typeclass default functions
like strategy, type class with default implemenations
# Beyond Typeclass patterns
TBD:
- Chain of Responsibility: ADT + fumction pattern matching the ADT (at least the distpatch variant)
- Template Method, like strategy, type class with default implemenations
- Currying / Partial application
## Dependency Injection -> Parameter Binding

View File

@ -44,6 +44,6 @@ addMinutesAdapter :: Int -> Minute -> Minute
addMinutesAdapter x = unmarshalWM . addMinutesToWallTime x . marshalMW
adapterDemo = do
putStrLn "Adapter vs. function composition"
putStrLn "Adapter -> function composition"
print $ addMinutesAdapter 100 $ Minute 400
putStrLn ""

View File

@ -15,6 +15,7 @@ builder acc name = withName (acc, name)
withName = undefined
builderDemo = do
putStrLn "Builder -> ???"
let acc1 = BankAccount {
accountNo = 1234
, name = "Marjin"

View File

@ -45,7 +45,7 @@ countingPipeline str =
return str >>= return . length . words >>= return . (3 *)
pipelineDemo = do
putStrLn "Pipeline vs. Monad"
putStrLn "Pipeline -> Monad"
print $ pipeline "hello world"
print $ countingPipeline "hello counting world"
putStrLn ""

View File

@ -54,7 +54,7 @@ fetch x ((y,v):ys)
singletonDemo :: IO ()
singletonDemo = do
putStrLn "Singleton vs. Applicative Functor, Pointed (and let in general)"
putStrLn "Singleton -> Applicative Functor, Pointed (and let in general)"
let exp = Mul (Add (Val 3) (Val 1))
(Mul (Val 2) (Var "pi"))
env = [("pi", pi)]

View File

@ -12,7 +12,7 @@ context :: Num a => (a -> a) -> [a] -> [a]
context = fmap
strategyDemo = do
putStrLn "Strategy Pattern vs. Functor (and Higher Order Functions in general)"
putStrLn "Strategy Pattern -> Functor (and Higher Order Functions in general)"
print $ context strategyId [1..10]
print $ context strategyDouble [1..10]
putStrLn ""

View File

@ -13,7 +13,7 @@ filterF :: Foldable f => (a -> Bool) -> f a -> [a]
filterF p = foldMap (\a -> if p a then [a] else [])
visitorDemo = do
putStrLn "Visitor vs. Foldable, Traversable"
putStrLn "Visitor -> Foldable -> Traversable"
let exp = Mul (Add (Val 3) (Val 2))
(Mul (Val 4) (Val 6))
print exp