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

The Archive Base Latest Questions

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

This function generates simple .dot files for visualizing automata transition functions using Graphviz. It’s

  • 0

This function generates simple .dot files for visualizing automata transition functions using Graphviz. It’s primary purpose is debugging large sets of automatically generated transitions (e.g., the inflections of Latin verbs).

prepGraph :: ( ... ) => NFA c b a -> [String]
prepGraph nfa = "digraph finite_state_machine {"
              : wrapSp "rankdir = LR"
              : wrapSp ("node [shape = circle]" ++ (mapSp (states nfa \\ terminal nfa)))
              : wrapSp ("node [shape = doublecircle]" ++ (mapSp $ terminal nfa))
              : formatGraph nfa ++ ["}"]

formatGraph :: ( ... ) => NFA c b a -> [String]
formatGraph = map formatDelta . deltaTuples
 where formatDelta (a, a', bc) = wrapSp (mkArrow a a' ++ " " ++ mkLabel bc)
       mkArrow x y   = show x ++ " -> " ++ show y
       mkLabel (y, z) = case z of
         (Just t) -> "[ label = \"(" ++ show y ++ ", " ++ show t ++ ")\" ]"
         Nothing  -> "[ label = \"(" ++ show y ++ ", " ++ "Null" ++ ")\" ]"

where wrap, wrapSp and mapSp are formatting functions, as is deltaTuples.

The problem is that formatGraph retains double quotes around Strings, which causes errors in Graphviz. E.g., when I print unlines $ prepGraph to a file, I get things like:

0 -> 1 [ label = "('a', "N. SF")" ];

instead of

0 -> 1 [ label = "('a', N. SF)" ];

(However, “Null” seems to work fine, and outputs perfectly well). Now of course the string “N. SF” isn’t the actual form I use to store inflections, but that form does include a String or two. So how can I tell Haskell: when you show a String values, don’t double-quote it?

  • 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-17T00:41:24+00:00Added an answer on May 17, 2026 at 12:41 am

    Check out how Martin Erwig handled the same problem in Data.Graph.Inductive.Graphviz:

    http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/src/Data-Graph-Inductive-Graphviz.html

    The function you’re looking for is “sq” at the bottom:

    sq :: String -> String
    sq s@[c]                     = s
    sq ('"':s)  | last s == '"'  = init s
                | otherwise      = s
    sq ('\'':s) | last s == '\'' = init s
                | otherwise      = s
    sq s                         = s
    

    (check out the context and adapt for your own code, of course)

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

Sidebar

Related Questions

I'm asking this because I'm working with a recursive function that generates a large
This code written as it is in a simple page generates an [object] as
with following code qTip works for me and generates tooltips: $('a.ppname[rel]').live('mouseover', function() { $(this).qtip(
I am using Postgresql 8.3 and have the following simple function that will return
I have a function to generate an 11 character salt. This salt can include
This is how my dialog is generated: $(function () { $(.btnDialog).click(function() { //e.preventDefault(); var
this action is generated in symfony 1.2 when you create a module: public function
I have this function in my generator. Private Sub AddBoundedValue(ByVal boundedValue As Object, ByVal
I sort of understand this, at least the function of generators (I've used them
This function works fine: std::string get_str() { return std::get<0>( make_tuple(std::string(hi)) ); } But if

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.