mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-25 05:43:19 +03:00
Use primitive constants as a last resort
This is for the situation where there's still an ambiguous overloading, we drop to using the built in primitive as a default.
This commit is contained in:
parent
27672444e4
commit
bdf6c03bf1
@ -6,6 +6,8 @@ beyond work on the language core, are (in no particular order):
|
||||
|
||||
* CI integration.
|
||||
* Documentation string support (at the REPL and IDE mode).
|
||||
* Generating HTML documentation from documentation strings (and possibly other
|
||||
formations)
|
||||
* A better REPL, including:
|
||||
- `it` and `:let`
|
||||
- readline and tab completion
|
||||
|
@ -38,15 +38,29 @@ expandAmbigName mode nest env orig args (IVar fc x) exp
|
||||
else pure $ IMustUnify fc "Name applied to arguments" orig
|
||||
Nothing =>
|
||||
do est <- get EST
|
||||
let prims = mapMaybe id
|
||||
[!fromIntegerName, !fromStringName, !fromCharName]
|
||||
fi <- fromIntegerName
|
||||
si <- fromStringName
|
||||
ci <- fromCharName
|
||||
let prims = mapMaybe id [fi, si, ci]
|
||||
let primApp = isPrimName prims x
|
||||
case !(lookupCtxtName x (gamma defs)) of
|
||||
[] => pure orig
|
||||
[nalt] => pure $ mkAlt primApp est nalt
|
||||
nalts => pure $ IAlternative fc Unique
|
||||
nalts => pure $ IAlternative fc (uniqType fi si ci x args)
|
||||
(map (mkAlt primApp est) nalts)
|
||||
where
|
||||
-- If there's multiple alternatives and all else fails, resort to using
|
||||
-- the primitive directly
|
||||
uniqType : Maybe Name -> Maybe Name -> Maybe Name -> Name ->
|
||||
List (FC, Maybe (Maybe Name), RawImp) -> AltType
|
||||
uniqType (Just fi) _ _ n [(_, _, IPrimVal fc (BI x))]
|
||||
= UniqueDefault (IPrimVal fc (BI x))
|
||||
uniqType _ (Just si) _ n [(_, _, IPrimVal fc (Str x))]
|
||||
= UniqueDefault (IPrimVal fc (Str x))
|
||||
uniqType _ _ (Just ci) n [(_, _, IPrimVal fc (Ch x))]
|
||||
= UniqueDefault (IPrimVal fc (Ch x))
|
||||
uniqType _ _ _ _ _ = Unique
|
||||
|
||||
buildAlt : RawImp -> List (FC, Maybe (Maybe Name), RawImp) ->
|
||||
RawImp
|
||||
buildAlt f [] = f
|
||||
|
Loading…
Reference in New Issue
Block a user