core: make NULL Ptr a instead of a

This commit is contained in:
hellerve 2020-05-18 23:20:45 +02:00
parent 322fe028db
commit 32d4095a5d
2 changed files with 4 additions and 5 deletions

View File

@ -56,10 +56,9 @@ It is the inverse of [`just?`](#just?).")
(doc unsafe-ptr "Creates a `(Ptr a)` from a `(Maybe a)`. If the `Maybe` was
`Nothing`, this function will return a `NULL` value.")
(defn unsafe-ptr [a]
(the (Ptr a) (Unsafe.coerce
(match-ref a
(Nothing) NULL
(Just _) (the (Ref (Maybe a)) a)))))
(match-ref a
(Nothing) NULL
(Just _) ((the (Fn [(Ref (Maybe a))] (Ptr a)) Unsafe.coerce) a)))
(doc from-ptr "Creates a `(Maybe a)` from a `(Ptr a)`. If the `Ptr` was
`NULL`, this function will return `Nothing`.")

View File

@ -309,7 +309,7 @@ startingGlobalEnv noArray =
, envMode = ExternalEnv
, envFunctionNestingLevel = 0
}
where bindings = Map.fromList $ [ register "NULL" (VarTy "a")
where bindings = Map.fromList $ [ register "NULL" (PointerTy (VarTy "a"))
]
++ (if noArray then [] else [("Array", Binder emptyMeta (XObj (Mod arrayModule) Nothing Nothing))])
++ [("StaticArray", Binder emptyMeta (XObj (Mod staticArrayModule) Nothing Nothing))]