4 Sep 19:41
Re: Compiler's bane
Andrew Coppin <andrewcoppin <at> btinternet.com>
2008-09-04 17:41:56 GMT
2008-09-04 17:41:56 GMT
Ryan Ingram wrote: > It's pretty simple, I think. > > type ExpGen = ReaderT [String] Gen > > arbExp :: ExpGen Expression > -- exercise for the reader > > instance Arbitrary Expression where > arbitrary = runReaderT arbExp [] > coarbitrary = coarbExp > > coarbExp (Var s) = variant 0 . coarbitrary s > coarbExp (Apply a b) = variant 1 . coarbitrary a . coarbitrary b > coarbExp (Lambda s e) = variant 2 . coarbitrary s . coarbitrary e > > instance Arbitrary Char where > arbitrary = elements "abcdefghijklmnopqrstuvwxyz_" > coarbitrary = coarbitrary . fromEnum > o_O I love the way other people have wildly different ideas of "simple" than me. I'm staring at this and completely failing to comprehend it. (But then, anything with "co" in the name generally makes little sense to me...) Why on earth would you need a reader monad? Surely if you want to add bound variables and then later query what variables are bound, you'd want a state monad? Hmm, I'm completely lost here.
RSS Feed