From 99d352221a8f32e5758bc9d51aded4c92999fcc4 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Sat, 30 Jun 2018 07:49:28 -0400 Subject: [PATCH] Type synonyms with quasiquotes or symbols outside refinements, #49. --- uom-plugin/liquid/Liquid.hs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/uom-plugin/liquid/Liquid.hs b/uom-plugin/liquid/Liquid.hs index b4eaf278..5a8f2902 100644 --- a/uom-plugin/liquid/Liquid.hs +++ b/uom-plugin/liquid/Liquid.hs @@ -1,18 +1,26 @@ -{-# LANGUAGE DataKinds#-} +{-# LANGUAGE DataKinds #-} {-# LANGUAGE QuasiQuotes #-} {-# OPTIONS_GHC -fplugin Data.UnitsOfMeasure.Plugin #-} -module Main (main) where +module Main (main, AB(..), Qs, Qm) where import Language.Haskell.Liquid.Liquid (liquid) -import Data.UnitsOfMeasure +import Data.UnitsOfMeasure (Quantity, u) import Data.UnitsOfMeasure.Defs () -{-@ type Qs = Quantity Double [u| s |] @-} + +-- NOTE: I cannot use quasiquotes or symbols with liquid haskell. type Qs = Quantity Double [u| s |] +type Qm = Quantity Double [u| m |] + +data AB + = A { x :: Quantity Double [u| s |] } + | B { y :: Quantity Double [u| m |] } + +{-@ data A = A {x :: Qs} | B {y :: Qm} @-} -minute :: Qs +minute :: Quantity Double [u| s |] minute = [u| 60 s |] main :: IO a