Questions tagged [scrap-your-boilerplate]

This Haskell package contains the generics system described in the Scrap Your Boilerplate papers. It defines the Data class of types permitting folding and unfolding of constructor applications, instances of this class for primitive types, and a variety of traversals.

This package contains the generics system described in the Scrap Your Boilerplate papers (see http://www.cs.uu.nl/wiki/GenericProgramming/SYB).

It defines the Data class of types permitting folding and unfolding of constructor applications, instances of this class for primitive types, and a variety of traversals.

http://hackage.haskell.org/package/syb

39 questions
1
vote
4 answers

A function for returning part of a product or record depending on parameter and requested return type

I'm looking for a function, that, given the necessary return type, will return the part of a product parameter that matches that type, based purely on the structure of the type passed to the function. For example: data MyProduct = MyProduct String…
Noel M
  • 15,812
  • 8
  • 39
  • 47
1
vote
1 answer

SYB Libraries functions

I've been working with some scrap-your-boilerplate functions for a while. Nevertheless, I tried to compile a module that imports Data.Data and Data.Typeable, though some functions like everywhere and mkT could not be found by the compiler. Where are…
1
vote
1 answer

Understanding Constr type of Data.Data package of Haskell

I am trying to understand the Constr type of Data.Data package. Consider the session below. dataTypeConstrs returns a list of Constr, both zero- and one-argument constructors of Maybe. Attempting to re-create the list fails due to obvious type…
Grwlf
  • 896
  • 9
  • 21
1
vote
1 answer

Does the current SYB permit extension of generic functions with new types?

The first two Scrap Your Boilerplate papers describe a way of writing generic functions that work for general types, but have special cases for specific types. For instance, fromJSON from the aeson package, defines a generic function for converting…
scvalex
  • 14,931
  • 2
  • 34
  • 43
1
vote
1 answer

Avoiding boilerplate that's not part of a Haskell class

I'm developing a framework for artificial life experiments. The framework can support multiple species, as long as each species is an instance of the Agent class. I wrap each Agent in an AgentBox so that I can read, write, and use them without…
mhwombat
  • 8,026
  • 28
  • 53
0
votes
1 answer

SYB `cast` function in Scala

I am reading the Scrap Your Boilerplate paper and trying to follow along by implementing the ideas in scala as best I can. However, I'm stuck on the very first function, the cast, which is used to take a value and attempt to cast it to another type…
anqit
  • 780
  • 3
  • 12
0
votes
1 answer

Resharper 6 live templates for CQRS dev

There's been some chatter on the ddd-cqrs list about people using Resharper live templates to help take care of the boilerplate code that you get when doing CQRS dev. Is this the best way to overcome the boilerplate madness and does anyone have any…
user156888
0
votes
2 answers

How to fold over a constructor with special cases?

So I have a tree that I want to collapse where the nodes are of type data Node = Node1 Node | Node2 Node Node | ... deriving Data except for a few special cases. I want to do something along the lines of collapse SPECIALCASE1 = ... collapse…
Andreas Hagen
  • 2,335
  • 2
  • 19
  • 34
0
votes
1 answer

Scrap your boilerplate

Regarding SYB,I am a beginner at it I tried wring a code to get the variables in an expression with the code variables = removeDuplicate $ (everything (++) ([] `mkQ` f)) where f (ExprVar st) = [st] f _ =…
anujuhi01
  • 71
  • 7
1 2
3