[Haskell] pattern matching on record fields and position

John Meacham john at repetae.net
Wed Nov 2 18:43:23 EST 2005


You might want to look at the 'get', 'set' and 'update' rules that DrIFT
can derive. i made them to addres a lot of the same issues you
mentioned.

I personally think it is a travesty that 

data Foo = Foo { a :: Int, b :: Char } | Bar { a :: Int }

let x = Bar { a = 4 }
    y = x { b = 'x'} 

results in bottom rather than just leaving x unchanged.

well, travesty is too strong. but it bugs the heck out of me.

but yeah, the DrIFT code derives functions that pull out fields but
returns them in a possibly failing monad so you can properly handle a
data type with no appropriate field.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell mailing list