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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -