Skip to content

Enhancements

  • Eliminate empty type class dictionaries in generated code (#2768, @LiamGoodacre)

    Empty type class dictionaries — dictionaries which do not contain any type class member implementations at runtime — are often used to provide evidence at compile-time to justify that a particular operation will not fail; for example, Prim.Row.Cons can be used to justify that we can expect a record to contain a particular field with a particular type. Unfortunately, constructing empty dictionaries can be costly, especially in more complex scenarios such as type-level programming. This release implements a new optimization which avoids the need to build empty dictionaries at runtime by instead inserting undefined into the generated code. This optimization can both reduce code size and improve performance in certain contexts.

  • Render doc-comments for data constructors and type class members in HTML documentation (#3507, @marcosh)

    Documentation comments for data constructors and type class members are now picked up by purs docs, and will soon start appearing in Pursuit too. For example:

    -- | Doc-comments like this one were always rendered in Pursuit
    data Maybe a =
      -- | Now this one (for the Just constructor) will be rendered too
      = Just a
      -- | And this one (for Nothing)
      | Nothing
      
    -- | Doc-comments like this one were always rendered in Pursuit
    class Eq a where
      -- | Now this one (for the `eq` method) will be rendered too
      eq :: a -> a -> Boolean
  • Show diffs of rows in errors and hints (#3392, @dariooddenino)

    In type mismatches between rows, we now elide common labels so that the problem is easier to identify. For example, consider the following code, which has a type error due to the types of the b fields in the two records not matching:

    foo =
      { a: 1, b: "hi", c: 3, d: 4, e: 5 }
    bar =
      { a: 1, b: 2, c: 3, d: 4, e: 5 }
    baz =
      [ foo, bar ]

    Previously, the type error would include the entirety of each record type:

    Could not match type
            
      String
            
    with type
         
      Int
    
    while trying to match type ( a :: Int   
                               , b :: String
                               , c :: Int   
                               , d :: Int   
                               , e :: Int   
                               )            
    with type ( a :: Int
              , b :: Int
              , c :: Int
              , d :: Int
              , e :: Int
              )
    

    This can become quite difficult to read in the case of large record types. Now, we get this:

    Could not match type
            
      String
            
    with type
         
      Int
         
    while trying to match type                
                               ( b :: String
                               ...          
                               )            
                                            
    with type             
                ( b :: Int
                ...       
                ) 
    

Bug fixes

  • Remove more dead code in purs bundle (#3551, @rhendric)

    The dead code elimination in purs bundle now no longer incorrectly considers declarations to be used in the presence of local variables which happen to share their names, and is therefore able to remove these declarations when they are unused.

  • Fix parsing of comma-separated guards in let statements (#3713, @natefaubion)

    The 0.13 parser would previously choke on guards separated by commas in let statements within do/ado blocks, such as

    test = ado
      let
        foo
          | bar
          , baz =
            42
          | otherwise = 100
      in
        foo

    This has now been fixed.

Other

Assets 8
You can’t perform that action at this time.