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

  • Home
  • SEARCH
  • 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 951511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:44:50+00:00 2026-05-15T23:44:50+00:00

In my application I need to serialize a vector containing an arbitrary datatype, in

  • 0

In my application I need to serialize a vector containing an arbitrary datatype, in this case is a list of Doubles. For serializing the vector I’m importing Data.Vector.Binary.

When loading the module in GHCi the following error arises:

Overlapping instances for Binary [Double]
  arising from a use of `decode' at Statistics.hs:57:33-42
Matching instances:
  instance (Data.Vector.Generic.Base.Vector v a, Binary a) =>
           Binary (v a)
    -- Defined in Data.Vector.Binary
  instance (Binary a) => Binary [a] -- Defined in Data.Binary

Is the list an instance of Vector?
I looked through the documentation but could not find such instance.

What can I do to be able to serialize this structure?

Edit:

I’m using the following package versions:

  • vector-0.6.0.2
  • vector-binary-instances-0.1.2
  • binary-0.5.0.2

Also here is a snippet that shows the issue, this time with a list of chars:

import Data.Binary
import Data.Vector.Binary
import qualified Data.ByteString.Lazy as L

main = L.writeFile "/tmp/aaa" $ encode "hello"
  • 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-15T23:44:51+00:00Added an answer on May 15, 2026 at 11:44 pm

    Ok, I think I see the problem here. The vector-binary-instances package defines:

    instance (Data.Vector.Generic.Base.Vector v a, Binary a) => Binary (v a)
    

    which is very bad. This definition means “for any type ‘v a’, this is a valid Binary instance”. That means this instance is available for any type that matches v a. That includes (but is not limited to) all lists, all functors, and all monads. As a demonstration, ghci reports the following:

    Prelude Data.Binary Data.Vector.Binary Data.ByteString.Lazy> :t getChar
    getChar :: IO Char
    Prelude Data.Binary Data.Vector.Binary Data.ByteString.Lazy> encode getChar
    <interactive>:1:0:
        No instance for (Data.Vector.Generic.Base.Vector IO Char)
          arising from a use of `encode' at <interactive>:1:0-13
        Possible fix:
          add an instance declaration for
          (Data.Vector.Generic.Base.Vector IO Char)
        In the expression: encode getChar
        In the definition of `it': it = encode getChar
    

    Here the interpreter is attempting to use this instance for getChar :: IO Char, which is obviously wrong.

    Short answer: don’t use vector-binary-instances for now. This instance is broken, and given how instances propagate through Haskell code it will cause problems. Until this is fixed, you should write your own binary instances for vectors. You should be able to copy the code from vector-binary-instances and restrict it to a monomorphic vector type

    instance (Binary a) => Binary (Vector a) where
    

    I believe this will work with any Vector which is an instance of Data.Vector.Generic.Vector.

    You also may want to contact the vector-binary-instances maintainer about this.

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

Sidebar

Related Questions

We have an application where we need to de-serialize some data from one stream
For my application, I need to serialize data to file using XML, so I
I need to serialize a color used in a WPF application to a database.
In my web application I often need to serialize objects as JSON. Not all
So I need to serialize a generic dictionary like Dictionary<long, List<MyClass>> . I need
I need to serialize a java Float to be read by an application written
There is this DB-connection-like object that my web application will need. It is pretty
For my mvc application I need to create Order object each having a list
i need to serialize AS3 strong typed Objects, send them to a C# Application
I'm serializing an object in a C# VS2003 / .Net 1.1 application. I need

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.