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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:13:55+00:00 2026-05-16T16:13:55+00:00

I just started a new project and wanted to use HaskellDB in the beginning.

  • 0

I just started a new project and wanted to use HaskellDB in the beginning. I created a database with 2 columns:

create table sensor (
    service text,
    name text
);

..found out how to do the basic HaskellDB machinery (ohhh..the documentation) and wanted to do an insert. However, I wanted to do a partial insert (there are supposed to be more columns), something like:

insert into sensor (service) values ('myservice');

Translated into HaskellDB:

transaction db $ insert db SE.sensor (SE.service <<- (Just $ senService sensor))

But…that simply doesn’t work. What also does not work is if I specify the column names in different order, which is not exactly conenient as well. Is there a way to do a partial insert in haskelldb?

The error codes I get are – when I just inserted a different column (the ‘name’) as the first one:

Couldn't match expected type `SEI.Service'
       against inferred type `SEI.Name'
  Expected type: SEI.Intsensor
  Inferred type: Database.HaskellDB.HDBRec.RecCons
                   SEI.Name (Expr String) er
When using functional dependencies to combine
  Database.HaskellDB.Query.InsertRec
    (Database.HaskellDB.HDBRec.RecCons f (e a) r)
    (Database.HaskellDB.HDBRec.RecCons f (Expr a) er),
etc..

And when I do the ‘service’ as the first – and only – field, I get:

Couldn't match expected type `Database.HaskellDB.HDBRec.RecCons
                                SEI.Name
                                (Expr String)
                                (Database.HaskellDB.HDBRec.RecCons
                                   SEI.Time
                                   (Expr Int)
                                   (Database.HaskellDB.HDBRec.RecCons
                                      SEI.Intval (Expr Int) Database.HaskellDB.HDBRec.RecNil))'
       against inferred type `Database.HaskellDB.HDBRec.RecNil'

(I have a couple of other columns in the table)
This looks really like ‘by design’, unfortunately 🙁

  • 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-16T16:13:55+00:00Added an answer on May 16, 2026 at 4:13 pm

    You’re right, that does look intentional. The HaskellDB.Query docs show that insert has a type of:

    insert :: (ToPrimExprs r, ShowRecRow r, InsertRec r er) => Database -> Table er -> Record r -> IO ()
    

    In particular, the relation InsertRec r er must hold. That’s defined elsewhere by the recursive type program:

    InsertRec RecNil RecNil
    (InsertExpr e, InsertRec r er) => InsertRec (RecCons f (e a) r) (RecCons f (Expr a) er)
    

    The first line is the base case. The second line is an inductive case. It really does want to walk every element of er, the table. There’s no short-circuit, and no support for re-ordering. But in my own tests, I have seen this work, using _default:

    insQ db = insert db test_tbl1 (c1 <<- (Just 5) # c2 << _default)
    

    So if you want a partial insert, you can always say:

    insC1 db x = insert db test_tbl1 (c1 <<- (Just x) # c2 << _default)
    insC2 db x = insert db test_tbl2 (c1 << _default  # c2 <<- (Just x))
    

    I realize this isn’t everything you’re looking for. It looks like InsertRec can be re-written in the style of HList, to permit more generalization. That would be an excellent contribution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started a new Haskell project and wanted to set up a good
I just started using the new project type SQL Server 2008 Database. I can
Hi all I've just started a new project using Visual Web Developer 2008 Express
I started a Rails project recently and decided to use RESTful controllers. I created
We just started a new ASP.Net project that uses web services to serialize some
I just started to read about this new technology... Does someone have some knowledge
I know the topic I started is too subjective. But I just wanted some
I am a seasoned .NET / SQL Server developer. I just started a new
I just started doing some Javascript work for a project, I do mostly backend
I've just started a project and need a little push in the right direction.

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.