1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
-----------------------------------------------------------------------------
-- |
-- Module : Debug.SimpleReflect.Vars
-- Copyright : (c) 2008-2014 Twan van Laarhoven
-- License : BSD-style
--
-- Maintainer : twanvl@gmail.com
-- Stability : experimental
-- Portability : portable
--
-- Single letter variable names.
--
-- All names have type @Expr@, except for @f@, @g@ and @h@, which are generic functions.
-- This means that @show (f x :: Expr) == \"f x\"@, but that @show (a x :: Expr)@ gives a type error.
-- On the other hand, the type of @g@ in @show (f g)@ is ambiguous.
--
-----------------------------------------------------------------------------
module Debug.SimpleReflect.Vars
( -- * Variables
a,b,c,d,e,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
-- * Functions
, f,f',f'',g,h
-- * Operators
, (⊗), (⊕), (@@)
) where
import Debug.SimpleReflect.Expr
------------------------------------------------------------------------------
-- Variables!
------------------------------------------------------------------------------
a,b,c,d,e,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z :: Expr
[a,b,c,d,e,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
= [var [letter] | letter <- ['a'..'e']++['i'..'z']]
f,f',f'',g,h :: FromExpr a => a
f = fun "f"
f' = fun "f'"
f'' = fun "f''"
g = fun "g"
h = fun "h"
------------------------------------------------------------------------------
-- Operators
------------------------------------------------------------------------------
-- | A non-associative infix 9 operator
(@@) :: Expr -> Expr -> Expr
(@@) = op Infix 9 " @@ "
infix 9 @@
-- | A non-associative infix 7 operator
(⊗) :: Expr -> Expr -> Expr
(⊗) = op Infix 7 " ⊗ "
infix 7 ⊗
-- | A non-associative infix 6 operator
(⊕) :: Expr -> Expr -> Expr
(⊕) = op Infix 6 " ⊕ "
infix 6 ⊕
|