4 ms·
> Speaking from experience, zero. You can just treat them as syntax, like the largest proportion of every other language, but with the opportunity of actually b
by dmitriid 9y ago
> Speaking from experience, zero. You can just treat them as syntax, like the largest proportion of every other language, but with the opportunity of actually being able to write things like that yourself later.
So, basically, "learn this thing without understanding what it does" :-\
Reminds me of teaching Java to newbies: "oh, just type this syntax, you have to memorize it, don't worry about it".
> Definitely less than it takes to become comfortable with the quirks of literally everything in JS: perhaps you should give something an honest shot before telling people who have derived real-world benefits from using it in production that it's useless?
A real app is not just "hey, memorize this DSL and type it". I've found Haskell unapproachable on multiple occasions. And yes, I've completed my obligatory "Haskell from first principles" and "Learn You a Haskell for Great Good!" :)
- mrkgnao 9y agoWell, Servant isn't introductory Haskell material. My point was to show that the advanced type system features of modern Haskell are useful in the real world, for, e.g. building webapps that real people use and ship to production. If you've picked up the stuff in LYAH, you're ready to learn what type operators are (that's where :> and friends come from, they're just things like Maybe but written infix, so they're probably defined as data a :> b = ColonPointyThing a b or something like that.) Servant then pattern-matches on these types, essentially. For instance, if I can handle an API that serves endpoint A, and one that serves endpoint B, I can handle an API that serves both: instance (Handler A, Handler B) => Handler (A :<|> B) where handle req = ... That's the idea. You'd hardly expect a beginner to pick up, I dunno, using React and Redux on a Webpack hot-reloadable setup on day 1 of "Javascript 101", but React is one of the best ways to sell modern web development (at least when I've been buying).
- dmitriid 9y agoThe problem is basically how to arrive at the "same level" in Haskell and in JS. Basically: what does it take to define (or even to just understand) a type-level DSL in Haskell, and a sufficiently advanced library in Javascript. I can take apart almost any JS library and see/understand how it works. How much type-foo do I need to understand Servant? Or any other sufficiently complex Haskell library (a friend of mine has struggled mightily with Yesod and gave up after a month or so).
- mrkgnao 9y agoI'm pretty sure you'll be able to follow the Servant docs, which are quite nice: https://haskell-servant.readthedocs.io/en/stable/ https://haskell-servant.readthedocs.io/en/stable/ There are definite advantages, and if you're willing to put in as much work as one, say, unconsciously puts in while setting up JS frameworks, understanding libraries like this is definitely doable. (Without the dissertation.)
- dmitriid 9y agoThe docs are nice, but they complement the code :) Basically to actually understand what's going on, I'll need to learn DataKinds (at the very least). And just to implement something as simple as BasicAuth, this is what I have to start with (https://haskell-servant.readthedocs.io/en/stable/tutorial/Authentication.html https://haskell-servant.readthedocs.io/en/stable/tutorial/Au...): {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} You rarely need anything beyond regular JS to understand the inner workings of most libraries.
- mrkgnao 9y agoServant isn't the "simplest" way to get BasicAuth: you get what you pay for. You can just use one of the raw HTTP servers, like wai or something. They expose an interface not unlike the ones you'll find in, say, Go or C++ or Node or something. Also: {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} These extensions only serve to lift a couple of restrictions that the compiler imposes because the original Haskell Report did. DataKinds and TypeFamilies are the real "new ideas" that you need to pick up after a book at the level of LYAH to understand Servant.
- 9y ago
- codygman 9y ago>> Speaking from experience, zero. You can just treat them as syntax, like the largest proportion of every other language, but with the opportunity of actually being able to write things like that yourself later. > So, basically, "learn this thing without understanding what it does" :-\ > Reminds me of teaching Java to newbies: "oh, just type this syntax, you have to memorize it, don't worry about it". I don't think what's recommended is the same.
- dmitriid 9y agoLet's consider this quote: --- start quote --- > :> and :<|> You can just treat them as syntax, like the largest proportion of every other language, but with the opportunity of actually being able to write things like that yourself later. --- end quote --- This is exactly what's recommended: just blindly type these things, your understanding is not required. It becomes worse. Link: https://news.ycombinator.com/item?id=14890937 https://news.ycombinator.com/item?id=14890937 You need 10 language extensions to implement the simples things. Answer to that complain? Oh, five of them are just workarounds [so, just blindly copy-paste them]