Giter VIP home page Giter VIP logo

Comments (5)

chrisdone avatar chrisdone commented on September 9, 2024 1

I agree, I was thinking about adding groups today.

from weigh.

chrisdone avatar chrisdone commented on September 9, 2024 1

I like this direction. I'll try applying it today or tomorrow and see how it scales. Presumably nesting works correctly too?

from weigh.

nobrakal avatar nobrakal commented on September 9, 2024

I have started to look at it. I come to something like:

data ToWeight = Simple String Action | Group String [ToWeight]

-- | Weigh specification monad.
newtype Weigh a =
  Weigh {runWeigh :: State (Config, [ToWeight]) a}
  deriving (Monad,Functor,Applicative)

[...]

-- | Write out an action.
tellAction :: String -> Action -> Weigh ()
tellAction name action = Weigh $ modify $ second $ \x -> x ++ [Simple name action]

wgroup :: String -> Weigh () -> Weigh ()
wgroup str wei = do
  start <- Weigh get
  let startL = length $ snd start
  wei
  Weigh $ modify $ second $ \x -> take startL x ++ [Group str $ drop startL x]

Not very beautiful, but I think this can do the trick. There can be a syntax like:

mainWith $ do
  wgroup "fst" $ do
    func "1" f 1
    func "2" f 2
  wgroup "snd" $ do
    func "3" f 3

from weigh.

nobrakal avatar nobrakal commented on September 9, 2024

Great :D
I can't see why nested wgroup will not work, but this definitely needs to be tested ^^

from weigh.

chrisdone avatar chrisdone commented on September 9, 2024

Implemented! http://hackage.haskell.org/package/weigh-0.0.8/docs/Weigh.html#v:wgroup

from weigh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.