Commit cd7a7d60 authored by Camil Staps's avatar Camil Staps 🚀

Merge branch 'add-packed-arrays-support-to-Clean.Types' into 'master'

Add packed arrays support to Clean.Types

See merge request !331
parents 45157274 87886d38
Pipeline #42176 passed with stage
in 2 minutes and 12 seconds
......@@ -30,6 +30,7 @@ from Text.Parsers.Simple.Core import :: Parser,
:: Token
= TIdent String // UpperCaseId or FunnyId
| TVar String // LowerCaseId
| TInt Int
| TArrow // ->
| TComma // ,
......@@ -55,6 +56,9 @@ where
(==) (TVar a) b = case b of
TVar b -> a == b
_ -> False
(==) (TInt a) b = case b of
TInt b -> a == b
_ -> False
(==) TArrow b = b=:TArrow
(==) TComma b = b=:TComma
(==) TStar b = b=:TStar
......@@ -106,6 +110,8 @@ where
with (id, cs`) = span isFunny cs
| isLower c = tkz [TVar $ toString [c:var]:tks] cs`
with (var, cs`) = span isIdentChar cs
| isDigit c = tkz [TInt (toInt (toString [c:int])):tks] cs`
with (int, cs`) = span isDigit cs
tkz _ _ = Nothing
isIdentChar :: !Char -> Bool
......@@ -132,15 +138,16 @@ where
<|> liftM Uniq (uniq argtype)
<|> liftM Uniq (uniq (liftM2 Cons cons $ some argtype))
<|> liftM Uniq (uniq (liftM2 Type ident $ some argtype))
<|> liftM (\t -> Type "_#Array" [t]) (braced (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!Array" [t]) (braced (pToken TStrict >>| type))
<|> liftM (\t -> Type "_Array" [t]) (braced type)
<|> liftM (\t -> Type "_#List!" [t]) (bracked (pToken TUnboxed >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_!List!" [t]) (bracked (pToken TStrict >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_#List" [t]) (bracked (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!List" [t]) (bracked (pToken TStrict >>| type))
<|> liftM (\t -> Type "_List!" [t]) (bracked (type |<< pToken TStrict))
<|> liftM (\t -> Type "_List" [t]) (bracked type)
<|> liftM (\t -> Type "_#Array" [t]) (braced (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_32#Array" [t]) (braced (pToken (TInt 32) >>| pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!Array" [t]) (braced (pToken TStrict >>| type))
<|> liftM (\t -> Type "_Array" [t]) (braced type)
<|> liftM (\t -> Type "_#List!" [t]) (bracked (pToken TUnboxed >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_!List!" [t]) (bracked (pToken TStrict >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_#List" [t]) (bracked (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!List" [t]) (bracked (pToken TStrict >>| type))
<|> liftM (\t -> Type "_List!" [t]) (bracked (type |<< pToken TStrict))
<|> liftM (\t -> Type "_List" [t]) (bracked type)
<|> liftM (\ts -> Type ("_Tuple" +++ toString (length ts)) ts)
(parenthised (pSepBy1 type (pToken TComma)))
<|> (pToken TStrict >>| argtype) // ! ignored for now
......
......@@ -142,9 +142,10 @@ typeConstructorName isInfix isArg t as
| t == "_#List!" = if isInfix ("[#" -- as -- "!]") ("[#!]" -- as`)
| t == "_|List" = if isInfix ("[|" -- as -- "]") ("[|]" -- as`)
// Arrays
| t == "_#Array" = if isInfix ("{#" -- as -- "}") ("{#}" -- as`)
| t == "_Array" = if isInfix ("{" -- as -- "}") ("{}" -- as`)
| t == "_!Array" = if isInfix ("{!" -- as -- "}") ("{!}" -- as`)
| t == "_#Array" = if isInfix ("{#" -- as -- "}") ("{#}" -- as`)
| t == "_32#Array" = if isInfix ("{32#" -- as -- "}") ("{32#}" -- as`)
| t == "_Array" = if isInfix ("{" -- as -- "}") ("{}" -- as`)
| t == "_!Array" = if isInfix ("{!" -- 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