
1 Sep
2022
1 Sep
'22
10:54 p.m.
On 01-09-22 16:33, Dominik Schrempf wrote:
Chiming in here, maybe I missed something. Liquid Haskell is great, but in this case, in my opinion, easier is better:
newtype LeftFoo = LeftFoo !Int
newtype RightFoo = RightFoo !Char
data Foo = LFoo LeftFoo | RFoo RightFoo – Probably with strictness annotations.
isLeftFoo :: Foo -> Bool isLeftFoo (LFoo _) = True isLeftFoo _ = False
takesOnlyLeftFoo :: LeftFoo -> Int takesOnlyLeftFoo (LeftFoo i) = i
Dominik
Chiming in here too. I do this all the time if the subpart is to be used on 2 or more places. Easiest way to do this without extensions. -- Rubén. (pgp: 1E88 3AC4 89EB FA22)