From 58a14778ab5fc1fe86403595bd5a499f17292a3c Mon Sep 17 00:00:00 2001 From: PHO Date: Fri, 23 Apr 2010 21:16:37 +0900 Subject: [PATCH] IsShortEnoughForVarName --- Database/RRDtool/Expression.hs | 40 +++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/Database/RRDtool/Expression.hs b/Database/RRDtool/Expression.hs index ec5b23a..499a580 100644 --- a/Database/RRDtool/Expression.hs +++ b/Database/RRDtool/Expression.hs @@ -10,8 +10,11 @@ module Database.RRDtool.Expression , IsExprSet , IsCommonExprSet - , Constant(..) , IsVarName + , IsShortEnoughForVarName + , IsGoodLetterForVarName + + , Constant(..) , Variable(..) , IsVariableSet , CommonUnaryOp(..) @@ -30,6 +33,9 @@ module Database.RRDtool.Expression import Data.HList import Data.HList.String +import Types.Data.Bool +import Types.Data.Num hiding ((:*:)) +import Types.Data.Ord -- MentionedVars @@ -68,13 +74,37 @@ instance MentionedVars Constant where type MentionedVarsOf Constant = HNil {- This is what we want to do but GHC can't handle this for now. -class ( (HLengthOf a :<=: D255) ~ True - , HString a +class ( (HLengthOf str :<=: D255) ~ True + , HString str ) - => IsVarName a + => IsVarName str -} -class HString a => IsVarName a +class ( IsShortEnoughForVarName str + , HString str + ) + => IsVarName str + +class HString str => IsShortEnoughForVarName str +instance ( HString str + , (HLength str :<=: D255) ~ True + ) + => IsShortEnoughForVarName str + +class IntegerT c => GoodLetterForVarName c where + type IsGoodLetterForVarName c + +instance IntegerT c => GoodLetterForVarName c where + type IsGoodLetterForVarName c = ( (c :>=: D65) :&&: (c :<=: D90) ) -- A-Z + :||: + ( (c :>=: D99) :&&: (c :<=: D122) ) -- a-z + :||: + ( c :==: D45 ) -- '-' + :||: + ( c :==: D95 ) -- '_' + +--instance (a :>=: D65) ~ True => IsGoodLetterForVarName a +-- Variable data Variable vn = Variable !vn deriving (Show, Eq, Ord) -- 2.40.0