Multivariant assignments generation language

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed by Anton Marchenko, Mansur Ziatdinov
Maintained by

Multivariant assignments generation language

This library allows you to write short description of multivariant assignments in embedded DSL and interpret them as solution, text of assignment and tests.

This library is available at hackage.


  • install stack
  • run stack exec multivariant

or you can use cabal install multivariant.

Language description

There are several typeclasses for tagless-final encoding of language:

  • Program
  • WithDescription
  • WithCornerCases
  • WithInvert

Each typeclass defines some operations that every interpreter has to implement.

There are currently three ``interpreters’’ (types that implement corresponding typeclasses):

  • Cases
  • Description
  • Solution






task = ((+1) :<->: (-1)) `withDescription` "Add one to each list element" `withCornerCases` ([0],[0])
    ~>   (   (sum :<->: (\s -> [s,0])) `withDescription` "Compute sum of elements" `withCornerCases` ([[]],[0])
	   <+++> (product :<->: (\p -> [1,p])) `withDescription` "Compute product of elements" `withCornerCases` ([[]],[1])


More examples are available in the examples directory.

comments powered byDisqus