5 ms·
Learn Haskell by building a blog generator – a project-oriented Haskell book
- ypeterholmes 4y agoFor anyone that does decide to learn Haskell, you can easily get a job afterwards working on the Cardano blockchain. Smart contract devs are in high demand, and Cardano uses a variant of Haskell that is relatively unique to the space.
- punkbit 4y agoI've been following for at least a year and find that the jobs pay is very low in comparison to Rust; or Solidity. I also don't see much jobs available. Where do you see those job listings?
- danuker 4y agoHow you would write tests in a real project? I suppose it's not writing out the entire program and then writing the tests, as seems to be implied. That would mean a lot of manual testing. Or is there a Haskell REPL where you can try out small pieces before saving them?
- jose_zap 4y agoYes, there is GHCi, the Haskell interpreter and repl comes bundled with the compiler. You can load your entire project in the repl and try your functions there.
- gilmi 4y agoWhen you create a project description for your project (for the package manager) you can define a library, executables and test suites. In the test suite you write your tests against the library. You can do that at any stage, even before writing a line of library code. But yes, Haskell also has a REPL that can be used to experiment with code.
- rowanG077 4y agoYou have testing libraries in Haskell just like in every other languages. For example: https://hackage.haskell.org/package/tasty https://hackage.haskell.org/package/tasty
- jokethrowaway 4y agoHUnit is a popular choice: https://mmhaskell.com/testing/test-driven-development https://mmhaskell.com/testing/test-driven-development
- lgas 4y agoIn addition to the other good answers you've gotten, I would like to point out that Haskell has QuickCheck (https://hackage.haskell.org/package/QuickCheck https://hackage.haskell.org/package/QuickCheck) which, if I'm not mistaken, more or less pioneered property testing. Property testing libraries are available in many languages now but they never seem to be as capture the magic of QuickCheck. (There's also https://hackage.haskell.org/package/hedgehog https://hackage.haskell.org/package/hedgehog which is sort of a "modern alternative" to QuickCheck but I still prefer the OG).
- _query 4y agoIf you want to do web development with Haskell beyond building a blog generator, a good starting point is IHP (https://ihp.digitallyinduced.com/ https://ihp.digitallyinduced.com/ https://github.com/digitallyinduced/ihp https://github.com/digitallyinduced/ihp). IHP is Haskell's version of Laravel/Rails/Django. It's really a superpower to have Haskell's type system combined with the rapid development approach of Rails :) (Disclaimer: I'm founder of the company that makes IHP)
- froza 4y agoI was tempted to try it, but then I saw that some core features (like mysql) are for paid versions only so its a big red flag already
- _query 4y agoMysql support is not implemented at the moment. If there's someone paying for the development we could have it. You're of course also free to contribute it yourself to the open source version, then it wouldn't need to be part of the commercial version. Some more background on why IHP has a paid variant can be found here: https://ihp.digitallyinduced.com/blog/6392ad84-e96a-46ce-9ab5-1d9523d48b23-announcing-the-new-ihp-developer-subscription-ihp-v0-14 https://ihp.digitallyinduced.com/blog/6392ad84-e96a-46ce-9ab...
- rowanG077 4y agoI don't get it. How can it be part of the commercial version if it is not implemented.
- prophesi 4y agoNot OP, but it sounds like MySQL support isn't out yet. So I think the business plan can help them get paid to implement it. No clue if that means the FOSS version would receive those upstream changes once it's done.
- cultofmetatron 4y ago
- alephnan 4y agoIs the website/book/blog self-hosting? https://en.wikipedia.org/wiki/Self-hosting_(compilers) https://en.wikipedia.org/wiki/Self-hosting_(compilers)
- gilmi 4y agoNo. It is built with mdbook[0]. [0]: https://rust-lang.github.io/mdBook https://rust-lang.github.io/mdBook
- matijash 4y agoThis is really cool! I've been looking for something like for a while - my learning path was through LYAH and Real-World Haskell (also tried Haskell from the first principles but a bit too extensive IMO). I think this would fit in perfectly between LYAH and RWH. I am using Haskell mostly for writing compilers (https://github.com/wasp-lang/wasp https://github.com/wasp-lang/wasp currently), but I believe if the tutorial isn't using a lot of specialized libraries/frameworks (which seems to be the case from the first glance), a majority of the material taught should be transferable to any domain.
- gilmi 4y agoThanks!
- hans1729 4y agoAt first sight I’ve read “an object-oriented Haskell book”. [brief pause for contemplating the thought] Naturally, someone went there: https://www.parsonsmatt.org/tutorials/ https://www.parsonsmatt.org/tutorials/
- greymalik 4y agoThe linked articles are actually about how to translate problems from an OOP perspective into idiomatic Haskell.
- cosmic_quanta 4y agoThat's the perfect learning project because there's something tangible at the end. Whenever the question of "How do I learn Haskell" comes up, I always suggest to come up with a project that would be useful on its own, regardless of the technology used to create it, and use Haskell to do it. In my case it was a pandoc filter to embed plots in documents (https://github.com/LaurentRDC/pandoc-plot https://github.com/LaurentRDC/pandoc-plot), which was ultimately useful to create my PhD dissertation. There's only so much you can learn about Haskell by working through toy examples.
- cholantesh 4y agoGreat project; I'd have loved to have had it when I was writing my dissertation - hell, I'd have liked anything that would have let me write it in vim and just generate the final submission per the university's format, because I hate Word.
- zeckalpha 4y agoI have found Hakyll to be useful in this space, if you want to move from building your own to configuring/extending your own.
- Iceland_jack 4y agoOh this looks fun getStructureString and render can be defined as record selectors newtype Structure = Structure { getStructureString :: String } newtype Html = Html { render :: String } BlockArguments let you write expressions like myhtml myhtml :: Html myhtml = html_ "My title" ( append_ (h1_ "Heading") ( append_ (p_ "Paragraph #1") (p_ "Paragraph #2") ) ) in a more domain-specific style. De gustibus, but some may prefer it to the parentheses. {-# Language BlockArguments #-} myhtml :: Html myhtml = html_ "My title" do append_ do h1_ "Heading" do append_ do p_ "Paragraph #1" do p_ "Paragraph #2" or using the associativity of append_ = (<>) myhtml = html_ "My title" do h1_ "Heading" <> p_ "Paragraph #1" <> p_ "Paragraph #2" myhtml = html_ "My title" do mconcat [ h1_ "Heading" , p_ "Paragraph #1" , p_ "Paragraph #2" ] All examples of 'concat . map' can be replaced with.. concatMap :Ð
- Iceland_jack 4y agoInstead of defining append_ for structure newtype Structure = Structure String append_ :: Structure -> Structure -> Structure append_ (Structure c1) (Structure c2) = Structure (c1 <> c2) empty_ :: Structure empty_ = Structure "" the <> operator (from Semigroup) can be reused by deriving it via the underlying String type (edit: I see this is suggested later in the tutorial). {-# Language DerivingStrategies #-} {-# Language GeneralizedNewtypeDeriving #-} newtype Structure = Structure String deriving newtype (Semigroup, Monoid) append_ :: Structure -> Structure -> Structure append_ = (<>) empty_ :: Structure empty_ = mempty Semigroup and Monoid let us use a lot of standard vocabulary concatStructure :: [Structure] -> Structure concatStructure list = case list of [] -> empty_ x : xs -> x <> concatStructure xs becomes concatStructure :: [Structure] -> Structure concatStructure = mconcat or concatStructure = fold Also in the detour about kinds they are written as * while the ecosystem is moving towards a more uniform Type name. {-# Language StandaloneKindSignatures #-} import Data.Kind (Type) type Tuple :: Type -> Type -> Type data Tuple a b = Tuple a b type Either :: Type -> Type -> Type data Either a b = Left a | Right b
- 4y ago
- newaccount2021 4y ago
- bwanab 4y agoIf you’re more inclined to visual and/or musical arts, I’d recommend “Th Haskell School Of Expression” by Paul Hudak. He guides you through the language and the techniques with an eye for concise, expressive code that has good runtime characteristics.
- mbrodersen 4y agoKudos to the author. The best way to teach something is to start with a foundation of nothing and then step by step building layers of understanding on top of it. Most other Haskell tutorials fail to do this.
- gilmi 4y agoThank you!