yesod - If it is possible to define locally data type in Haskell? -
recentlly, find interesting question when i'am writing code in haskell.
for example, in yesod framework, if need write route parse json parameters, need define data type this:
data args = args { :: int } instance fromjson args putsampler :: handler () putsampler = args{..} <- requirejsonbody <balabalabala>
it works fine. becomes pulzzled if have lot of these routes need parameters parsed.
i may have args1, args2, args3 , there field must different, args1{a1}, args2{a2}, args3{a3}
it annoying me.
so, if possible write code way:
putsampler :: handler () putsampler = args{..} <- requirejsonbody <balabalabala> data args = args { :: int } instance fromjson args
to define data variables locally?
Comments
Post a Comment