Verified Commit 750f8ab3 authored by Camil Staps's avatar Camil Staps 🙂

Add pretty-print support for new Maybe syntax to Clean.Types and Clean.PrettyPrint

parent 2ab3f602
Pipeline #43821 passed with stage
in 2 minutes and 15 seconds
......@@ -14,13 +14,21 @@ where
lookup k [] = k
lookup k [(k`,v):m] = if (k == k`) v (lookup k m)
namemap =
[ ("_Nil", "[]")
, ("_nil", "[|]")
, ("_|Nil", "[|]")
, ("_#Nil", "[#]")
, ("_Unit", "()")
]
namemap =:
[ ("_Nil", "[]")
, ("_nil", "[|]")
, ("_|Nil", "[|]")
, ("_#Nil", "[#]")
, ("_Nothing", "?^None")
, ("_#Nothing", "?#None")
, ("_!Nothing", "?None")
, ("_|Nothing", "?|None")
, ("_Just", "?^Just")
, ("_#Just", "?#Just")
, ("_!Just", "?Just")
, ("_|Just", "?|Just")
, ("_Unit", "()")
]
instance print Import
where
......
......@@ -214,6 +214,9 @@ where
lookup "_#Array" = Yes ("{#" :+: join stnp " " ats :+: "}")
lookup "_32#Array" = Yes ("{32#" :+: join stnp " " ats :+: "}")
lookup "_!Array" = Yes ("{!" :+: join stnp " " ats :+: "}")
lookup "_Maybe" = Yes (if (isEmpty ats) ("(?^)" :+: PrintNil) ("(?^ " :+: join stnp " " ats :+: ")"))
lookup "_!Maybe" = Yes (if (isEmpty ats) ("(?)" :+: PrintNil) ("(? " :+: join stnp " " ats :+: ")"))
lookup "_#Maybe" = Yes (if (isEmpty ats) ("(?#)" :+: PrintNil) ("(?# " :+: join stnp " " ats :+: ")"))
lookup name
| name % (0,5) == "_Tuple"
| length ats == arity = Yes ("(" :+: join stnp "," types :+: ")")
......
......@@ -146,6 +146,10 @@ typeConstructorName isInfix isArg t as
| t == "_32#Array" = if isInfix ("{32#" -- as -- "}") ("{32#}" -- as`)
| t == "_Array" = if isInfix ("{" -- as -- "}") ("{}" -- as`)
| t == "_!Array" = if isInfix ("{!" -- as -- "}") ("{!}" -- as`)
// Maybes
| t == "_Maybe" = if (isEmpty as) ["(?^)"] ("(?^ " -- as -- ")")
| t == "_#Maybe" = if (isEmpty as) ["(?#)"] ("(?# " -- as -- ")")
| t == "_!Maybe" = if (isEmpty as) ["(?)"] ("(? " -- as -- ")")
// Tuples
| t % (0,5) == "_Tuple"
# n = toInt (t % (6, size t - 1))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment