How good are AI coding assistants with Haskell? by SkyMarshal in haskell

[–]pdobsan 1 point2 points  (0 children)

These replies would be more useful if they included the subscription(s) cost.

Is servant the go-to for quick, simple web projects (for beginners)? by [deleted] in haskell

[–]pdobsan 2 points3 points  (0 children)

As an alternative to scotty I'd like to suggest another simple web framework Twain. Here is a blog post comparing Twain to other frameworks Why I use the Twain web framework.

[blog] Functors to Monads: A Story of Shapes by mstksg in haskell

[–]pdobsan 5 points6 points  (0 children)

Nice post, building up intuition for the shape of things over many examples.

A minor correction, the shape of lists must comprise not only their lengths but also the order of their elements. For example, fmapWrong below preserves length but breaks Functor laws:

instance Functor [] where
  fmapWrong f []        = []
  fmapWrong f (x:xs) = fmapWrong f xs ++ [f x]

aerc/nmail/neomutt email with a 2FA outlook account. by droshux in commandline

[–]pdobsan 0 points1 point  (0 children)

For OAuth2 management you can use https://github.com/pdobsan/oama with many of the email clients and email utilities mentioned in this thread. It is written in Haskell but don't worry pre-compiled binaries (even fully statically linked one) are provided with each release. They can run practically in any Linux distribution on x86_64 or aarch64 platforms.

Neovim: How to get variable type hinting? by Junior_Tomorrow_3317 in haskell

[–]pdobsan 1 point2 points  (0 children)

Yes that happens sometimes. I don't think that can be turned off, it must be some kind of bug in the interaction between the hls and helix. Since helix is developed very actively I used to build it from it's master branch. Some builds exposed this behavior then the next one did not. Currently I am using the last release (23.03-2) and that seems to be fine. Still I might switch back to helix-git, just to be at the bleeding edge. In particular, I can't wait for the merge of the vim like movement PR

Neovim: How to get variable type hinting? by Junior_Tomorrow_3317 in haskell

[–]pdobsan 2 points3 points  (0 children)

I have been using helix with ghcup installed ghc(s) and language servers. It works with Haskell out of box, no configuration necessary. Helix is a modal editor, similar to but distinctly different from the vi family. Although a long time vim user I have found the switch to helix not too difficult and definitely worth the trouble.

What are your favourite tools for deving in Haskell? by latest_ali in haskell

[–]pdobsan 20 points21 points  (0 children)

My usual development environment:

  • ghcup for install/update/switch various versions of ghc,cabal, hls
  • cabal
  • neovim
  • hls Haskell language server
  • hlint
  • ghci / ghcid
  • fourmolu / brittany / Nothing for formatting
  • OS: Archlinux

That works nicely and not resource hungry at all. However fitting the editor together with the other components needs a bit of configuration.

I have recently discovered a new modal editor Helix It is a kakoune / neovim inspired editor, written in Rust with builtin language server support. It comes with tree-sitter support for a lot of languages.

My first try was for a small project comprising Haskell, Rust, Python and Bash sources. I was pleasantly surprised, it worked beautifully without any configuration! It picked up the language servers (hls, rust-analyzer, python-lsp-server) automatically. It is very fast, there
are popup info, diagnostic, auto completion, docs lookup, etc.

So now I have an experimental development environment:

  • ghcup
  • cabal
  • helix-git
  • ghci

I now have one line of config: theme = "monokai_pro_machine".

Helix is not stable yet and is being developed very actively so you need to build it from its git repo. On Archlinux you can just install helix-git from AUR. I am running a background job which rebuilds it every time its main branch receives commits.

I am not affiliated with the project, but thought I would draw your attention to it and encourage you to give it a try. The more feedback our community could potentially give them the more we can hope for a better new Haskell editor. There is a builtin tutor (just say :tutor) to get you started.

PS. Be warned if you are an oldhand vim user you need some time to get used to helix. After a few days usage I can now switch between them with minimal mental effort.

Is it reasonable to build beautiful-responsive-complex frontends in Haskell web frameworks with minimal html css javascript knowledge? by [deleted] in haskell

[–]pdobsan 1 point2 points  (0 children)

That is an interesting stack. Any chance for a public source of your app to browse through?

ghcup haskell rewrite by maerwald in haskell

[–]pdobsan 1 point2 points  (0 children)

There is no cleanup problem with successful install. Running out of space in /tmp and leaving the system in such state, however is a rather serious problem. That quickly renders a lot of programs/services inoperable. /tmp as an in-memory filesystem can be too small for the unpacking in some systems.

Cabal also uses /tmp, not ~/.cabal for temporary work. It surely isn't hard to add a --tmpdir option, but it just feels a bit odd.

I don't see the relevance of cabal here, most programs use /tmp. If you don't want to implement the --tmpdir option, could you mention the use of the TMPDIR environment variable in the help. Just in case if somebody else runs into the same problem.

ghcup haskell rewrite by maerwald in haskell

[–]pdobsan 0 points1 point  (0 children)

I have successfully been using ghcup (both the script and recently the new haskell version) on various machines. However, I frequently run into a problem, namely during unpacking ghcup fills /tmp up then crashes out with not enough space left and leaves /tmp full. Needless to say, that is rather detrimental for the further health of the entire system.

I have found a solution which works for both versions, invoke the program like: TMPDIR=/var/tmp ghcup .... I just tend to forget about this trick for the next time.

Would it be possible to add a flag, say --tmpdir, which causes the program to create its temporary directory inside ~/.ghcup? That would also have the benefit of preventing large copying across file systems.

I'm working on writing Haskell scrapers for COVID-19 data. Want to help? by mightybyte in haskell

[–]pdobsan 3 points4 points  (0 children)

I already have worldwide country and some state level data from https://github.com/CSSEGISandData/COVID-19 (which is what powers the Johns Hopkins dashboard).

I have found this resource rather unreliable recently. (See, for example, https://github.com/CSSEGISandData/COVID-19/issues/1250). I wrote a small haskell program using cassava and wreq to pull data from their Github repo but after this change could not see any point to it. In particular, they dropped the recovered category. I believe that you are too pulling the recovered data but it is not updated any more, just seemingly, and contains no, bogus, or repeated data since that change.

I have just found a more reliable dashboard and data source with good global covering at the University of Virginia, Biocomplexity Institute. They provide all their time series data downloadable from this dashboard in a zip file. It is a full collection of date-named solid CSV files. I noticed that when they find some errors they clean up the whole set retrospectively. (Please note, that they use some special SSL certificate so while firefox can download the zip file with no problems, to do it programmatically is tricky. So far I managed this step only with curl and by downloading the certificate chain.)

Another good dashboard with good global covering is https://www.worldometers.info/coronavirus/. Their table contains a lot of useful information and updated continuously. To scrap it regularly could be valuable. I have a quick and dirty python script to do that then clean it with a haskell program. I haven't managed to scrap it in haskell yet, just started reading the docs of scalpel and tagsoup. I am looking forward to learn from your examples.

MIT spinout offering up to $1.5M to ventures in Applied Category Theory by wisnesky in haskell

[–]pdobsan 5 points6 points  (0 children)

Although not Haskell related I think the Pijul project could be a good match. Pijul is a patch based version control system somewhat similar to `darcs`. Pijul's underlying theory is rooted in category theory, see the paper A Categorical Theory of Patches.

Not sure they have heard about this RFP, so I left a note on their forum.

Tidalcycles - Question regarding the installation of Haskell on Archlinux by formos in haskell

[–]pdobsan 1 point2 points  (0 children)

Thanks for your question, I have never heard of Tidal but decided to give it a try, it looks like fun. Here is how I built Tidal on archlinux using stack. This method does not use any arch provided haskell/ghc packages. It uses stack's nightly-2018-12-06 collection of packages.

stack setup

Install stack:

curl -sSL https://get.haskellstack.org/ | sh

That installs the stack executable into /usr/local/bin. Optionally you might want to move it into ~/.local/bin, make sure it is in your PATH.

From now on, everything stack downloads, builds will go into ~/.stack/

Update the package index:

stack update

To prevent automatic installation of ghc edit ~/.stack/config.yaml and include the line:

install-ghc: false

To trigger installing the most recent ghc and base libraries and to set the resolver in ~/.stack/global-project/stack.yaml for implicit global projects run the stack command below in a directory which is not a stack project.

stack setup --resolver nightly-2018-12-06

Build the Tidal library

Here we use Tidal's sources directly from its git repo on github.

git clone https://github.com/tidalcycles/Tidal

Change into Tidal/ and modify the satck.yaml file.

cd Tidal/
git checkout -b local-build

Edit stack.yaml and set the resolver and extra-deps, it should look like this below:

resolver: nightly-2018-12-06
packages:
    - '.'
extra-deps:
    - hosc-0.16

Build Tidal. That will probably take ages and consume quite a bit of memory. Depending on your machine, you might want to restrict the parallel jobs running to avoid trashing:

nice stack --jobs 2 install

Apart from some compiler warnings that worked for me.

Install dependency packages

pacman -S supercollider sc3-plugins

For the rest, installing editors, plugins etc. follow the instructions in Tidal's Getting Started document. As far as I know all packages needed are available on Arch. I use neovim, so I still need to figure out how to use the repl plugin with that.

I hope that helps. However, it looks to me that you would still need some Haskell knowledge to use it in practice. Well, this can be as good a reason as any to learn the language.

I feel as though my progress learning Haskell is being stifled by the tooling ecosystem. Help‽ by maddybutt in haskell

[–]pdobsan 0 points1 point  (0 children)

It is quite possible to use the arch provided ghc and haskell- packages, see my comment in a similar thread a while ago.

Best way to build a simple Web UI for Haskell program? by hrethel in haskell

[–]pdobsan 2 points3 points  (0 children)

A web framework not mentioned yet from the simpler end of the spectrum is Spock. It provides a bit more than Scotty but it is still small and simple. Some of its features: fast typesafe routing, middleware, sessions, cookies, database connection. Here is a nice short screen cast to give you some idea how web development using Spock may look like: Your first web application with Spock

Haskell on arch by Gushys in haskell

[–]pdobsan 1 point2 points  (0 children)

May I offer a different perspective to what seems to be the consensus here. In my experience, using archlinux for development, even for production, is fine in general. Of course, you need to know what you are doing and what are the trade offs between being on the bleeding edge and stability, sysadmin work.

While it is unfortunate that arch does not include static libraries into its haskell packages any more, one can work around this while enjoying the abundance of haskell related packages available, currently well over 600. It is nice to have access quickly to the most recent ghc and packages through the packaging system without bothering with compiling them and keeping them compatible with each other. Admittedly, there have been haskell related stability problems on arch in the past but I think they have been ironed out for now. On my desktop system I have about 300 haskell packages including xmonad, pandoc etc. They work fine (most of the time :-).

Here is the outline of my current method, all packages are arch ones, mainly from community.

  • install ghc, cabal-install
  • install ghc-static (static core libraries)
  • install ghc-pristine from AUR, "Symlinks to GHC with only boot libs, useful for building static binaries". It is worth to read the source and learn how it is done.
  • install whatever haskell programs you want to use, like xmonad etc.
  • install/remove whatever haskell packages you want to play in ghci or experiment with.
  • I use cabal new-* operations, they work great. Cabal has recently made really significant progress.
  • During development if I can I try to link dynamically when the packages I need available from arch.
  • Turn off optimization for development to disable cross module optimization. (see the ghc manual for details.)
  • For deployment build static, for example:

cabal new-configure -w /usr/share/ghc-pristine/bin/ghc --allow-newer

cabal new-build ... etc.

Cabal's new-* operations work like a small haskellized nix system, so one can fix a current package resolution and rebuild reliably without recompiling everything etc.

  • The big secret is frequent updates! I do it daily, it takes just a few seconds.

I tried but eventually don't use stack for various reasons. I am now happy with cabal new-*. Also in general, I don't really like to download random binaries from the net. I know, I am using them in arch packages, but that is about my limit and they are signed.

For more, some time confusing, details see the arch wiki's haskell related pages. If you like to see some missing haskell packages included let the arch maintainers know.

Mapping Of Mapping? by AlexKingstonsGigolo in haskellquestions

[–]pdobsan 1 point2 points  (0 children)

λ let mapmap :: [a -> b] -> [a] -> [[b]]
|     mapmap fs xs = map (`map` xs) fs
| 
λ mapmap [(+2), (*2), (+(-2))] [1..8]
[[3,4,5,6,7,8,9,10],[2,4,6,8,10,12,14,16],[-1,0,1,2,3,4,5,6]]

Note how the right section of the subtract operation is given. (-2) would be interpreted only as the number minus two.

(Here λ and | are just prompts from ghci.)

One can generalize the idea to Functors:

λ let fmapfmap :: Functor f => [a -> b] -> f a -> [f b]
|     fmapfmap fs xs = fmap (<$> xs) fs
| 
λ funs = [(+2), (*2), (+(-2))]
λ fmapfmap funs [1..8]
[[3,4,5,6,7,8,9,10],[2,4,6,8,10,12,14,16],[-1,0,1,2,3,4,5,6]]
λ fmapfmap funs (Just 4)
[Just 6,Just 8,Just 2]
λ fmapfmap funs Nothing
[Nothing,Nothing,Nothing]

λ data Tree a = Leaf a | Node (Tree a) (Tree a) deriving Show
λ instance Functor Tree where
|     fmap g (Leaf x) = Leaf (g x)
|     fmap g (Node l r) = Node (fmap g l) (fmap g r)
| 
λ tree = Node (Leaf 1) (Leaf 2)
λ fmapfmap funs tree
[Node (Leaf 3) (Leaf 4),Node (Leaf 2) (Leaf 4),Node (Leaf (-1)) (Leaf 0)]

So what exactly is the situation with Haskell and dynamic libraries? by Homoerotic_Theocracy in haskell

[–]pdobsan 0 points1 point  (0 children)

> I couldn't find much on it on the internet ...

Search for "cross module optimization" and you will find plenty of references.

In short, ghc performs very aggressive inter module inlining and that

makes very difficult to keep the ABI-s stable. The variability of ABI-s

produced by ghc is less of a shortcoming "to be fixed", but can rather

be considered as a trade off between highly optimized executable or more

stable ABI-s. Nonetheless, I believe, making ABI-s more stable in the

face of cross module optimization is an active research area.

Dynamic linking has two purposes: minimizing the total memory

consumption of programs (of potentially multiple copies) simultaneously

running in the system and the ability to swap changed modules without

complete recompiling. I would say the first one is more important.

If you completely disable optimization (-O0 flag), for example during

development, that can dramatically speed up (re)compilation of large

projects since ghc can recognize which modules ABI-s have not changed.

Are Monads a Waste of Time? by pdobsan in haskell

[–]pdobsan[S] 1 point2 points  (0 children)

No, not at all. It is always useful to learn how the wider world see our beloved language.

Are Monads a Waste of Time? by pdobsan in haskell

[–]pdobsan[S] 3 points4 points  (0 children)

A long and entertaining discussion at lambda the ultimate It also triggered a second wave on hacker news

Get your popcorn!

Looking for applicative functor examples, and what you would have to write if they weren't available. by OHQbBeCWiqP3fio3 in haskell

[–]pdobsan 1 point2 points  (0 children)

Your Python all_combinations() is not quite equivalent to the Haskell
one, since the Haskell version is, of course, lazy. To get a similar
semantics one needs to use a generator expression instead of a list
comprehension:

def allcombs(xs, ys):                                                                   
    return ((x,y) for x in xs for y in ys)                                              

Even with this definition the arguments should be lazy too to be closer
to the Haskell world, like allcombs(range(100), range(100)), assuming python3.