News for hackers. Stuff that matters.
Re:Automated reasoning in F#, Scala, Haskell, C++, and Julia by tikhonj on Monday August 03, 2015 @02:17PM (#9998482)
This feels like something you could do with GADTs in Haskell and OCaml. Here's your example rendered with GADTs:

    {-# LANGUAGE DataKinds, GADTs, KindSignatures #-}

    data IsAdd = IsAdd | NotAdd

    data Expr :: IsAdd -> * where
      Add   :: [Expr 'NotAdd] -> Expr 'IsAdd
      Const :: Integer        -> Expr 'NotAdd
      ...                     -> Expr 'NotAdd
You could also use True and False instead of Add and IsAdd, or even type-level string literals as arbitrary symbols:

    data Expr :: Symbol -> * where
      Add   :: [Expr "NotAdd"] -> Expr "IsAdd"
      Const :: Integer         -> Expr "NotAdd"

There are no comments on this comment yet.