cd /news/developer-tools/empty-list-without-list-literals · home topics developer-tools article
[ARTICLE · art-9158] src=discourse.haskell.org ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Empty list without list literals

The article describes a problem where the Haskell language extension `OverloadedLists` automatically transforms list literals like `[]` into `fromList []`, interfering with a rewrite rule for the `++` operator. The author presents a workaround by defining a custom `(+++)` function with an `INLINE` pragma to handle specific list cases, while expressing curiosity about alternative methods to specify a list as type `[a]` without using an explicit type signature.

read1 min views20 publishedMay 22, 2026

This is my situation. I want to make this rule: {-# RULES "++ 1 element" forall x xs. (x:[]) ++ xs = x:xs #-} However, I have OverloadedLists enabled, so this becomes. {-# RULES "++ 1 element" forall x xs. (x:(fromList [])) ++ xs = x:xs #-} Is there a way to avoid this automatic fromList ? Also, I’d like to be able to just say that a list is normal for readability. My soultion was to do this: Make a helper function special casing those situations and just inline that instead.

(+++) :: [a] -> [a] -> [a]
(+++) [] x = x
(+++) [a] x = a:x
(+++) xs ys = xs ++ ys
{-# INLINE (+++) #-}

But I’m still curious for a way to say that a list is of type [a] without using a type signature.

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/empty-list-without-l…] indexed:0 read:1min 2026-05-22 ·