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 6743521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:58:14+00:00 2026-05-26T11:58:14+00:00

Apologies for another question, I think I shall re-phrase my original question here as

  • 0

Apologies for another question, I think I shall re-phrase my original question here as this is probably a pretty simple thing to do:

If i had a language which i wanted to create, like so:

A B <something> C

this would mean only an input like: A B …. C would be valid.

In contrast, B A ….. would not be valid.

Is there any easy way to define a constructor such as ‘B’ must always occur after ‘A’? I have only ever seen the A | B type of constructor ‘A or B’

  • 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-26T11:58:15+00:00Added an answer on May 26, 2026 at 11:58 am

    Like so?

    -- file Temp.hs
    module Temp where
    data C = C1 | C2 | C3
    data B = B1 Int | B2 String | B3
    data A a = MkA B a C
    

    This compiles fine with ghc -c Temp.hs – you can’t use data statements in ghci, that’s one of the limitations of ghci.

    So, here I’m defining three data types:

    • C, which has three constructors which take no arguments: C1, C2, and C3. Each of these is a value of type C
    • B, which has constructors
      • B1 which wraps a Int value, so B1 3 and B1 544 are values of type B
      • B2 which wraps a String value, so B2 "hello" and B2 "world" are values of type B
      • B3 is a simple argument-less constructor, so B3 is a value of type B.
    • A a which is a polymorphic data type – for every type a, A a is also a data type. It has one constructor, MkA which takes
      • a value of type B
      • value of type a
      • and a value of type C

      and creates a value of type A a. So, for instance

      • MkA B3 True C1 is of type A Bool
      • MkA (B1 30) "Foo" C3 is of type A String
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My apologies if this was answered in another question, I could not find an
I don't think this is not another resize iframe according to content height question.
Apologies for another question on a similar topic, but I'm inexperienced at this level
Not sure what to search for here, so apologies if I'm repeating another question.
My apologies if this is just another question that gets asked over and over.
If I've missed this in another question I apologize; I looked for a good
Apologies if this is too ignorant a question or has been asked before. A
Apologies if this question is a bit obscure, I've been banging my head against
Apologies for asking what's probably a very obvious question, I've been banging my head
Apologies if this is a dumb question. In previous ASP.NET projects, I've been using

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.