{"slug": "empty-list-without-list-literals", "title": "Empty list without list literals", "summary": "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.", "body_md": "This is my situation.\nI want to make this rule:\n{-# RULES \"++ 1 element\" forall x xs. (x:[]) ++ xs = x:xs #-}\nHowever, I have OverloadedLists\nenabled, so this becomes.\n{-# RULES \"++ 1 element\" forall x xs. (x:(fromList [])) ++ xs = x:xs #-}\nIs there a way to avoid this automatic fromList\n? Also, I’d like to be able to just say that a list is normal for readability.\nMy soultion was to do this:\nMake a helper function special casing those situations and just inline that instead.\n(+++) :: [a] -> [a] -> [a]\n(+++) [] x = x\n(+++) [a] x = a:x\n(+++) xs ys = xs ++ ys\n{-# INLINE (+++) #-}\nBut I’m still curious for a way to say that a list is of type [a] without using a type signature.", "url": "https://wpnews.pro/news/empty-list-without-list-literals", "canonical_source": "https://discourse.haskell.org/t/empty-list-without-list-literals/14147#post_3", "published_at": "2026-05-22 14:02:18+00:00", "updated_at": "2026-05-22 14:43:56.264159+00:00", "lang": "en", "topics": ["developer-tools"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/empty-list-without-list-literals", "markdown": "https://wpnews.pro/news/empty-list-without-list-literals.md", "text": "https://wpnews.pro/news/empty-list-without-list-literals.txt", "jsonld": "https://wpnews.pro/news/empty-list-without-list-literals.jsonld"}}