Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Constructor classes and type classes. (PATRICK BROWNE)


----------------------------------------------------------------------

Message: 1
Date: Fri, 4 Nov 2016 00:10:26 +0000
From: PATRICK BROWNE <patrick.bro...@dit.ie>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Constructor classes and type classes.
Message-ID:
        <CAGFLrKcRtO6zBYPtwLNTBbfcfxTRS92vKWf0TC=mxrkmtx9...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Imants
Thanks for the sanity check on the instances.

I am concerned about the use of the function immsucc' from the same paper
<http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.36.9395>, which is
defined in instances the Time class (but omitted from the class). The
function  immsucc' is first used without arguments, which to me implies
that it 'might' a function passed to the higher-order closure function. It
is then used as just an ordinary function with arguments. I have found a
version of closure based on Craft of Function Programming.
<https://github.com/buntine/Haskell--Craft-of-FP/blob/master/AbsTypes/Relation.lhs>
which
does not require a function as an argument.

So basically my question is: does the usage of immsucc' make sense in the
code below?, do the types match up?
Regards,
Pat



data TimeFacts t = Bef (t, t, TimeFacts t) | New

class SetClass t => Time l t where
 new :: (t, t) -> l t
 bef :: (t, t, l t) -> l t
 succ , pred :: (t, l t) -> Set t
 immsucc , immpred :: (t, l t) -> Set t
 before, after :: (t, t, l t) -> Bool
 immedbefore, immedafter :: (t, t, l t) -> Bool
 immedafter (a, b, t) = immedbefore (b, a, t)
 after (a, b, t) = before (b, a, t)
 before (a, b, t) = memberInSet (b, succ (a, t))
 succ (a, tl) = closure ([a], immsucc' , tl)
 pred (a, tl) = closure ([a], immpred' , tl)
 immsucc (a, tl) = immsucc' ([a], [], tl)
 immpred (a, tl) = immpred' ([a], [], tl)

instance (SetClass t) => Time TimeFacts t where
 immsucc’ (a, s, New ) = s
 immsucc’ (a, s, Bef (e, f, tt)) = if memberInSet (e,a) then immsucc’ (a,
insertInSet (f,s), tt) else immsucc’ (a, s,tt)


On 3 November 2016 at 18:05, Imants Cekusins <ima...@gmail.com> wrote:

> this builds. not sure if the instances are as intended
>
>
> {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
> module SetClass where
>
> data TimeFacts t = Bef (t, t, TimeFacts t) | New
>
> class SetClass t  where
> class SetClass t => Time l t  where
> class Time l t => TimeE l t where
> class Time l t => TimeTO l t where
>
>
> instance SetClass (TimeFacts t) where -- OK
> instance (SetClass t) => Time (TimeFacts t) t where
> instance (SetClass t) => TimeE (TimeFacts t) t where
> instance (SetClass t) => TimeTO (TimeFacts t) t where
>
> ​
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>

-- 


This email originated from DIT. If you received this email in error, please 
delete it from your system. Please note that if you are not the named 
addressee, disclosing, copying, distributing or taking any action based on 
the contents of this email or attachments is prohibited. www.dit.ie

Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí 
earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an 
seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon 
dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa 
ríomhphost nó sna hiatáin seo. www.dit.ie

Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to 
Grangegorman <http://www.dit.ie/grangegorman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20161104/24a37a6e/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 101, Issue 5
*****************************************

Reply via email to