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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:20:41+00:00 2026-05-23T08:20:41+00:00

Say I have a dictionary.txt file, I need to read it into a map

  • 0

Say I have a dictionary.txt file, I need to read it into a map and use it in my program, how can I make this dictionary.txt file contained in the compiled exe file?

  • 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-23T08:20:41+00:00Added an answer on May 23, 2026 at 8:20 am

    You can store serialized data types as bytestring literals. Here’s an example:

    • http://code.haskell.org/~dons/code/compiled-constants/
    • http://haskell.org/haskellwiki/Compiling_in_constants

    However, the file-embed automates this process, making it easier to do non-trivial embeddings.

    All approaches essentially boil down to representing the static data as a bytestring literal,

    {-# LANGUAGE OverloadedStrings #-}
    
    import Data.Binary
    import qualified Data.Map as M
    import qualified Data.ByteString.Char8 as S
    import Data.ByteString.Lazy
    import Codec.Compression.GZip
    
    --
    -- this is a gzip compressed literal bytestring, storing a binary-encoded Data.Map
    --
    mytable =
        "\US\139\b\NUL\NUL\NUL\NUL\NUL\NUL\ETXEN\
        \\219\SO\194 \f\197\224\188\196\CAN\227\US\
        \\224\171~\NAKc\GS4ce\161`\178\191\215(\176\
        \\190\180\167\231\210\n\241\171\203\191\ti\
        \\157\217\149\249< \ENQ\214\&9>\202\162\179a\
        \\132X\233\ESC=\231\215\164\SYN\157\DC2D\226*\
        \\146\174o\t\167\DLE\209\"i_\240\193\129\199<W\
        \\250nC\CAN\212\CAN\162J\160\141C\178\133\216;\
        \\\@4\144-W\203\209x\205\140\166\RS\163\237]9f\
        \\170\143\ACK\163g\223\STX\184\&7\rH\222\FSW\
        \\130\&7D\197\NUL\164\&0U\193\186\t\186o\
        \\228\180~\NUL\a6\249\137#\SOH\NUL\NUL"
    
    main = print =<< M.lookup "ghc" m
        where
            -- build the table from the bytestring:
            m :: M.Map String (Maybe String)
            m = decode . decompress . fromChunks . return $ mytable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say that i have a generic dictionary with data like this (I hope the
Let's say I have a dictionary of names (a huge CSV file). I want
Let's say I have a dictionary in which the keys map to integers like:
Let's say I have a text file with the following: line = this is
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Let's say I have a list: a = ['apple', 'carrot'] and a dictionary: d
If I have, say, 100 items that'll be stored in a dictionary, should I
Lets say have this immutable record type: public class Record { public Record(int x,
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
Say you have an application divided into 3-tiers: GUI, business logic, and data access.

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.