{-# LANGUAGE FlexibleContexts #-}{-# LANGUAGE TypeOperators #-}------------------------------------------------------------------------------- |-- Module : Generics.Regular.Functions.LR-- Copyright : (c) 2008 Universiteit Utrecht-- License : BSD3---- Maintainer : generics@haskell.org-- Stability : experimental-- Portability : non-portable---- Summary: Generic functionality for regular dataypes: mapM, flatten, zip,-- equality, show, value generation and fold.-----------------------------------------------------------------------------moduleGenerics.Regular.Functions.LR(-- * Functions for generating values that are different on top-levelLRBase(..),LR(..),left,right,)whereimportGenerics.Regular.Base------------------------------------------------------------------------------- Functions for generating values that are different on top-level.------------------------------------------------------------------------------- | The @LRBase@ class defines two functions, @leftb@ and @rightb@, which -- should produce different values.classLRBaseawhereleftb::arightb::ainstanceLRBaseIntwhereleftb=0rightb=1instanceLRBaseIntegerwhereleftb=0rightb=1instanceLRBaseCharwhereleftb='L'rightb='R'instanceLRBasea=>LRBase[a]whereleftb=[]rightb=[rightb]-- | The @LR@ class defines two functions, @leftf@ and @rightf@, which should -- produce different functorial values.classLRfwhereleftf::a->farightf::a->fainstanceLRIwhereleftfx=Ixrightfx=IxinstanceLRBasea=>LR(Ka)whereleftf_=Kleftbrightf_=KrightbinstanceLRUwhereleftf_=Urightf_=Uinstance(LRf,LRg)=>LR(f:+:g)whereleftfx=L(leftfx)rightfx=R(rightfx)instance(LRf,LRg)=>LR(f:*:g)whereleftfx=leftfx:*:leftfxrightfx=rightfx:*:rightfxinstanceLRf=>LR(Ccf)whereleftfx=C(leftfx)rightfx=C(rightfx)instanceLRf=>LR(Ssf)whereleftfx=S(leftfx)rightfx=S(rightfx)-- | Produces a value which should be different from the value returned by -- @right@.left::(Regulara,LR(PFa))=>aleft=to(leftfleft)-- | Produces a value which should be different from the value returned by -- @left@.right::(Regulara,LR(PFa))=>aright=to(rightfright)