Questions tagged [uniplate]

Uniplate is library for writing simple and concise generic operations.

Uniplate is a simple, concise and fast generics library. To expand on that sentence:

  1. A generics library is one which allows you to write functions that operate over a data structure without tying down all aspects of the data structure. In particular, when writing an operation, you don't need to give a case for each constructor, and you don't have to state which fields are recursive.
  2. Uniplate is the simplest generics library. Using Uniplate is within the reach of all Haskell programmers.
  3. Uniplate is more concise than any other generics library.
  4. Uniplate is fast, not always the absolute fastest, but massively faster than many generics libraries.
  5. Uniplate is also less powerful than some other generics libraries, but if it does the job, you should use it.

The Uniplate library can be installed with the standard sequence of cabal commands:

cabal update
cabal install uniplate

Full documentation: http://community.haskell.org/~ndm/darcs/uniplate/uniplate.htm

8 questions
14
votes
1 answer

Simplifying a GADT with Uniplate

I'm trying to answer this stackoverflow question, using uniplate as I suggested, but the only solution I've come up with so far is pretty ugly. This seems like a fairly common issue, so I wanted to know if there was a more elegant…
rampion
  • 87,131
  • 49
  • 199
  • 315
7
votes
2 answers

Ensuring that a haskell type A contains a member of type B

Let us look at the following code: transformBi (++"asdasd") [1,2,3,4] Clearly, this code does nothing, but it still compiles fine. I would like to create a new version of transformBi that will not compile if the compiler can prove by the types that…
tohava
  • 5,344
  • 1
  • 25
  • 47
6
votes
1 answer

How can holes and contexts be implemented for higher-kinded types in a lens style uniplate library?

András Kovács proposed this question in response to an answer to a previous question. In a lens-style uniplate library for types of kind * -> * based on the class class Uniplate1 f where uniplate1 :: Applicative m => f a -> (forall b. f b -> m…
Cirdec
  • 24,019
  • 2
  • 50
  • 100
2
votes
1 answer

Generic transformations on a set of a given datatype

If I have a datatype representing a subset of propositional logic such as data Prop = Lit String | Neg Prop | And Prop Prop | Or Prop Prop Are there then easy ways to do generic transformations on [[Prop]]?…
beta
  • 2,380
  • 21
  • 38
2
votes
1 answer

Count `Pat`s in a Module

I need to count the number of Pat in a haskell Module. I know the simplest way is to pattern match on each level of the AST, which will result in a huge function that looks like the entire AST. I believe there's some way to take advantage of…
rem
  • 893
  • 4
  • 18
1
vote
1 answer

Can uniplate's `universeBi` be used to retrieve nodes in a breadth-first fashion?

Is it possible to use Uniplate's universeBi to get the output in breadth-first-order? It appears the results are returned in a depth-first fashion. I'm wondering how I can use uniplate to retrieve the universeBi in a breadth-first fashion. To…
alias
  • 28,120
  • 2
  • 23
  • 40
1
vote
1 answer

Deriving Uniplate with Derive

My program is using Uniplate.Data extensively, and want to improve its performance. Currently I'm deriving Data instances automatically using the DeriveDataTypeable GHC extension. {-# LANGUAGE DeriveDataTypeable #-} import Data.Data import…
Benesh
  • 3,398
  • 1
  • 18
  • 38
0
votes
1 answer

zip AST with bool list

I have an AST representing a haskell program and a bitvector/bool list representing the presence of strictness annotations on Patterns in order.For example, 1000 represents a program with 4 Pats where the first one is a BangPat. Is there any way…
rem
  • 893
  • 4
  • 18