/tech/ - Technology and Computing

Technology, computing, and related topics (like anime)

Reports of my death have been greatly overestimiste.

Still trying to get done with some IRL work, but should be able to update some stuff soon.


Max message length: 6144

Drag files to upload or
click here to select them

Maximum 5 files / Maximum size: 20.00 MB


(used to delete files and postings)

Open file (14.39 KB 711x512 haskell-logo.png)
Haskell general - see what other languages will introduce in 10 years Anonymous 09/14/2019 (Sat) 19:42:43 No.114
This thread is for make benefit glorious language of Haskell and functional programming in general. Discuss anything from newbie questions (what's a monad?) to advanced topics (what's a monad?) to category theory (what's a monad?) to your real-life haskell projects (>implying haskell is used outside academia) to what language features should be included in GHC9 to which IDE is best.

The hottest opinions: https://github.com/ghc-proposals/ghc-proposals/pulls?q=is%3Aopen+is%3Apr+no%3Alabel

Haskell for starters: http://learnyouahaskell.com/introduction#what-you-need
Hoogle: https://www.stackage.org/
Introduction to lenses: https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/a-little-lens-starter-tutorial

If you're past the Hello World phase, I highly recommend using stack to sandbox projects https://docs.haskellstack.org/en/stable/README/#quick-start-guide and install HIE for IDE integration (e.g. VS Code) https://github.com/haskell/haskell-ide-engine#user-content-installation . Where Hoogle beats any other form of documentation, HIE beats any autocomplete and checker, simply because Haskell has such a rich type system and GHC has features like typed holes.

Honorable mention to http://www.purescript.org/ for being basically Haskell but without a lot of legacy garbage and with row types. A huge downside is that it's not lazy.
Trying to wire my first program that tests for prime numbers starting at (2^82589933)-1 module Main where import Data.List import System.Environment main :: IO() factors :: Int -> [Int] factors n = [x|x <-[1..n], mod n x == 0] isPrime :: Int -> Bool isPrime n = factors == [1,n] p = 82589933 main = do if isPrime (2^(p))-1 == True then p else isPrime (2^(p+1))-1 I get this error after compiling in ghc with -o: primes.hs:12:24: error: • Couldn't match expected type ‘Int -> [Int]’ with actual type ‘[Int]’ • In the second argument of ‘(==)’, namely ‘[1, n]’ In the expression: factors == [1, n] In an equation for ‘isPrime’: isPrime n = factors == [1, n] | 12 | isPrime n = factors == [1,n] | ^^^^^ primes.hs:18:7: error: • Couldn't match expected type ‘IO ()’ with actual type ‘Bool’ • In the expression: isPrime (2 ^ (p + 1)) - 1 In a stmt of a 'do' block: if isPrime (2 ^ (p)) - 1 == True then p else isPrime (2 ^ (p + 1)) - 1 In the expression: do if isPrime (2 ^ (p)) - 1 == True then p else isPrime (2 ^ (p + 1)) - 1 | 18 | else isPrime (2^(p+1))-1 Wat do?
>>114 Thanks, I wanted to try out Purescript but forgot the name. If I get into webdev it's either with that or Elm or ClojureScript.
>>3018 Elm is breddy gud, I'm learning it now. Compared to some JS frameworks I've played with, it's very "on the rails" and forces you do do things its own way. It's not for everyone, but I'm liking it so far.
>>3017 10/10 made me reply without firing up ghc Interesting that it ignored the explicit types of factors and isPrime because you have the type of main all the way at the top. Put that type right before the actual definition of main and the type error should become clear: you need to print p and place your parens correctly. And print (isPrime (2^(p+1)-1)) if that's what you want. But if you want to print out all the cool Mersenne primes just use a list comprehension main = print [p | p<-[82589933..], isPrime (2^p-1)] and have fun heating your room with your epic primality test. Though, I bet you could find the first 9 Mersenne primes if you let it run for a couple of days. Also you need the arbitrary precision Integer instead of Int everywhere.
Anyone have a good 'advent of code' style list of problems that I can work off to learn haskell? It's been a couple years since I've touched it, but I'd like to get back into functional programming
>>3023 You can do an old AoC, although AoC is very much aimed at imperative languages. Other than that try project euler and kattis.
>>3025 >kattis Exactly what I was looking for, thanks m8.
if i learn haskell can i get a job and make 3 gorillion dollars a year?
>>3039 No, but you may be able to use it to virtue-signal your way into a position of temporary power in the coming pozfest during the coming collapse of the West. Elephant language is popular in academia (especially with a certain type of professor) after all. If you want gorillions then learn C++.
>>3039 If you have to ask it's a no. Most people who have learned Haskell out of interest enjoy a well-paid and satisfying job. And by learned I mean knowing how to build a useful program, not just knowing hello world, list comprehensions or >hurr durr monads are burritos. But don't despair, even if you only want to learn it to make 9 bajillion dollars, learning Haskell will help you become a better programmer by presenting you with approaches and abstractions that you could never imagine and can be applied in other languages too. And better programmers earn more.

Report/Delete/Moderation Forms

Captcha (required for reports)

no cookies?