Skip to content

Commit

Permalink
Use hakyll-shortcut-links library
Browse files Browse the repository at this point in the history
  • Loading branch information
vrom911 committed May 2, 2019
1 parent 440ceae commit 22d9621
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
18 changes: 9 additions & 9 deletions blog/2019-03-20-write-yourself-a-lens.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ our users. This brings us to the decision of implementing our own lenses inside
### How it should work

`relude` encourages users enthusiasm and eagerness to explore. That’s why
`relude` uses the approach with the [`Extra.*` modules](https://github.com/kowainik/relude/tree/master/src/Relude/Extra) which
`relude` uses the approach with the [`Extra.*` modules](@github(kowainik):relude/tree/master/src/Relude/Extra) which
are not exported by default, so it is quite easy to bring something new and let
users decide whether to use it or not without spoiling the global namespace.
This method is also applied to the implementation of `lens`. To use lenses from
Expand Down Expand Up @@ -175,7 +175,7 @@ the one that suits us the most. Okay, we actually need the functor that won't
change the object at all and will just return a value. Let's look at the
standard [Functor instances in the base library][functor] to choose the most
suitable instance. Recall, that we are implementing the getter, so name
[`Const`](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Functor-Const.html#t:Const)
[`Const`](@hackage:base-4.12.0.0/docs/Data-Functor-Const.html#t:Const)
sounds good in these conditions. Let's check it out:

```haskell
Expand Down Expand Up @@ -210,7 +210,7 @@ know that it is all about choosing the correct functor. This time we actually
want to change the value inside the functor and to return the whole data not
wrapped into anything. Let's check [the list][functor] again. Aha, look what I
found:
[Identity](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Functor-Identity.html#t:Identity)
[Identity](@hackage:base-4.12.0.0/docs/Data-Functor-Identity.html#t:Identity)


```haskell
Expand All @@ -233,7 +233,7 @@ But wait, we are not using a variable with name `a` at all! This is suspicious,
taking into consideration the goal that this function is pursuing. We want the
value of the type `a` to be changed to the given one. So we need to somehow
change the `a` value, no matter what the value it had before. Sounds like the
[`const`](https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#v:const)
[`const`](@hackage:base-4.12.0.0/docs/Prelude.html#v:const)
function:

```haskell
Expand Down Expand Up @@ -393,7 +393,7 @@ Haskeller { haskellerName = "vrom911", ... }
```

To give the context of how it works, check out the type of
[`&`](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Function.html#v:-38-)
[`&`](@hackage:base-4.12.0.0/docs/Data-Function.html#v:-38-)
operator:


Expand Down Expand Up @@ -445,11 +445,11 @@ you & kLensL .~ True

As promised, some links:

* [relude: Lens Hackage page](https://hackage.haskell.org/package/relude-0.5.0/docs/Relude-Extra-Lens.html)
* [relude: Lens source code](https://github.com/kowainik/relude/blob/master/src/Relude/Extra/Lens.hs)
* [relude: Lens Hackage page](@hackage:relude-0.5.0/docs/Relude-Extra-Lens.html)
* [relude: Lens source code](@github(kowainik):relude/blob/master/src/Relude/Extra/Lens.hs)
* [`lens` package][lens]
* [`microlens` package](http://hackage.haskell.org/package/microlens)
* [lens tutorial](http://hackage.haskell.org/package/lens-tutorial-1.0.3/docs/Control-Lens-Tutorial.html)
* [`microlens` package](@hackage:microlens)
* [lens tutorial](@hackage:lens-tutorial-1.0.3/docs/Control-Lens-Tutorial.html)
* [School of Haskell lens tutorial](https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/a-little-lens-starter-tutorial)
* [Wiki Lenses](https://en.wikibooks.org/wiki/Haskell/Lenses_and_functional_references)
* [Lens over tea](https://artyom.me/lens-over-tea-1)
Expand Down
7 changes: 4 additions & 3 deletions src/Website/Blog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import Data.List (nub)
import Hakyll (Compiler, Context, Item, Pattern, Rules, buildTags, compile, constField, create,
customRoute, defaultContext, defaultHakyllReaderOptions, defaultHakyllWriterOptions,
field, fromCapture, getResourceString, getTags, idRoute, itemBody, itemIdentifier,
listField, loadAll, loadAndApplyTemplate, makeItem, match, pandocCompiler,
recentFirst, relativizeUrls, renderPandocWith, route, tagsRules, toFilePath)
listField, loadAll, loadAndApplyTemplate, makeItem, match, recentFirst,
relativizeUrls, renderPandocWith, route, tagsRules, toFilePath)
import Hakyll.ShortcutLinks (allShortcutLinksCompiler)
import System.FilePath (replaceExtension)
import Text.Pandoc.Options (WriterOptions (..))

Expand All @@ -33,7 +34,7 @@ matchBlogPosts = match "blog/*" $ do
let postTagsCtx = postCtxWithTags tgs
<> mkPostSocialCtx
<> constField "toc" toc
pandocCompiler
allShortcutLinksCompiler
>>= loadAndApplyTemplate "templates/post.html" postTagsCtx
>>= relativizeUrls

Expand Down
1 change: 1 addition & 0 deletions website.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ library
build-depends: base ^>= 4.12
, filepath ^>= 1.4
, hakyll ^>= 4.12
, hakyll-shortcut-links ^>= 0.0.0.0
, pandoc >= 2.6
, text

Expand Down

0 comments on commit 22d9621

Please sign in to comment.