Home - Vaclav Svejcar personal blog

Web Name: Home - Vaclav Svejcar personal blog

WebSite: http://www.svejcar.dev

ID:255647

Keywords:

Vaclav,Home,Svejcar,blog

Description:


Vaclav Svejcar

software developer

armcabalcatsfpfutureghcguidehackagehakyllhaskellmacosmetamonixpandocraspberrysassscalashapelessstacktravisvscode
Scala Cats How-To Guide
14 April 2020 catsfpguidescala Table of Contents1 How to…1.1 …correctly use imports from Cats?1.2 …compose two Future[Option[T]] values?1.3 …have Either that can contain also both values?1.4 …have Either that accumulates errors?1.5 …have type-safe equality check?1.6 …have type-safe non-empty list?1.7 …use Cats’ extension methods?1.8 …work with mapN and tuples

Cats is popular library for functional programming in Scala and in addition to great official documentation, there is a plethora of articles and blog posts describing this library in depth. I don’t really want to repeat myself, so I decided to give this blog post different approach, more like a how-to style, with set of common problems and how to solve them using Cats. I also won’t go in depth with explanations how used type classes and data types from Cats work, but instead I’ll put links to official documentation, which definitely will do better job :) I’ll also update this blog post in future if I’ll find next topics to add.

continue reading >
Uploading Package to Hackage
29 February 2020 cabalhackagehaskellstacktravis Table of Contents1 Prerequisities1.1 Project Configuration1.2 Version Bounds1.3 Haddock Documentation1.4 Setup CI2 Hackage User Account3 Upload to Hackage3.1 Package Candidate3.2 Publishing Package4 Summary

After few months I spent learning Haskell, I finally finished my very first real world Haskell project called Headroom. It’s basically a manager for license headers located in source code files (more about it in next blog post). When I reached some reasonable stability of the codebase, I decided it would be also nice to have it released on Hackage. I found the process not to be as straightforward as I expected, so I decided to sum up my experience in this blog post, both for future myself and for anyone else interested.

continue reading >
My VSCode setup for Haskell
1 January 2020 haskellmacosvscode Table of Contents1 Installation steps1.1 Stack - the build tool1.2 Syntax Highlighting1.3 Brittany - the code formatter1.4 HLint - the linter1.5 Haskell IDE Engine - the IDE experience2 Summary

When I started to learn Haskell, I hoped that I’ll be able to get similar IDE experience as I have with Scala and IntelliJ Idea. Unfortunately the opposite was true. There are some Haskell plugins for Idea, but none of them worked for me (mostly due to crashes or hangs) and they seem to be pretty immature as well. But I found pretty good feedback on using VSCode for Haskell development, so I tried it and with help of few extensions, you get pretty decent IDE-like experience with syntax highlighting, error reporting and code completion. In this blogpost, I’ll present my VSCode setup I use for (almost) everyday Haskell development.

continue reading >
Table of Contents in Hakyll
27 November 2019 hakyllhaskellmetapandoc Table of Contents1 Expected features2 Implementation2.1 Integration with Hakyll2.2 Enabling per blog post2.3 Adding stylesheets2.4 Making headings clickable3 Conclusion

It took me several attemps to run and actually maintain some kind of personal blog, so I’m happy I finally settled down on this one, based on Hakyll. Main reason why Hakyll was that I wanted to learn Haskell and best way for me to learn something new is to apply it for some real world use case. After publishing first few blog posts I realized that some are pretty long with many headings and having table of contents would definitely be helpful for readers.

So I spent some time searching best solution and found that Pandoc (library used by Hakyll to convert Markdown to HTML) already contains built-in support for this. In this blog post, I’ll show how to implement simple table of contents for blog posts, that can be easily customized to your specific needs. Because the below solution is the one I use for my blog, you can also check full source code to get details about imported modules, etc.

continue reading >
Troubles with Future
14 November 2019 fpfuturemonixscala Table of Contents1 What’s wrong with Future?1.1 Breaks referential transparency1.2 ExecutionContext everywhere1.3 Gotchas with for-comprehension2 Monix Task to the rescue2.1 Preserves referential transparency2.2 Scheduler needed only for evaluation2.3 Consistent behaviour with for-comprehension3 Conclusion

Anyone who works with Scala for a while probably used, or at least seen the Future class. Being part of the standard library, Future provides a way how to express asynchronous computation or value. It’s used by many and many popular Scala libraries, such as Apache Spark, Akka or Slick, and the use of Future itself is also pretty easy. But it also comes with some drawbacks, caused mainly by its design. This blog post summarizes the most common pitfals and introduces Monix Task as more powerful and robust alternative.

continue reading >
Extracting case class field names with Shapeless
22 October 2019 scalashapeless Table of Contents1 Before we start2 Naive implementation2.1 Attempt with Generic2.2 LabelledGeneric to the rescue2.3 Extracting field names3 Making things more generic4 Scala 2.13 and productElementNames

In my previous job, we were working on backend system that regularly fetched data from other services, both 3rd party and inhouse. These data were parsed and mapped into our internal data structure modelled with case classes. The fetching itself was usually done using some REST API and was mostly straightforward, except for one service, where we had to explicitly list all fields of given entity for which we wanted to fetch new data. This was done using REST call similar to this:

GET /entities/User?fields=id,name,surname

So based on the fact that this entity would be mapped in our backend as case class User, how can we get all its field names to build the above query? In this blog post, I’d like to share the simple solution, based on some generic derivation using Shapeless.

continue reading >
Using Sass with Hakyll
11 October 2019 hakyllhaskellmetasass Table of Contents1 Using hakyll-sass package1.1 Problems with hot reloading1.2 The solution

In last few years, CSS changed a lot. Many new features were added, such as Flexbox, Media Queries and animations, but other things, such as using some kind of variables or modules that would allow better organizing of source code are still not so great. This is where CSS preprocessors come into play. And since I always had great experience with Sass preprocessor, I decided to use if for this blog, written using Hakyll static site generator.

Unfortunately there’s no built-in support for Sass or any other CSS preprocessor in Hakyll, but adding it is pretty straightforward and doesn’t require much coding. In this blog post, I decided to sum up this process, both for future myself and for anyone else who’d try to solve the same problem.

continue reading >
Better 'toString' alternative for case classes
26 September 2019 catsscalashapeless Table of Contents1 Before we begin2 Using Show typeclass3 Automatic derivation of Show typeclass4 Changes in Scala 2.13

One of the great advantages of Scala’s case classes is that compared to regular classes, bunch of useful methods, such as equals, hashCode and toString, are automatically generated. The generated toString method is nice, because it includes actual field values of the displayed case class.

case class Test(name: String, value: Int) val test = Test("The Answer", 42)test.toString   // Test(The Answer,42)

The above output is good, but for case classes with many fields, nested structures or just lots of similar fields, it can become not so clear which value belongs to which field, as shown below:

case class Config(poolSize: Int, maxConnections: Int, batchSize: Int, intervalLength: Int, maxTimeout: Int) val config = Config(45, 23, 10, 10, 5000)config.toString // Config(45,23,10,10,5000)

Wouldn’t it help if we could also see field names for these values? In this article, I’ll show how this can be done without much boilerplate using Cats and Kittens libraries.

continue reading >
Haskell on Raspberry PI 4
23 September 2019 armghchaskellraspberrystack Table of Contents1 Before we begin2 Installation steps2.1 Increase SWAP size2.2 Install Stack2.3 Setup Stack project2.4 Solving troubles with GHC3 Enjoy

Last year, I purchased the Raspberry Pi 3B+ for some hobby projects. Shortly after I started to learn Haskell, I was wondering if I could build and run Haskell software on the ARMv7 platform. So I made some attempts with my Raspberry but quickly realized that despite being able to run compiled binaries, the 1GB or RAM is just not enough to build them using the GHC. So I gave it up for a while.

Then the Raspberry Pi 4B came out, with option to have up to 4GB of RAM. So I purchased the 4GB model and tried again. This time, with greatly increased available RAM size, I was able to make things working. You can find the entire process described in steps bellow.

continue reading >
Copyright © 2019-2020 Vaclav Svejcar
powered by hakyll
source code

TAGS:Vaclav Home Svejcar blog

<<< Thank you for your visit >>>

Websites to related :
Homepage - CZECH HOSPITALITY AND

  úvod | napište nám CZECH HOSPITALITY AND TOURISM PAPERSAbout Czech Hospitality and Tourism PapersSubmit paperArchivesEditorial BoardContactsAbout C

Homepage | BAST

   chevron_right Bast chevron_right Produkte chevron_right Technologische Möglichkeiten Unsere Partner Karriere Kontakte menuBast expand_more P

Масложировой б

  

Home - FIZ

  New. German Engineering.Willkommen im Frankfurter Innovationszentrum Biotechnologie.Geschäftsideen und -modellefür das digitale ZeitaltermehrBig-Dat

That&#39;s Livin

  "); } else { win._boomrl = function() { bootstrap(); }; if (win.addEventListener) { win.addEventListener("load", win._

Home | Sparrow Website

   :root{--color_0:255,255,255;--color_27:57,82,100;--color_1:255,255,255;--color_2:0,0,0;--color_3:237,28,36;--color_4:0,136,203;--color

Home - Pilakoutas Industrial

  .elementor-1231 .elementor-element.elementor-element-e7442c3 > .elementor-container{max-width:1400px;}.elementor-1231 .elementor-element.elementor-ele

X-Rite Home

  Skip to Store Area: Přeskočit na obsah Skip to Left Column Skip to Footer

Home - Cyprus Rejected

  info@cypool.netΣτείλτε μας email+357 22760751Κεντρικά Γραφεία, ΛευκωσίαΕΠΙΚΟΙΝΩΝΙΑΑΡΧΙΚΗΑΣΦΑΛΙ

Home - Paint & Coatings

  Paint & Coatings Italy25-10-2022 - 26-10-2022NH Milano Congress Centre, Strada 1, Milanofiori, 20057, Assago, MI, ItaliaMenu HomeEspositoriTechFocusLa

ads

Hot Websites