[Haskell-cafe] Representing record subtypes, sort of.

Karl Voelker karl at karlv.net
Tue Nov 11 03:32:19 UTC 2014


On Mon, Nov 10, 2014, at 05:44 PM, Kannan Goundan wrote:
> How would you represent this in Haskell?

If you don't mind turning on a few language extensions:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
module FS where
 
type Date = String
 
data FileKind = FILE | FOLDER
 
data Entry (k :: FileKind) where
  File   :: String -> Date -> Int -> Entry FILE
  Folder :: String -> String -> Entry FOLDER

https://gist.github.com/ktvoelker/296f40966e2f1d4846e2

-Karl


More information about the Haskell-Cafe mailing list