Compare commits
10 Commits
487130ef65
...
cce60e0790
Author | SHA1 | Date |
---|---|---|
Sanchayan Maity | cce60e0790 | |
Sanchayan Maity | 91050d615a | |
Sanchayan Maity | c56f7f977c | |
Sanchayan Maity | ce6e56a49e | |
Sanchayan Maity | b1ef1705d3 | |
Sanchayan Maity | 0c904479a5 | |
Sanchayan Maity | b4bf90923d | |
Sanchayan Maity | 0fb8217770 | |
Sanchayan Maity | cadd5d2406 | |
Sanchayan Maity | 3b32e4c073 |
10
README.md
10
README.md
|
@ -16,6 +16,10 @@ result/bin/ihaskell-notebook
|
|||
One can link the binary in local/bin to the above so that it can be run from
|
||||
anywhere.
|
||||
|
||||
# My Lens talk
|
||||
|
||||
https://www.youtube.com/watch?v=uZLN2x3u2kg
|
||||
|
||||
# References
|
||||
|
||||
namc.in/2018-03-26-lenses-part-1
|
||||
|
@ -26,6 +30,12 @@ https://www.schoolofhaskell.com/user/griba/easier_lenses_profunctor_based_with_m
|
|||
|
||||
https://www.schoolofhaskell.com/user/liyang/profunctors
|
||||
|
||||
https://bartoszmilewski.com/2015/07/13/from-lenses-to-yoneda-embedding/
|
||||
|
||||
https://github.com/hablapps/DontFearTheProfunctorOptics
|
||||
|
||||
https://twanvl.nl/blog/haskell/isomorphism-lenses
|
||||
|
||||
https://blog.jez.io/lens-intuition/
|
||||
|
||||
https://blog.jle.im/entry/lenses-products-prisms-sums.html
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<style>/* Styles used for the Hoogle display in the pager */\n",
|
||||
".hoogle-doc {\n",
|
||||
"display: block;\n",
|
||||
"padding-bottom: 1.3em;\n",
|
||||
"padding-left: 0.4em;\n",
|
||||
"}\n",
|
||||
".hoogle-code {\n",
|
||||
"display: block;\n",
|
||||
"font-family: monospace;\n",
|
||||
"white-space: pre;\n",
|
||||
"}\n",
|
||||
".hoogle-text {\n",
|
||||
"display: block;\n",
|
||||
"}\n",
|
||||
".hoogle-name {\n",
|
||||
"color: green;\n",
|
||||
"font-weight: bold;\n",
|
||||
"}\n",
|
||||
".hoogle-head {\n",
|
||||
"font-weight: bold;\n",
|
||||
"}\n",
|
||||
".hoogle-sub {\n",
|
||||
"display: block;\n",
|
||||
"margin-left: 0.4em;\n",
|
||||
"}\n",
|
||||
".hoogle-package {\n",
|
||||
"font-weight: bold;\n",
|
||||
"font-style: italic;\n",
|
||||
"}\n",
|
||||
".hoogle-module {\n",
|
||||
"font-weight: bold;\n",
|
||||
"}\n",
|
||||
".hoogle-class {\n",
|
||||
"font-weight: bold;\n",
|
||||
"}\n",
|
||||
".get-type {\n",
|
||||
"color: green;\n",
|
||||
"font-weight: bold;\n",
|
||||
"font-family: monospace;\n",
|
||||
"display: block;\n",
|
||||
"white-space: pre-wrap;\n",
|
||||
"}\n",
|
||||
".show-type {\n",
|
||||
"color: green;\n",
|
||||
"font-weight: bold;\n",
|
||||
"font-family: monospace;\n",
|
||||
"margin-left: 1em;\n",
|
||||
"}\n",
|
||||
".mono {\n",
|
||||
"font-family: monospace;\n",
|
||||
"display: block;\n",
|
||||
"}\n",
|
||||
".err-msg {\n",
|
||||
"color: red;\n",
|
||||
"font-style: italic;\n",
|
||||
"font-family: monospace;\n",
|
||||
"white-space: pre;\n",
|
||||
"display: block;\n",
|
||||
"}\n",
|
||||
"#unshowable {\n",
|
||||
"color: red;\n",
|
||||
"font-weight: bold;\n",
|
||||
"}\n",
|
||||
".err-msg.in.collapse {\n",
|
||||
"padding-top: 0.7em;\n",
|
||||
"}\n",
|
||||
".highlight-code {\n",
|
||||
"white-space: pre;\n",
|
||||
"font-family: monospace;\n",
|
||||
"}\n",
|
||||
".suggestion-warning { \n",
|
||||
"font-weight: bold;\n",
|
||||
"color: rgb(200, 130, 0);\n",
|
||||
"}\n",
|
||||
".suggestion-error { \n",
|
||||
"font-weight: bold;\n",
|
||||
"color: red;\n",
|
||||
"}\n",
|
||||
".suggestion-name {\n",
|
||||
"font-weight: bold;\n",
|
||||
"}\n",
|
||||
"</style><span class='get-type'>(>>-) :: forall r a. MCont r a -> (a -> r) -> r</span>"
|
||||
],
|
||||
"text/plain": [
|
||||
"(>>-) :: forall r a. MCont r a -> (a -> r) -> r"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"newtype MCont r a = MCont { (>>-) :: (a -> r) -> r }\n",
|
||||
"\n",
|
||||
":t (>>-)\n",
|
||||
"\n",
|
||||
"instance Functor (MCont r) where\n",
|
||||
" fmap f cra = MCont $ \\k -> cra >>- \\a -> k (f a)\n",
|
||||
" \n",
|
||||
"instance Applicative (MCont r) where\n",
|
||||
" pure a = MCont $ \\aTor -> aTor a\n",
|
||||
" cf <*> cx = MCont $ \\bTor ->\n",
|
||||
" cx >>- \\a ->\n",
|
||||
" cf >>- \\f ->\n",
|
||||
" bTor (f a)\n",
|
||||
" \n",
|
||||
"instance Monad (MCont r) where\n",
|
||||
" return = pure\n",
|
||||
" cra >>= f = MCont $ \\bTor ->\n",
|
||||
" cra >>- \\a ->\n",
|
||||
" (f a) >>- \\b ->\n",
|
||||
" bTor b\n",
|
||||
" \n",
|
||||
"join' :: MCont r (MCont r a) -> MCont r a\n",
|
||||
"join' ccx = MCont $ \\k ->\n",
|
||||
" ccx >>- \\cx -> -- extract inner continuation\n",
|
||||
" cx >>- \\x -> -- extract value of inner continuation\n",
|
||||
" k x -- wrap value in k again"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"square :: Int -> MCont r Int\n",
|
||||
"square x = MCont $ \\k -> k (x ^ 2)\n",
|
||||
"\n",
|
||||
"add :: Int -> Int -> MCont r Int\n",
|
||||
"add x y = MCont $ \\k -> k (x + y)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pythagoras :: Int -> Int -> MCont r Int\n",
|
||||
"pythagoras x y = do\n",
|
||||
" xsquare <- square x\n",
|
||||
" ysquare <- square y\n",
|
||||
" add xsquare ysquare"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Haskell",
|
||||
"language": "haskell",
|
||||
"name": "haskell"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": "ihaskell",
|
||||
"file_extension": ".hs",
|
||||
"name": "haskell",
|
||||
"pygments_lexer": "Haskell",
|
||||
"version": "8.6.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
http://okmij.org/ftp/continuations/#tutorial
|
||||
|
||||
http://okmij.org/ftp/Haskell/types.html
|
||||
|
||||
https://gist.github.com/lexi-lambda/d97b8187a9b63619af29689e9fa1b880
|
||||
|
||||
http://hackage.haskell.org/package/liboleg-2010.1.10.0/docs/Control-CCRef.html
|
||||
|
||||
https://hackage.haskell.org/package/CC-delcont-0.2.1.0/candidate/docs/Control-Monad-CC.html
|
||||
|
||||
http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html
|
||||
|
||||
http://www.haskellforall.com/2012/12/the-continuation-monad.html
|
||||
|
||||
https://blog.poisson.chat/posts/2019-10-26-reasonable-continuations.html
|
||||
|
||||
http://okmij.org/ftp/continuations/implementations.html
|
||||
|
||||
https://free.cofree.io/2020/01/02/cps/
|
||||
|
||||
https://maxhallinan.com/posts/2019/10/22/how-does-the-continuation-monad-work/
|
||||
|
||||
https://github.com/iokasimov/pipeline
|
||||
|
||||
https://hexagoxel.de/postsforpublish/posts/2018-09-09-cont-part-one.html
|
||||
|
||||
https://github.com/rain-1/continuations-study-group/wiki/Reading-List
|
||||
|
||||
http://blog.ielliott.io/continuations-from-the-ground-up/
|
||||
|
||||
https://deque.blog/2017/12/08/continuation-passing-style-free-monads-and-direct-style-free-monads/
|
||||
|
||||
https://vaibhavsagar.com/blog/2017/05/22/discovering-continuations/
|
||||
|
||||
http://blog.sigfpe.com/2008/12/mother-of-all-monads.html
|
||||
|
||||
https://github.com/quchen/articles/blob/master/cont_monad.md
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Contravariant Functors"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"{-# LANGUAGE KindSignatures #-}\n",
|
||||
"\n",
|
||||
"-- (.) :: (b -> c) -> (a -> b) -> a -> c\n",
|
||||
"-- contraComp :: (a -> b) -> (b -> c) -> a -> c\n",
|
||||
"\n",
|
||||
"-- (.) f g x = f (g x)\n",
|
||||
"-- contraComp f g x = g (f x)\n",
|
||||
"\n",
|
||||
"-- instance Functor (a ->) where\n",
|
||||
"-- fmap = (.)\n",
|
||||
"\n",
|
||||
"-- instance Contravariant (-> z) where\n",
|
||||
"-- contramap = flip (.)\n",
|
||||
"\n",
|
||||
"newtype Predicate a = Predicate { getPredicate :: a -> Bool }\n",
|
||||
"\n",
|
||||
"newtype Op b a = Op { getOp :: a -> b }\n",
|
||||
" \n",
|
||||
"class Contravariant (f :: * -> *) where\n",
|
||||
" contramap :: (a -> b) -> f b -> f a\n",
|
||||
" \n",
|
||||
"instance Contravariant (Op a) where\n",
|
||||
" contramap f g = Op $ let bToa = getOp g in bToa . f"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Haskell",
|
||||
"language": "haskell",
|
||||
"name": "haskell"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": "ihaskell",
|
||||
"file_extension": ".hs",
|
||||
"name": "haskell",
|
||||
"pygments_lexer": "Haskell",
|
||||
"version": "8.8.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
https://gist.github.com/CMCDragonkai/b203769c588caddf8cb051529339635c
|
||||
|
||||
http://iveselov.info/posts/2012-08-30-existential-types.html
|
||||
|
||||
Great explanation by Anupam Jain in FPNCR Telegram channel :)
|
||||
|
||||
Everything gets a forall.
|
||||
|
||||
Basically if you see a free variable x in a type signature, assume there’s a
|
||||
*forall x* in front of the signature.
|
||||
|
||||
Free variable is just a fancy way to say an undeclared variable. Where *forall*
|
||||
is the way we declare variables. So if the signature is *foo :: a -> Int*,
|
||||
the *a* is free because it was not introduced first with a *forall*.
|
||||
|
||||
*forall* at type level is like a lambda (\) at the value level. It basically
|
||||
says somehow I will be given a type and then rest of the implementation can
|
||||
depend on that type. And in fact some languages like Dhall make it explicit
|
||||
where they accept an actual type parameter instead of making it implicit
|
||||
|
||||
In Dhall it would be something like ‘foo : a:Type -> val:a -> Int’
|
||||
It says foo takes a type, a value of that type, and gives you an Int back.
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue