Skip to content

v0.9.0 (Beta 26.02.2021)

Compare
Choose a tag to compare
@mpscholten mpscholten released this 26 Feb 16:57
· 3122 commits to master since this release
883cf75

A lot has been done since the last IHP release in january. With v0.9 we're now getting closer to the first major version of IHP 🎉

Major Changes

  • Use the new GHC Garbage Collector: We now use the new non-moving GC which has been added in recent GHC versions. This avoids long GC pauses when it's time to free some memory. This will improve the production performance.

  • New Logging module:
    IHP was previously using putStrLn to log something. This has been replaced with a new IHP.Log modules that provides a unified logging solution for the full framework. The logger supports custom formatters and also custom log destinations (e.g. logging to a file instead of stdout/stderr).

    Check the full documentation here: https://ihp.digitallyinduced.com/Guide/logging.html

  • New Plugins: ihp-sentry and ihp-zip

    Add error reporting to your IHP apps with ihp-sentry
    Provides easy zip file downloads with ihp-zip
    Check the plugin's README for details on how to install them.

    If you're thinking about making your own IHP plugin, consider using these as the starting point :)

  • Custom WebSocket Servers:
    We now opened up the IHP WebSocket interface so that you can write your own WebSocket servers.

    Check out the new Guide on WebSockets: https://ihp.digitallyinduced.com/Guide/websockets.html

  • AutoRoute Improvements:
    In previous IHP versions AutoRoute by default only worked with UUID arguments (and Id types like Id Post). If you have a controller like data HelloWorldController = HelloAction { name :: Text } where you have a text parameter, you would have to configure AutoRoute manually using parseArgument. Also when we you had an action with two different types like HelloAction { userId :: Id User, name :: Maybe Text } this was not supported by AutoRoute.

    The type-magic has been reengineered and now it works with all types especially different types. If you have used parseArgument before, you need to remove that as these functions have been removed because this now works without manually configuring it.

  • Database Transactions:
    There's a new withTransaction function to run sql statements inside a single database transaction:

    withTransaction do
       company <- newRecord @Company |> createRecord
       user <- newRecord @User
           |> set #companyId (get #id company)
           |> createRecord
       company <- company
           |> setJust #ownerId (get #id user)
           |> updateRecord

    Check out the Guide for details: https://ihp.digitallyinduced.com/Guide/database.html#transactions

  • New Function: setJust:
    Like set but wraps the value in a Just. Across a lot of IHP code bases we spotted a pattern like |> set #field (Just(value)). The (Just ..) is basically just syntactical noise and makes the value expression kind of more complicated:

    -- BEFORE
    project |> set #userId (Just (get #id user))
    
    -- AFTER
    project |> setJust #userId (get #id user)
  • New Query Function: distinct: Use distinct to remove all duplicate rows from the result

    query @Book
        |> distinct
        |> fetch
    
    -- SELECT DISTINCT * FROM books
  • New Query Function: distinctOn: Use distinctOn to add a DISTINCT ON to your sql query.

    query @Book
        |> distinctOn #categoryId
        |> fetch
    
    -- SELECT DISTINCT ON (category_id) * FROM books
  • New Query Functions: filterWhereLike and friends:

    query @Book
        |> filterWhereLike (#title, "%haskell%")
        |> fetch
    
    -- SELECT * FROM books WHERE title LIKE '%haskell%'

    Additonally there's now also:
    - filterWhereILike (like filterWhereLike but case-insensitive)
    - filterWhereMatches filter with a postgres regex
    - filterWhereIMatches case-insensitive variant of filterWhereMatches

Other Changes

Updating

See the UPGRADE.md for upgrade instructions.

If you have any problems with updating, let us know on the IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be available in march.