1
1
mirror of https://github.com/thma/LtuPatternFactory.git synced 2025-01-05 19:04:46 +03:00

update Coerce

add nice quote to conclusion section
This commit is contained in:
Mahler, Thomas 2018-11-13 17:08:51 +01:00
parent 1f33d594f9
commit 996954faea
2 changed files with 27 additions and 1 deletions

View File

@ -1297,6 +1297,18 @@ BankAccount {accountNo = 5678, name = "Marjin Mejer", branch = "Reikjavik", bala
> these features are already or nearly available now.
> Quoted from [Design Patterns as Higher-Order Datatype-Generic Programs](http://www.cs.ox.ac.uk/jeremy.gibbons/publications/hodgp.pdf)
> Crystallizing design patterns
> To end with FP benefits, there is this curious thing called CurryHoward correspondence which is a direct analogy between mathematical concepts and computational calculus (which is what we do, programmers).
>
> This correspondence means that a lot of useful stuff discovered and proven for decades in Math can then be transposed to programming, opening a way for a lot of extremely robust constructs for free.
>
> In OOP, Design patterns are used a lot and could be defined as idiomatic ways to solve a given problems, in specific contexts but their existences wont save you from having to apply and write them again and again each time you encounter the problems they solve.
>
> Functional programming constructs, some directly coming from category theory (mathematics), solve directly what you would have tried to solve with design patterns.
>
> Quoted from [Geekocephale](http://geekocephale.com/blog/2018/10/08/fp)
https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence
<!--
## TBD: Conclusion
@ -1324,3 +1336,7 @@ https://staticallytyped.wordpress.com/2013/03/09/gang-of-four-patterns-with-type
http://norvig.com/design-patterns/design-patterns.pdf
[Scala Typeclassopedia](https://github.com/tel/scala-typeclassopedia)
https://github.com/mmenestret/fp-resources/blob/master/README.md

View File

@ -40,4 +40,14 @@ instance Coerce (m a) c => Coerce (WrappedMonad m a) c where
instance Coerce (State s a) (s -> (a,s)) where
unwrap = runState
wrap = state
coerce :: (Coerce a b, Coerce b a, Typeable a, Typeable b) => a -> b
coerce = undefined
{--
coerce x = let u = wrap x
d = unwrap x
--ta = typeRep ([] :: [a])
tb = typeRep ([] :: [b])
in if (typeOf u == tb) then u
else d
--}