When should you use primitive types instead of custom types?

Instead of using unsafePartial $ fromJust ... I tend to use pattern matching and unsafeCrashWith, so in case my assumption gets invalidated at some point, I’ll get proper error message:

foo = case mkFoo "baz" of
  Nothing -> unsafeCrashWith "baz should be valid Foo"
  Just v -> v
2 Likes