Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use syntax T and F for true and false Booleans #374

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Disco/AST/Surface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ instance Pretty Term where
Nothing -> error $ "pretty @Term: Prim " ++ show p ++ " is not in the primMap!"
TParens t -> pretty t
TUnit -> text "■"
(TBool b) -> text (map toLower $ show b)
(TBool b) -> text (take 1 $ show b)
TChar c -> text (show c)
TString cs -> doubleQuotes $ text cs
TAbs q bnd -> withPA initPA $
Expand Down
6 changes: 4 additions & 2 deletions src/Disco/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ reservedWords =
, "false"
, "True"
, "False"
, "T"
, "F"
, "let"
, "in"
, "is"
Expand Down Expand Up @@ -695,8 +697,8 @@ parseAtom :: Parser Term
parseAtom =
label "expression" $
parseUnit
<|> TBool True <$ (reserved "true" <|> reserved "True")
<|> TBool False <$ (reserved "false" <|> reserved "False")
<|> TBool True <$ (reserved "true" <|> reserved "True" <|> reserved "T")
<|> TBool False <$ (reserved "false" <|> reserved "False" <|> reserved "F")
<|> TChar <$> lexeme (between (char '\'') (char '\'') L.charLiteral)
<|> TString <$> lexeme (char '"' >> manyTill L.charLiteral (char '"'))
<|> TWild <$ try parseWild
Expand Down
4 changes: 2 additions & 2 deletions src/Disco/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import qualified Prelude as P

import Control.Monad (forM)
import Data.Bifunctor (first)
import Data.Char (chr, ord, toLower)
import Data.Char (chr, ord)
import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
import Data.List (foldl')
Expand Down Expand Up @@ -471,7 +471,7 @@ prettyValue (TyUser x args) v = do
prettyValue (body args) v
prettyValue _ VUnit = "■"
prettyValue TyProp _ = prettyPlaceholder TyProp
prettyValue TyBool (VInj s _) = text $ map toLower (show (s == R))
prettyValue TyBool (VInj s _) = text $ take 1 (show (s == R))
prettyValue TyBool v =
error $ "Non-VInj passed with Bool type to prettyValue: " ++ show v
prettyValue TyC (vchar -> c) = text (show c)
Expand Down
6 changes: 3 additions & 3 deletions test/arith-count/expected
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
1
10
45
true
true
T
T
12600
true
T
2520
0
3628800
Expand Down
20 changes: 10 additions & 10 deletions test/arith-numthry/expected
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
3
3
true
true
true
true
true
false
false
false
true
true
T
T
T
T
T
F
F
F
T
T
4 changes: 2 additions & 2 deletions test/containers-cmp/expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{1, 2}, {1, 3}, {2, 3}}
true
T
{⟅1 # 3⟆, ⟅2 # 5⟆}
true
T
44 changes: 22 additions & 22 deletions test/containers-ops/expected
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
{(1, 10), (1, 20), (1, 30), (2, 10), (2, 20), (2, 30)}
{(1, 10), (1, 20), (1, 30), (2, 10), (2, 20), (2, 30)}
{1}
true
true
true
T
T
T
{{}, {1}, {1, 2}, {1, 2, 3}, {1, 3}, {2}, {2, 3}, {3}}
{{}}
{{}, {1}}
Expand All @@ -29,31 +29,31 @@ bag([2, -3]) union bag([1 / 2]) : Bag(ℚ)
⟅⟆
⟅2 # 2, 3, 5⟆
⟅1⟆
true
true
true
T
T
T
⟅⟅⟆⟆
⟅⟅⟆, ⟅1⟆⟆
⟅⟅⟆, ⟅1⟆, ⟅1, 2⟆, ⟅2⟆⟆
⟅⟅⟆, ⟅'a'⟆, ⟅'a', 'b'⟆ # 2, ⟅'a', 'b' # 2⟆, ⟅'b'⟆ # 2, ⟅'b' # 2⟆⟆
⟅⟅⟆, ⟅'a'⟆ # 2, ⟅'a', 'b'⟆ # 6, ⟅'a', 'b' # 2⟆ # 6, ⟅'a', 'b' # 3⟆ # 2, ⟅'a' # 2⟆, ⟅'a' # 2, 'b'⟆ # 3, ⟅'a' # 2, 'b' # 2⟆ # 3, ⟅'a' # 2, 'b' # 3⟆, ⟅'b'⟆ # 3, ⟅'b' # 2⟆ # 3, ⟅'b' # 3⟆⟆
[(2, 3), (2, 4), (2, 4), (1, 3), (1, 4), (1, 4)]
true
true
false
false
true
false
false
true
true
true
false
false
true
false
true
true
T
T
F
F
T
F
F
T
T
T
F
F
T
F
T
T
⟅'x' # 3, 'y' # 2⟆
⟅'x' # 3, 'y'⟆
⟅'x', 'y'⟆
Expand Down
4 changes: 2 additions & 2 deletions test/containers-reduce/expected
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ reduce : (a × a → a) × a × List(a) → a
reduce(~+~, 0, [1 .. 10]) : ℕ
55
60
true
T
2351
6
7
true
T
2 changes: 1 addition & 1 deletion test/error-tyargs/error-tyargs.disco
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type T(a,b) = Unit + a*b
type X(a,b) = Unit + a*b
6 changes: 3 additions & 3 deletions test/error-tyargs/expected
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Loading error-tyargs.disco...
Loaded.
Error: not enough arguments for the type 'T'.
Error: not enough arguments for the type 'X'.
https://disco-lang.readthedocs.io/en/latest/reference/num-args-type.html
Error: not enough arguments for the type 'T'.
Error: not enough arguments for the type 'X'.
https://disco-lang.readthedocs.io/en/latest/reference/num-args-type.html
Error: too many arguments for the type 'T'.
Error: too many arguments for the type 'X'.
https://disco-lang.readthedocs.io/en/latest/reference/num-args-type.html
Error: not enough arguments for the type 'List'.
https://disco-lang.readthedocs.io/en/latest/reference/num-args-type.html
Expand Down
8 changes: 4 additions & 4 deletions test/error-tyargs/input
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:load test/error-tyargs/error-tyargs.disco
x : T
y : T(Int)
z : T(Int,Char)
w : T(Int,Char,Bool)
x : X
y : X(Int)
z : X(Int,Char)
w : X(Int,Char,Bool)
q : List
p : List(Int,Char)
2 changes: 1 addition & 1 deletion test/error-unboundtyvar/expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Loading unboundtyvar.disco...
While checking unboundtyvar.T:
While checking unboundtyvar.Ty:
Error: Unknown type variable 'b'.
https://disco-lang.readthedocs.io/en/latest/reference/unbound-tyvar.html
2 changes: 1 addition & 1 deletion test/error-unboundtyvar/unboundtyvar.disco
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type T(a) = a + b
type Ty(a) = a + b
8 changes: 4 additions & 4 deletions test/graphs-equality/expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
true
true
true
true
T
T
T
T
2 changes: 1 addition & 1 deletion test/list-poly/expected
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[10, 9, 8, 7, 6]
[1, 3, 6, 10, 15, 21]
[1, 4, 9, 16, 25, 36]
true
T
[]
[1, 3, 4, 4, 3, 1, -2, -6, -11, -17]
[1, 3/2, 2, 5/2, 3]
Expand Down
66 changes: 34 additions & 32 deletions test/logic-bools/expected
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
true
false
true
false
true
false
false
false
false
false
true
true
true
false
true
true
false
true
true
false
true
true
true
false
true
true
true
false
false
true
false
false
T
F
T
F
T
F
T
F
F
F
F
F
T
T
T
F
T
T
F
T
T
F
T
T
T
F
T
T
T
F
F
T
F
F
2 changes: 2 additions & 0 deletions test/logic-bools/input
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ true
false
True
False
T
F
true and true
true and false
false and true
Expand Down
86 changes: 43 additions & 43 deletions test/logic-cmp/expected
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
true
false
false
true
true
true
false
false
true
false
false
true
true
false
false
false
true
true
false
true
false
true
true
false
true
false
true
false
false
true
true
true
false
true
false
true
true
false
true
true
false
false
true
T
F
F
T
T
T
F
F
T
F
F
T
T
F
F
F
T
T
F
T
F
T
T
F
T
F
T
F
F
T
T
T
F
T
F
T
T
F
T
T
F
F
T
3
5
1
Expand Down
8 changes: 4 additions & 4 deletions test/map-compare/expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
true
true
true
true
T
T
T
T
Loading
Loading