Skip to content

Commit

Permalink
fix: Output checked type in getSelectionTypeOrKind if none is synthed
Browse files Browse the repository at this point in the history
  • Loading branch information
georgefst committed Jun 8, 2023
1 parent 515d39d commit c783fdb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions primer/src/Primer/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import Control.Monad.Writer (MonadWriter)
import Control.Monad.Zip (MonadZip)
import Data.Map qualified as Map
import Data.Tuple.Extra (curry3)
import Optics (ifoldr, over, preview, to, traverseOf, view, (%), (^.), _Just)
import Optics (afailing, ifoldr, over, preview, to, traverseOf, view, (%), (^.), _Just)
import Primer.API.NodeFlavor qualified as Flavor
import Primer.API.RecordPair (RecordPair (RecordPair))
import Primer.Action (ActionError, ProgAction, toProgActionInput, toProgActionNoInput)
Expand Down Expand Up @@ -168,6 +168,7 @@ import Primer.Core (
unLocalName,
unsafeMkLocalName,
_bindMeta,
_chkedAt,
_exprMetaLens,
_synthed,
_type,
Expand Down Expand Up @@ -1326,7 +1327,7 @@ getSelectionTypeOrKind = curry $ logAPI (noError GetTypeOrKind) $ \(sid, sel0) -
viewExprType :: ExprMeta -> TypeOrKind
viewExprType = Type . fromMaybe trivialTree . viewExprType'
viewExprType' :: ExprMeta -> Maybe Tree
viewExprType' = preview $ _type % _Just % _synthed % to (viewTreeType' . mkIds)
viewExprType' = preview $ _type % _Just % (_synthed `afailing` _chkedAt) % to (viewTreeType' . mkIds)
-- We prefix ids to keep them unique from other ids in the emitted program
mkIds :: Type' () -> Type' Text
mkIds = over _typeMeta (("seltype-" <>) . show . getID) . create' . generateTypeIDs
Expand Down

0 comments on commit c783fdb

Please sign in to comment.