From: PHO Date: Fri, 23 Apr 2010 12:16:37 +0000 (+0900) Subject: IsShortEnoughForVarName X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=58a14778ab5fc1fe86403595bd5a499f17292a3c;p=hs-rrdtool.git IsShortEnoughForVarName --- 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)