You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.
While looking at the type signature of window, it uses data-default in order to provide default instances for various types.
However, there are no nonDefault versions of these functions, which I find extremely odd! I was going to try adding them. But I considered "when you have a non-Default version that takes an initial value, why even bother with a default version when you can just say window clk rst def siganyway?
But thinking about that, I thought "why even say def when normally I would say like, 0 anyway?* Thinking more, I decided to start looking around, and there aren't really that many uses of default around the place? There are mostly some basic instances for Vec and other things like Index, but almost all of these uses are trivial, and I'm not sure they buy us anything anyway. Actual clash code doesn't really use it -- and in the case it does, like window, it's actually kind of annoying!
For reference, at $WORK right now, we have thousands of lines of Clash code and supporting Haskell code and we don't even use default anywhere in the actual Clash code, and only use it once in supporting Haskell code. We would not miss it.
There are plenty of reasons to dislike default: mostly, it's a kind of meaningless class that's hard to control, and has no laws. Personally I have always found something like Monoid at least to be much more useful. In the above example, for instance, it's limiting window, and adding other versions of window is just pointless duplication. Adding newtypes is a bit difficult (due to the way the compiler works regarding coercions right now, as @christiaanb and I have talked about) and awkward way of working around this just for brevity in 1% of scenarios, and it's not like you save that much anyway.
Plus, for things like Index or Unsigned -- they already have Num instances anyway with fromInteger, so writing '0' is shorter than def anyway :)
(This also reduces the dependency footprint of clash-prelude somewhat which is always great as well.)
The text was updated successfully, but these errors were encountered:
While looking at the type signature of
window
, it usesdata-default
in order to provide default instances for various types.However, there are no non
Default
versions of these functions, which I find extremely odd! I was going to try adding them. But I considered "when you have a non-Default version that takes an initial value, why even bother with a default version when you can just saywindow clk rst def sig
anyway?But thinking about that, I thought "why even say def when normally I would say like, 0 anyway?* Thinking more, I decided to start looking around, and there aren't really that many uses of default around the place? There are mostly some basic instances for
Vec
and other things likeIndex
, but almost all of these uses are trivial, and I'm not sure they buy us anything anyway. Actual clash code doesn't really use it -- and in the case it does, likewindow
, it's actually kind of annoying!For reference, at
$WORK
right now, we have thousands of lines of Clash code and supporting Haskell code and we don't even use default anywhere in the actual Clash code, and only use it once in supporting Haskell code. We would not miss it.There are plenty of reasons to dislike default: mostly, it's a kind of meaningless class that's hard to control, and has no laws. Personally I have always found something like
Monoid
at least to be much more useful. In the above example, for instance, it's limitingwindow
, and adding other versions of window is just pointless duplication. Adding newtypes is a bit difficult (due to the way the compiler works regarding coercions right now, as @christiaanb and I have talked about) and awkward way of working around this just for brevity in 1% of scenarios, and it's not like you save that much anyway.Plus, for things like
Index
orUnsigned
-- they already haveNum
instances anyway withfromInteger
, so writing '0' is shorter thandef
anyway :)(This also reduces the dependency footprint of
clash-prelude
somewhat which is always great as well.)The text was updated successfully, but these errors were encountered: