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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:31:26+00:00 2026-05-26T16:31:26+00:00

I had previously written a function that seems to work, but unfortunately I didn’t

  • 0

I had previously written a function that seems to work, but unfortunately I didn’t write the code very nicely, and now have to figure it out again [that I’m modifying the monad transformer stack I’m working with].

run_astvn ::
    LowerMonadT (StateT LowerSketchData Identity) β
    -> Seq SketchAST
run_astvn x = get_ast2 $ runIdentity $
    runStateT (runStateT (runStateT x empty) empty)
        (LowerSketchData Set.empty)
    where get_ast2 = snd . fst

I want to get the concrete type of get_ast2. I seem to be able to add the flag -ddump-simpl and grep through my terminal output until I find, (cleaned up a little)

(((β, Seq SketchAST), Seq SketchAST), LowerSketchData) -> Seq SketchAST

(Sorry this is likely nonsense to everyone else, but the point is it is useful for me.) Is there a faster / more convenient way to do this? In case it’s not obvious, what I mean by “concrete” in this case is that the above type is useful; knowing the type of snd . fst is not :).

  • 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-26T16:31:27+00:00Added an answer on May 26, 2026 at 4:31 pm

    There’s two ways I know of to do this currently, and they’re both sort of hacks. The first is to use implicit parameters:

    {-# LANGUAGE ImplicitParams #-}
    import Control.Monad.State
    import Control.Monad.Identity
    import Data.Sequence
    import qualified Data.Set as Set
    
    data LowerSketchData = LowerSketchData (Set.Set Int)
    type LowerMonadT m = StateT (Seq SketchAST) (StateT (Seq SketchAST) m)
    data SketchAST = SketchAST
    
    --run_astvn ::
    --    LowerMonadT (StateT LowerSketchData Identity) β
    --    -> Seq SketchAST
    run_astvn x = ?get_ast2 $ runIdentity $
        runStateT (runStateT (runStateT x empty) empty)
            (LowerSketchData Set.empty)
    --    where get_ast2 = snd . fst
    

    Then, in ghci:

    *Main> :t run_astvn
    run_astvn
      :: (?get_ast2::(((a, Seq a1), Seq a2), LowerSketchData) -> t) =>
         StateT
           (Seq a1) (StateT (Seq a2) (StateT LowerSketchData Identity)) a
         -> t
    

    The other way is to give an intentionally wrong type signature and check how the compiler complains.

    import Control.Monad.State
    import Control.Monad.Identity
    import Data.Sequence
    import qualified Data.Set as Set
    
    data LowerSketchData = LowerSketchData (Set.Set Int)
    type LowerMonadT m = StateT (Seq SketchAST) (StateT (Seq SketchAST) m)
    data SketchAST = SketchAST
    
    run_astvn ::
        LowerMonadT (StateT LowerSketchData Identity) β
        -> Seq SketchAST
    run_astvn x = get_ast2 $ runIdentity $
        runStateT (runStateT (runStateT x empty) empty)
            (LowerSketchData Set.empty)
    --    where get_ast2 = snd . fst
        where get_ast2 :: (); get_ast2 = undefined
    

    This gives the error:

    test.hs:13:19:
        The first argument of ($) takes one argument,
        but its type `()' has none
        In the expression:
          <snip>
    

    Changing the wrong type to () -> ():

    test.hs:13:30:
        Couldn't match expected type `()'
                    with actual type `(((β, Seq SketchAST), Seq SketchAST),
                                       LowerSketchData)'
        In the second argument of `($)', namely
          <snip>
    

    So now we know the type should look like (((β, Seq SketchAST), Seq SketchAST), LowerSketchData) -> (). One last iteration gets rid of the final (), because the compiler complains that:

    test.hs:13:19:
        Couldn't match expected type `Seq SketchAST' with actual type `()'
        In the expression:
          <snip>
    

    …so the other () should be Seq SketchAST.

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

Sidebar

Related Questions

Previously we had desktop applications but given the fact that accessing the server (either
I originally had this code written as a series of if statements, but after
I have an application that uses CoreData. I previously had a class named Marker
previously i had custom tableviewcell and was loading from Nib.in that i have specified
I want to define a constant in objective-c. Previously I had the following function:
Previously, I had a class that wrapped an internal System.Collections.Generic.List<Item> (where Item is a
Got some basic problem again. I need to modify a function that previously returned
I am converting a stored procedure which I had previously written as a string
I have previously written an application for Mac OSX that includes a kernel extension.
I've had this REST Server (written by myself) that is secured by simple HTTP

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.