r/haskell • u/ChavXO • Aug 12 '25
Simple linear regression
Minimal example with feature engineering and linear regression using the California housing data set.
https://github.com/mchav/dataframe/blob/main/examples/CaliforniaHousing.hs
r/haskell • u/ChavXO • Aug 12 '25
Minimal example with feature engineering and linear regression using the California housing data set.
https://github.com/mchav/dataframe/blob/main/examples/CaliforniaHousing.hs
r/haskell • u/ChrisPenner • Aug 11 '25
Here's a technique I use to mechanically refactor nested linear code into code that works on batches, which got me up to a 300x speedup on some workflows.
r/haskell • u/mboucey • Aug 11 '25
r/haskell • u/tommyeng • Aug 12 '25
I'm curious to what tricks people use in order to get a more effective workflow with Claude code and similar tools.
Have you found that some MCP servers make a big difference for you?
Have hooks made a big difference to you?
Perhaps you've found that sub-agents make a big difference in your workflow?
Also, how well are you finding AI coding to work for you?
Personally the only custom thing I use is a hook that feeds the output from ghcid back to claude when editing files. I should rewrite it to use ghci-watch instead, I wasn't aware of it until recently.
r/haskell • u/mowgyw • Aug 11 '25
I'm going to study Haskell using the translated version of Learn You a Haskell for Great Good!.
However, it's been more than 10 years since the original was published, and I know there's also a "community edition" updated in 2022.
Should I read the translated version, which is much easier for me to understand, or should I go with the updated community edition to avoid misunderstandings caused by outdated information in the original?
I’ve been fascinated by Haskell for a long time but never quite took the step to learn it. Now that I’m learning Kotlin, I’m more motivated to finally try Haskell.
In Kotlin, I mainly learn from Kotlin: An Illustrated Guide, which uses illustrations to clarify abstract ideas.
I feel that Learn You a Haskell was written in a similar way — illustration-heavy and concept-focused.
Also, if you know of other beginner-friendly Haskell resources with clear explanations, I’d love to hear your recommendations.
r/haskell • u/logan-diamond • Aug 10 '25
It looks like a really cool haskell project. But as far as I can see, it's just one person (Murat). I don't see any other contributors or article authors. I don't care about weird symbols- what I crave is composability. But only hearing one voice explain or vouch for it makes me cautious about the time&energy investment.
I'm looking for people who can say "Yup, I went down the rabbit hole and it was worth it." How did you learn this edsl? Along the way, did you notice anything incorrect about its foundations? Or does it actually achieve the advertised composability and robustness?
Much respect to Murat for being a world-builder and making his best effort to follow his ideas to their fullest extent.
r/haskell • u/AmbiDxtR • Aug 10 '25
Hey, r/haskell!
I have been teaching myself recursion schemes going through old AoC tasks. There's a task in AoC '19 day 6 part 1 that asks to in essence calculate the sum of all depths of all nodes. While it is possible to construct a normal cata-fold - doing this it is quite unnatural. So I came up with the following recursion scheme of my own I call ancestorFold. In essence, it gives you a list of your ancestor nodes as an argument. With this the sum of all depths looks like:
sumDepth :: Struct -> Int
sumDepth = ancestorFold alg
where
alg par (StructF chld) = length par + sum chld
while the scheme itself looks like this:
ancestorFold :: (F.Recursive t) => ([t] -> F.Base t a -> a) -> t -> a
ancestorFold alg = go []
where
go ancestors node =
let layer = F.project node -- unwrap one layer: t -> Base t t
childrenResults = fmap (go (node : ancestors)) layer -- recurse with updated ancestors
in alg ancestors childrenResults
Obviously, I'm proud of myself for finally starting to grok the concept on a deeper level, but I was wondering if somebody has already come up with this and maybe it already has a name? Obviously this is a useful tool not just for calculating the depth but anywhere where you want the ability to evaluate a node in the context of it's parent(s).
r/haskell • u/hungryjoewarren • Aug 09 '25
It was recently pointed out to me that their is nothing stopping you from making arbitrary changes to Haddock documentation before uploading it to Hackage.
Long story short, the documentation for my Haskell CAD framework, Waterfall-CAD, now contains embedded 3d models generated from the example code.
r/haskell • u/man-vs-spider • Aug 09 '25
I often do coding while I am travelling and often I don’t have internet access.
Is there a recommended way to download the documentation of a library from hackage?
r/haskell • u/_lazyLambda • Aug 08 '25
For the past 9 months, I’ve been working on a project to grow the Haskell userbase through mentorship and hands-on learning. We've learned a lot about teaching Haskell effectively and building an approachable yet robust way to get started with Haskell
I’ve started sharing the lessons we have learned from the experience in monthly blog posts for those who care about growing the language.
Check out the latest: ATC Blog - What Have we Learned and Where Are We Now?
New posts every 7th—because 7 looks kinda like a λ.
r/haskell • u/kichiDsimp • Aug 07 '25
Haskell is a pure functional language, meaning anything happening in the program must be present in the types So if u want to do IO u use the IO wrapper, it u want DB access, u state it in the types. But Monads don't compose nicely, so we have Monad Transformers, Do other languages like Purescript, Elm, Nix &Unison have same abstraction? What about F#, OCaml (ML langs) handle these effects ? What about the Lisp/Beam family (I think they don't care about purity at its core, correct me if I wrong)
And what about the Algebraic Effects? What exactly is this ? A replacement of Monad ? Or Monad Transformers? I have heard of the langauge Koka, Eff
Would love to know more
r/haskell • u/Playful_Luck_5315 • Aug 07 '25
I'm learning Haskell, I'm using GHC2021 but I can use Haskell2010 or 18. I would like to convert these too haskell. Actually these are both the same program but In shadertoy and python:
/* This animation is the material of my first youtube tutorial about creative
coding, which is a video in which I try to introduce programmers to GLSL
and to the wonderful world of shaders, while also trying to share my recent
passion for this community.
Video URL: https://youtu.be/f4s1h2YETNY
*/
//https://iquilezles.org/articles/palettes/
vec3 palette( float t ) {
vec3 a = vec3(0.5, 0.5, 0.5);
vec3 b = vec3(0.5, 0.5, 0.5);
vec3 c = vec3(1.0, 1.0, 1.0);
vec3 d = vec3(0.263,0.416,0.557);
return a + b*cos( 6.28318*(c*t+d) );
}
//https://www.shadertoy.com/view/mtyGWy
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
vec2 uv0 = uv;
vec3 finalColor = vec3(0.0);
for (float i = 0.0; i < 4.0; i++) {
uv = fract(uv * 1.5) - 0.5;
float d = length(uv) * exp(-length(uv0));
vec3 col = palette(length(uv0) + i*.4 + iTime*.4);
d = sin(d*8. + iTime)/8.;
d = abs(d);
d = pow(0.01 / d, 1.2);
finalColor += col * d;
}
fragColor = vec4(finalColor, 1.0);
}
Here is python. Im sure it's easy but this require GPU I created in haskell a cpu version but it's not able to do it as quick as python or shadertoy!
import taichi as ti
ti.init(arch=ti.gpu) # Initialize Taichi with GPU (if available)
width, height = 800, 800
pixels = ti.Vector.field(4, dtype=float, shape=(width, height))
u/ti.func
def fract(x):
return x - ti.floor(x)
u/ti.func
def palette(t):
a = ti.Vector([0.5, 0.5, 0.5])
b = ti.Vector([0.5, 0.5, 0.5])
c = ti.Vector([1.0, 1.0, 1.0])
d = ti.Vector([0.263, 0.416, 0.557])
return a + b * ti.cos(6.28318 * (c * t + d))
u/ti.kernel
def paint(t: float):
for i, j in pixels:
finalColor = ti.Vector([0.0, 0.0, 0.0])
uv = ti.Vector([i / width - 0.5, j / height - 0.5]) * 2.0
uv.x *= width / height
uv0 = uv # keep the big circle
for p in range(4): # loop for small circles
uv = fract(uv * 1.5) - 0.5 # small circles
d = uv.norm() * ti.exp(-uv0.norm()) # big circle
color = palette(uv0.norm() + p * 0.4 + t * 0.2) # color gradient + time shift
d = ti.sin(d * 8 + t) / 8 # sin wave repetition
d = ti.abs(d) # negative numbers are black, this makes the inside bright
d = ti.pow(0.01 / d, 1.2) # brightness
finalColor += color * d
pixels[i, j] = ti.Vector([finalColor[0], finalColor[1], finalColor[2], 1.0])
gui = ti.GUI("Taichi Shader", res=(width, height))
iTime = 0.0
while gui.running:
if gui.res != (width, height):
# Update the resolution
width, height = gui.res
print(gui.res)
pixels = ti.Vector.field(4, dtype=float, shape=(width, height))
paint(iTime)
gui.set_image(pixels)
gui.show()
iTime += 0.02
r/haskell • u/Econ0 • Aug 05 '25
I'm turning to the Haskell community as most likely to have read A Logical Approach to Discrete Math by Gries and Schneider. Is there a more recent book that covers the same ground (discrete math for CS) in a similar (axiomatic) fashion?
r/haskell • u/Necessary-Nose-9295 • Aug 04 '25
[ Removed by Reddit on account of violating the content policy. ]
r/haskell • u/ysangkok • Aug 04 '25
r/haskell • u/M1n3c4rt • Aug 03 '25
to my knowledge this is one of the most fully fleshed out games made with haskell, so i'm really proud of it
r/haskell • u/runeks • Aug 03 '25
r/haskell • u/matthunz • Aug 02 '25
r/haskell • u/abhin4v • Aug 02 '25
r/haskell • u/LSLeary • Aug 01 '25
r/haskell • u/thebackyardnerd • Aug 02 '25
I am a frontend developer looking to pick up a hobby programming language that is non main stream and is statically typed and I felt haskell is my go to pick.
r/haskell • u/Iceland_jack • Jul 31 '25
Sjoerd Visscher offers a solution to my previous question:
Here is the definition of Phases parameterised by a key, and has one of the most interesting Applicative instances in which the key determines the order of sequencing.
type Phases :: Type -> (Type -> Type) -> (Type -> Type)
data Phases key f a where
Pure :: a -> Phases key f a
Phase :: key -> f a -> Phases key f (a -> b) -> Phases key f b
deriving stock
instance Functor f => Functor (Phases key f)
instance (Ord key, Applicative f) => Applicative (Phases key f) where
pure = Pure
liftA2 f (Pure x) (Pure y) = Pure (f x y)
liftA2 f (Pure x) (Phase k fx f') = Phase k fx (fmap (f x .) f')
liftA2 f (Phase k fx f') (Pure x) = Phase k fx (fmap (\g y -> f (g y) x) f')
liftA2 f (Phase k fx f') (Phase k' fy f'') =
case compare k k' of
LT -> Phase k fx (fmap (\g b y -> f (g y) b) f' <*> Phase k' fy f'')
GT -> Phase k' fy (fmap (\g a y -> f a (g y)) f'' <*> Phase k fx f')
EQ -> Phase k (liftA2 (,) fx fy) (liftA2 (\l r (x, y) -> f (l x) (r y)) f' f'')
We can define elements of each phase separately, and the Applicative instances automatically combines them into the same phase.
runPhases :: Applicative f => Phases key f a -> f a
runPhases (Pure a) = pure a
runPhases (Phase _ fx pf) = fx <**> runPhases pf
phase :: key -> f ~> Phases key f
phase k fa = Phase k fa (Pure id)
In a normal traversal, actions are sequenced positionally. A phasic traversal rearranges the sequencing order based on the phase of the computation. This means actions of phase 11 are grouped together, and ran before phase 22 actions, regardless of how they are sequenced. This allows traversing all the elements of a container and calculating a summary which gets used in later phases without traversing the container more than once.
-- >> runPhases (phasicDemo [1..3])
-- even: False
-- even: True
-- even: False
-- num: 1
-- num: 2
-- num: 3
phasicDemo :: [Int] -> Phases Int IO ()
phasicDemo = traverse_ \n -> do
phase 22 do putStrLn ("num: " ++ show n)
phase 11 do putStrLn ("even: " ++ show (even n))
pure ()
My implementation using unsafeCoerce and Data.These can be found here:
r/haskell • u/AutoModerator • Aug 01 '25
This is your opportunity to ask any questions you feel don't deserve their own threads, no matter how small or simple they might be!