Skip to content

Spurious rejection of polymorphic types at the syntactic top level #2425

Open
@sauclovian-g

Description

@sauclovian-g

You can't bind polymorphic terms at the syntactic top level:

f <- return concat;

produces

% saw test.saw
[22:19:20.624] Loading file "test.saw"
[22:19:20.625] Stack trace:
Not a monomorphic type: [t.5] -> [t.5] -> [t.5]

It's not clear what the reason for this restriction might be. One might guess it was cargo-culted from Haskell's monomorphism restriction. Based on https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-930004.5.5, there are roughly speaking three reasons for the monomorphism restriction: confusing lazy evaluation behavior (SAWScript doesn't have lazy evaluation, and besides, the behavior in question is perfectly sound); certain ambiguous cases arising from typeclass constraints (SAWScript doesn't have typeclasses); and other ambiguous cases arising from having modules (SAWScript has no module system). Therefore, there's no need for any related constraint in SAWScript.

Unless some other reason appears, this restriction should be removed.

(This point has come up before, e.g. when I was fixing the typechecker, but I can't find an existing issue about it.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    subsystem: saw-scriptIssues related to the SAWScript language and/or its interpretation and executiontech debtIssues that document or involve technical debttopics: error-handlingIssues involving the way SAW responds to an error conditiontype: bugIssues reporting bugs or unexpected/unwanted behaviorusabilityAn issue that impedes efficient understanding and use

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions