@@ -29,9 +29,11 @@ Boolean data type has two possible truth values to represent logic.\
2929@docs select, select0, select1, select2, select3, select4, select5, select6, select7, select8 
3030-} 
3131
32- import  Regex  exposing  (Regex , fromStringWith , contains , find )
3332import  Maybe  exposing  (withDefault )
33+ import  String  exposing  (toInt )
3434import  List  exposing  (length )
35+ import  Regex  exposing  (Regex , fromStringWith , contains , find )
36+ 
3537
3638
3739
@@ -42,18 +44,35 @@ Converts string to boolean.
4244
4345    -- parse s 
4446    -- s: a string 
45-     parse "1"        == True 
46-     parse "truthy"   == True 
47-     parse "not off"  == True 
48-     parse "not true" == False 
49-     parse "inactive" == False 
50-     parse "disabled" == False 
47+     parse "1"            == True 
48+     parse "truthy"       == True 
49+     parse "Not Off"      == True 
50+     parse "Not Inactive" == True 
51+     parse "cold"         == False 
52+     parse "inactive"     == False 
53+     parse "Negative Yes" == False 
54+     parse "Negative Aye" == False 
5155-} 
5256parse  :  String  ->  Bool 
5357parse  s = 
54-   let  fal =  contains ( regex " (negati|never|refus|wrong|fal|off)|\\ b(f|n|0)\\ b" )  s
55-       neg =  modBy 2  ( length ( find ( regex " \\ b(nay|nah|no|dis|un|in)" )  s))  ==  1  in 
56-   not ( xor fal neg) 
58+   let  t =  contains rTru s
59+       f =  contains rFal s
60+       n =  modBy 2  ( length ( find rNeg s))  ==  1  in 
61+   if  contains rNum s
62+     then  ( withDefault 0  ( toInt " 2" ))  >  0 
63+     else  nimply f t ==  n
64+ 
65+ rNum  :  Regex 
66+ rNum  =  regex " ^[ -+]?\\ d+$" 
67+ 
68+ rTru  :  Regex 
69+ rTru  =  regex " \\ b(?:t|y|1)\\ b|\\ b(?:\\ +|ay|go|on|up)|(?:tru|acc|asc|day|for|hot|inc|joy|new|pos|top|win|yes|dawn|full|safe|grow|high|just|real|some|know|live|love|open|pure|shin|warm|wis[de]|activ|admit|advan|agree|begin|brigh|build|creat|early|enter|float|f(?:i|ou)nd|grant|light|north|prett|prese|publi|start|succe|victr)" 
70+ 
71+ rFal  :  Regex 
72+ rFal  =  regex " \\ b(?:f|n|0)\\ b|(?:fal|off|dim|end|low|old|back|cold|cool|dark|dead|decr|desc|dirt|down|dull|dusk|exit|late|sink|ugly|absen|botto|close|finis|night|priva|south|wrong)" 
73+ 
74+ rNeg  :  Regex 
75+ rNeg  =  regex " \\ b(?:-|na|no|un|in|aft|bad|dis|lie|non|ben[dt]|den[iy]|empt|fail|fake|hate|los[es]|stop|decli|defea|destr|never|negat|refus|rejec|forget|shr[iu]nk|against|is.?nt|can.?(?:no)?t)|(?:hind)" 
5776
5877regex  :  String  ->  Regex 
5978regex  s = 
0 commit comments