Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6337795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:19:11+00:00 2026-05-24T19:19:11+00:00

So I was playing around with defining a TrieSet datatype (even though I know

  • 0

So I was playing around with defining a TrieSet datatype (even though I know I don’t need to):

module Temp where

import Data.Map

data TrieSet a = Nonterminal (Data.Map a (TrieSet a)) | Terminal (Data.Map a (TrieSet a))

insert :: Ord a => [a] -> TrieSet a -> TrieSet a
insert [] (_ m) = Terminal m
insert (a:as) (c m) = c $ insertWith (insert as . flip const) a (insert as $ Nonterminal empty) m

When I got an error I’ve never seen before:

% ghc -c Temp.hs
Temp.hs:8:11: Parse error in pattern

So it seemed like GHC doesn’t like matching multiple unary constructors with the same pattern.
I did another test to make sure that was the problem:

module Temp2 where

extract :: Either String String -> String
extract (_ s) = s

Which seemed to confirm my suspicion:

% ghc -c Temp2.hs
Temp2.hs:4:9: Parse error in pattern

So my question is (in multiple parts):

  1. Am I right about why GHC doesn’t like these functions?
  2. Any reason why this wouldn’t be a part of the Haskell standard? After all, we can match multiple nullary constructors with the same pattern.
  3. Is there a LANGUAGE pragma I can give GHC to make it accept these?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:19:11+00:00Added an answer on May 24, 2026 at 7:19 pm
    1. Yes. That kind of wildcards was never supported.
    2. In my opinion, it would be much more difficult to infer a function’s type if you don’t know the data-constructor that was matched on. Just think about a function f (_ n) = n. What should be its type? The type-system of Haskell has no way to describe the arity of a type’s constructors, so a function like f could not exist.
    3. I don’t think so.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
I've been playing around with Simple.Data and have run across something that I can't
Playing around with Google Maps these days, with some directions. I have a map
Hi I have been playing around with MDX and need some very high-level getting-started
Playing around with Python - tkInter - Entry widget - when I use validatecommand
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
Just playing around with the now released Silverlight 2.0. I'm trying to put a
While playing around with regexps in Scala I wrote something like this: scala> val
been playing around with ResolveClientUrl(~/Confirmation.aspx) and other methods.. I am tryin go get the
I playing around with the Twitter API for my BlackBerry application. Is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.