Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the recommended way to have module-private record types without setting off -Wunused-top-binds?

This module

module Foo (Foo, qux) where

data Foo = Foo {bla::Int}

qux :: Foo
qux = Foo 37

causes a warning when compiled with -Wall:

/tmp/wtmpf-file12937.hs:3:17: warning: [-Wunused-top-binds]
    Defined but not used: ‘bla’
  |
3 | data Foo = Foo {bla::Int}
  |                 ^^^

Ok – if bla were just a standalone function, this would be easy and should be fixed by removing bla. But for a record, the fields do more than just provide a name that can be used, they also serve as documentation in the code.

What is the preferred way to get rid of the warning?

It should be a permanent solution, should preferrably keep the record as-is, and preferrably not disable any warnings for the rest of the module.

like image 325
leftaroundabout Avatar asked Sep 18 '19 15:09

leftaroundabout


People also ask

How do I restrict access to record types in Salesforce?

You can create a new record type and enable it for system admin profile only. Whenever you want to create a record that should be visible to admin only then choose this new record type. Other users will not be able to those records as they don't have access to that record type.

How do I control record visibility in Salesforce?

To define record level security in salesforce, first set your OWD (Org Wide Default) sharing settings and define a hierarchy, and then create sharing rules. It is easy that with roles, we can modify profile and permission set in Salesforce Org.

How do I restrict users to view only their own records?

On the 'Records' page there is 'Added by' filter, using which you can filter records by user who added it. You can always save the result in Report. If you want to restrict your User's group to access users only their own records you need to enable 'Access to only own records' option.


1 Answers

To avoid these, I usually add a definition like this to the module:

_unused :: a
_unused = error "don't complain" bla

The nice thing is you can chain them, like so:

_unused :: a
_unused = error "don't complain" bla bah foo bar

It's kind of crude, but gets the job done.

like image 179
alias Avatar answered Oct 16 '22 07:10

alias